use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testLookaheadScope.
@Test
public void testLookaheadScope() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
String[] templates = { "findNonTerminalOccurrences", "findProduction", "bindNonTerminalOccurrences", "recursiveProduction2", "testProduct1", "testProduct2", "testProduct3" };
for (String template : templates) {
PathExpression pe1 = (PathExpression) tm.create(template);
IBindingManager bm = BindingManagerFactory.instance.createArguments();
IEntityIterator<IEntity> i1 = BehaviorUtils.<IEntity>compileAndLazyEvaluate(pe1, g, bm);
IEntity p1 = null;
while ((p1 = i1.lookahead()) != null) {
Set<String> s1 = i1.lookaheadScope().wNames();
IEntity p2 = i1.next();
// false for tuples Assert.assertSame(p1,p2);
Assert.assertEquals(bm.wNames().size(), s1.size());
for (String name : s1) Assert.assertTrue(bm.wIsSet(name));
}
}
}
Aggregations