Search in sources :

Example 6 with AlternatesWithInst

use of com.squarespace.template.Instructions.AlternatesWithInst in project template-compiler by Squarespace.

the class InstructionEqualityTest method testAlternatesWithEquals.

@Test
public void testAlternatesWithEquals() throws CodeSyntaxException {
    CodeMaker mk = maker();
    AlternatesWithInst a1 = mk.alternates();
    AlternatesWithInst a2 = mk.alternates();
    assertEquals(a1, a2);
    assertFalse(a1.equals(null));
    a1.getConsequent().add(mk.text("foo"));
    assertNotEquals(a1, a2);
    assertNotEquals(a1, mk.section("foo"));
    assertNotEquals(a1, mk.end());
    a2.getConsequent().add(mk.text("foo"));
    assertEquals(a1, a2);
    a1.setAlternative(mk.text("bar"));
    assertNotEquals(a1, a2);
    assertNotEquals(a1, mk.section("foo"));
    assertNotEquals(a1, mk.end());
    a2.setAlternative(mk.text("bar"));
    assertEquals(a1, a2);
}
Also used : AlternatesWithInst(com.squarespace.template.Instructions.AlternatesWithInst) Test(org.testng.annotations.Test)

Aggregations

AlternatesWithInst (com.squarespace.template.Instructions.AlternatesWithInst)6 Test (org.testng.annotations.Test)4 RepeatedInst (com.squarespace.template.Instructions.RepeatedInst)3 IfInst (com.squarespace.template.Instructions.IfInst)1 IfPredicateInst (com.squarespace.template.Instructions.IfPredicateInst)1 PredicateInst (com.squarespace.template.Instructions.PredicateInst)1 RootInst (com.squarespace.template.Instructions.RootInst)1 SectionInst (com.squarespace.template.Instructions.SectionInst)1 TextInst (com.squarespace.template.Instructions.TextInst)1 VariableInst (com.squarespace.template.Instructions.VariableInst)1