Package com.google.template.soy.exprtree.OperatorNodes

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


    expr = (new ExpressionParser("not false")).parseExpression();
    NotOpNode notOp = (NotOpNode) expr.getChild(0);
    assertEquals(false, ((BooleanNode) notOp.getChild(0)).getValue());

    expr = (new ExpressionParser("90 -14.75")).parseExpression();
    MinusOpNode minusOp = (MinusOpNode) expr.getChild(0);
    assertEquals(90, ((IntegerNode) minusOp.getChild(0)).getValue());
    assertEquals(14.75, ((FloatNode) minusOp.getChild(1)).getValue());

    expr = (new ExpressionParser("$a or true")).parseExpression();
    OrOpNode orOp = (OrOpNode) expr.getChild(0);
    assertEquals("$a", orOp.getChild(0).toSourceString());
    assertEquals(true, ((BooleanNode) orOp.getChild(1)).getValue());
View Full Code Here


  }


  public void testNotImplemented() throws SoySyntaxException {

    MinusOpNode expr = new MinusOpNode();
    expr.addChild(new FloatNode(17.0));

    DataRefNode dataRef = new DataRefNode(false, false, "boo");
    expr.addChild(dataRef);

    IncompleteEvalVisitor iev = new IncompleteEvalVisitor(ImmutableMap.of("boo", 13.0));

    try {
      iev.exec(expr);
View Full Code Here

    //             [DataRefNode] $x
    //             [DataRefNode] $x
    //       [DataRefNode] $x

    // Root n0.
    MinusOpNode n0 = new MinusOpNode();
    // Children of n0.
    MinusOpNode n1 = new MinusOpNode();
    MinusOpNode n2 = new MinusOpNode();
    n0.addChild(n1);
    n0.addChild(n2);
    // Children of n1.
    NegativeOpNode n3 = new NegativeOpNode();
    n1.addChild(x);
    n1.addChild(n3);
    // Child of n3.
    n3.addChild(x);
    // Children of n2.
    NegativeOpNode n4 = new NegativeOpNode();
    n2.addChild(n4);
    n2.addChild(x);
    // Child of n4.
    MinusOpNode n5 = new MinusOpNode();
    n4.addChild(n5);
    // Children of n5.
    n5.addChild(x);
    n5.addChild(x);

    assertEquals("$x - -$x - (-($x - $x) - $x)", n0.toSourceString());
  }
View Full Code Here

  }


  public void testInterfaceImplementation() throws SoySyntaxException {

    MinusOpNode expr = new MinusOpNode();
    expr.addChild(new IntegerNode(17));

    DataRefNode dataRef = new DataRefNode(false, false, "boo");
    expr.addChild(dataRef);

    IncompleteEvalVisitor iev = new IncompleteEvalVisitor(ImmutableMap.of("boo", 13.0));
    assertEquals(4.0, iev.exec(expr));

    expr.replaceChild(0, new IntegerNode(34));

    assertEquals(21.0, iev.exec(expr));
  }
View Full Code Here

TOP

Related Classes of com.google.template.soy.exprtree.OperatorNodes.MinusOpNode

Copyright © 2018 www.massapicom. 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.