Examples of PlusOpNode


Examples of com.google.template.soy.exprtree.OperatorNodes.PlusOpNode


  public void testSubstituteGlobals() throws Exception {

    ExprRootNode<?> expr = (new ExpressionParser("BOO + 'aaa' + foo.GOO")).parseExpression();
    PlusOpNode plus0 = (PlusOpNode) expr.getChild(0);
    PlusOpNode plus1 = (PlusOpNode) plus0.getChild(0);

    assertEquals("BOO", ((GlobalNode) plus1.getChild(0)).getName());
    assertEquals("foo.GOO", ((GlobalNode) plus0.getChild(1)).getName());

    Map<String, PrimitiveData> globals =
        ImmutableMap.<String, PrimitiveData>of(
            "BOO", StringData.forValue("boo"), "foo.GOO", StringData.forValue("goo"),
            "foo.MOO", StringData.forValue("moo"));
    ((new SubstituteGlobalsVisitor(globals, false)).new SubstituteGlobalsInExprVisitor())
        .exec(expr);

    assertEquals("boo", ((StringNode) plus1.getChild(0)).getValue());
    assertEquals("goo", ((StringNode) plus0.getChild(1)).getValue());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.