Search in sources :

Example 6 with SoyList

use of com.google.template.soy.data.SoyList in project closure-templates by google.

the class EvalVisitorTest method testEvalListLiteral.

@Test
public void testEvalListLiteral() throws Exception {
    SoyList result = (SoyList) eval("['blah', 123, $boo]");
    assertThat(result.length()).isEqualTo(3);
    assertThat(result.get(0).stringValue()).isEqualTo("blah");
    assertThat(result.get(1).integerValue()).isEqualTo(123);
    assertThat(result.get(2).integerValue()).isEqualTo(8);
    // trailing comma
    result = (SoyList) eval("['blah', 123, $boo,]");
    assertThat(result.length()).isEqualTo(3);
    assertThat(result.get(0).stringValue()).isEqualTo("blah");
    assertThat(result.get(1).integerValue()).isEqualTo(123);
    assertThat(result.get(2).integerValue()).isEqualTo(8);
    result = (SoyList) eval("[]");
    assertThat(result.length()).isEqualTo(0);
}
Also used : SoyList(com.google.template.soy.data.SoyList) Test(org.junit.Test)

Aggregations

SoyList (com.google.template.soy.data.SoyList)6 Test (org.junit.Test)5 SoyValue (com.google.template.soy.data.SoyValue)3 SoyValueProvider (com.google.template.soy.data.SoyValueProvider)1 FloatData (com.google.template.soy.data.restricted.FloatData)1 StringData (com.google.template.soy.data.restricted.StringData)1 RangeArgs (com.google.template.soy.shared.RangeArgs)1 ForNonemptyNode (com.google.template.soy.soytree.ForNonemptyNode)1