use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class ControlQueriesTest method testQueryDecl2.
@Test
public void testQueryDecl2() {
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("queryDecl2");
int count = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Production, p));
assertEquals("IContent", ((Production) p).getName().getValue());
count++;
}
assertEquals(1, count);
}
use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class ControlQueriesTest method testQueryDecl6.
@Test
public void testQueryDecl6() {
// not used
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("queryDecl6");
int count = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
if (++count == 1)
assertEquals(5, p.wIntValue());
else if (count == 2)
assertEquals(10, p.wIntValue());
else if (count == 3)
assertEquals(8, p.wIntValue());
}
assertEquals(3, count);
}
use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class ControlQueriesTest method testQueryDecl1.
@Test
public void testQueryDecl1() {
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("queryDecl1");
int count = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Production, p));
assertEquals("IContent", ((Production) p).getName().getValue());
count++;
}
assertEquals(1, count);
}
use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testPatternWithVariablePredicate.
@Test
public void testPatternWithVariablePredicate() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
StringBuilder names = new StringBuilder();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
IEntityIterator<Production> iterator = BehaviorUtils.<Production>compileAndLazyEvaluate((PathExpression) tm.create("path8"), g, bm);
for (Production p : iterator) {
Assert.assertEquals(bm.wStringValue("name"), p.getName().getValue());
names.append(p.getName().getValue());
}
Assert.assertEquals("VersionEncodingValueNameNameSpaceCharDataCDataSectDataCommentText", names.toString());
}
use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testPatternPredicate.
@Test
public void testPatternPredicate() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
int count = 0;
for (As as : BehaviorUtils.<As>compileAndLazyEvaluate((PathExpression) tm.create("path7"), g)) {
Assert.assertEquals("tag", as.getName().wStringValue());
count++;
}
Assert.assertEquals(2, count);
}
Aggregations