Search in sources :

Example 1 with LegacyObjectMapLiteralNode

use of com.google.template.soy.exprtree.LegacyObjectMapLiteralNode in project closure-templates by google.

the class ParseExpressionTest method testParseListsAndMaps.

@Test
public void testParseListsAndMaps() throws Exception {
    ExprNode expr = assertThatExpression("[]").isValidExpression();
    assertThat(((ListLiteralNode) expr).numChildren()).isEqualTo(0);
    expr = assertThatExpression("[55]").isValidExpression();
    assertThat(((ListLiteralNode) expr).numChildren()).isEqualTo(1);
    expr = assertThatExpression("[55,]").isValidExpression();
    assertThat(((ListLiteralNode) expr).numChildren()).isEqualTo(1);
    expr = assertThatExpression("['blah', 123, $boo]").isValidExpression();
    assertThat(((ListLiteralNode) expr).numChildren()).isEqualTo(3);
    expr = assertThatExpression("['blah', 123, $boo,]").isValidExpression();
    assertThat(((ListLiteralNode) expr).numChildren()).isEqualTo(3);
    expr = assertThatExpression("[:]").isValidExpression();
    assertThat(((LegacyObjectMapLiteralNode) expr).numChildren()).isEqualTo(0);
    expr = assertThatExpression("['aa': 55]").isValidExpression();
    assertThat(((LegacyObjectMapLiteralNode) expr).numChildren()).isEqualTo(2);
    expr = assertThatExpression("['aa': 55,]").isValidExpression();
    assertThat(((LegacyObjectMapLiteralNode) expr).numChildren()).isEqualTo(2);
    expr = assertThatExpression("['aaa': 'blah', 'bbb': 123, $foo.bar: $boo]").isValidExpression();
    assertThat(((LegacyObjectMapLiteralNode) expr).numChildren()).isEqualTo(6);
    expr = assertThatExpression("['aaa': 'blah', 'bbb': 123, $foo.bar: $boo,]").isValidExpression();
    assertThat(((LegacyObjectMapLiteralNode) expr).numChildren()).isEqualTo(6);
}
Also used : ExprNode(com.google.template.soy.exprtree.ExprNode) ListLiteralNode(com.google.template.soy.exprtree.ListLiteralNode) LegacyObjectMapLiteralNode(com.google.template.soy.exprtree.LegacyObjectMapLiteralNode) Test(org.junit.Test)

Aggregations

ExprNode (com.google.template.soy.exprtree.ExprNode)1 LegacyObjectMapLiteralNode (com.google.template.soy.exprtree.LegacyObjectMapLiteralNode)1 ListLiteralNode (com.google.template.soy.exprtree.ListLiteralNode)1 Test (org.junit.Test)1