use of com.google.template.soy.exprtree.OperatorNodes.GreaterThanOpNode in project closure-templates by google.
the class TemplateParserTest method testParseIfStmt.
@Test
public void testParseIfStmt() throws Exception {
String templateBody = "{@param zoo : ?}{@param boo: ?}{@param foo : ?}{@param moo : ?}\n" + " {if $zoo}{$zoo}{/if}\n" + " {if $boo}\n" + " Blah\n" + " {elseif $foo.goo > 2}\n" + " {$moo}\n" + " {else}\n" + " Blah {$moo}\n" + " {/if}\n";
List<StandaloneNode> nodes = parseTemplateContent(templateBody, FAIL).getChildren();
assertEquals(2, nodes.size());
IfNode in0 = (IfNode) nodes.get(0);
assertEquals(1, in0.numChildren());
IfCondNode in0icn0 = (IfCondNode) in0.getChild(0);
assertEquals("$zoo", in0icn0.getExpr().toSourceString());
assertEquals(1, in0icn0.numChildren());
assertEquals("$zoo", ((PrintNode) in0icn0.getChild(0)).getExpr().toSourceString());
assertTrue(in0icn0.getExpr().getRoot() instanceof VarRefNode);
IfNode in1 = (IfNode) nodes.get(1);
assertEquals(3, in1.numChildren());
IfCondNode in1icn0 = (IfCondNode) in1.getChild(0);
assertEquals("$boo", in1icn0.getExpr().toSourceString());
assertTrue(in1icn0.getExpr().getRoot() instanceof VarRefNode);
IfCondNode in1icn1 = (IfCondNode) in1.getChild(1);
assertEquals("$foo.goo > 2", in1icn1.getExpr().toSourceString());
assertTrue(in1icn1.getExpr().getRoot() instanceof GreaterThanOpNode);
assertEquals("{if $boo}Blah{elseif $foo.goo > 2}{$moo}{else}Blah {$moo}{/if}", in1.toSourceString());
}
Aggregations