Search in sources :

Example 1 with NotEqualOpNode

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

the class AbstractOperatorNodeTest method testToSourceString2.

@Test
public void testToSourceString2() {
    // Test expression: not $x ? $x != $x : $x * $x
    // 
    // The expression tree looks like this:
    // [ConditionalOpNode] n0
    // [NotOpNode] n1
    // [VarRefNode] $x
    // [NotEqualOpNode] n2
    // [VarRefNode] $x
    // [VarRefNode] $x
    // [TimesOpNode] n3
    // [VarRefNode] $x
    // [VarRefNode] $x
    // Root n0.
    ConditionalOpNode n0 = new ConditionalOpNode(X);
    // Children of n0.
    NotOpNode n1 = new NotOpNode(X);
    NotEqualOpNode n2 = new NotEqualOpNode(X);
    TimesOpNode n3 = new TimesOpNode(X);
    n0.addChild(n1);
    n0.addChild(n2);
    n0.addChild(n3);
    // Child of n1.
    n1.addChild(x);
    // Children of n2.
    n2.addChild(x.copy(new CopyState()));
    n2.addChild(x.copy(new CopyState()));
    // Children of n3.
    n3.addChild(x.copy(new CopyState()));
    n3.addChild(x.copy(new CopyState()));
    assertThat(n0.toSourceString()).isEqualTo("not $x ? $x != $x : $x * $x");
}
Also used : ConditionalOpNode(com.google.template.soy.exprtree.OperatorNodes.ConditionalOpNode) TimesOpNode(com.google.template.soy.exprtree.OperatorNodes.TimesOpNode) NotOpNode(com.google.template.soy.exprtree.OperatorNodes.NotOpNode) CopyState(com.google.template.soy.basetree.CopyState) NotEqualOpNode(com.google.template.soy.exprtree.OperatorNodes.NotEqualOpNode) Test(org.junit.Test)

Aggregations

CopyState (com.google.template.soy.basetree.CopyState)1 ConditionalOpNode (com.google.template.soy.exprtree.OperatorNodes.ConditionalOpNode)1 NotEqualOpNode (com.google.template.soy.exprtree.OperatorNodes.NotEqualOpNode)1 NotOpNode (com.google.template.soy.exprtree.OperatorNodes.NotOpNode)1 TimesOpNode (com.google.template.soy.exprtree.OperatorNodes.TimesOpNode)1 Test (org.junit.Test)1