use of com.squarespace.template.Instructions.RootInst in project template-compiler by Squarespace.
the class HardSoftCodeLimiterTest method testSoftLimit.
@Test
public void testSoftLimit() throws CodeException {
TestHandler handler = new TestHandler(Limit.SOFT, 6);
CodeLimiter limiter = HardSoftCodeLimiter.builder().setSoftLimit(5).setResolution(1).setHandler(handler).build();
JsonNode node = JsonUtils.decode("[0,1,2,3,4,5,6,7,8,9]");
Context ctx = new Context(node);
ctx.setCodeLimiter(limiter);
RootInst root = builder().repeated("@").var("@").end().eof().build();
ctx.execute(root);
assertTrue(handler.wasCalled());
}
use of com.squarespace.template.Instructions.RootInst in project template-compiler by Squarespace.
the class InstructionEqualityTest method testRootEquals.
@Test
public void testRootEquals() throws CodeSyntaxException {
CodeMaker mk = maker();
RootInst r1 = mk.root();
RootInst r2 = mk.root();
assertEquals(r1, r2);
assertFalse(r1.equals(null));
assertNotEquals(r1, mk.end());
assertNotEquals(r1, mk.section("foo"));
r1.getConsequent().add(mk.text("foo"));
assertNotEquals(r1, r2);
assertNotEquals(r1, mk.end());
r2.getConsequent().add(mk.text("foo"));
assertEquals(r1, r2);
r2.getConsequent().add(mk.end());
assertNotEquals(r1, r2);
}
Aggregations