use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class SelectQueriesTest method testSelectDistinct.
@Test
public void testSelectDistinct() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("selectNonTerminalSet");
Set<String> set = new HashSet<String>();
for (NonTerminal nt : BehaviorUtils.<NonTerminal>compileAndLazyEvaluate(pe1, g)) if (!set.add(nt.getValue()))
fail();
assertEquals(22, set.size());
}
use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTupleWithTemplates.
@Test
public void testSelectTupleWithTemplates() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Grammar model = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
PathExpression query = (PathExpression) tm.create("selectTupleWithTemplates");
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
FieldDeclaration fd = (FieldDeclaration) tuple.wGet(0);
Feature f = (Feature) tuple.wGet(1);
As e = (As) tuple.wGet(2);
assertEquals(e.getName().getValue(), fd.getFragments().wGet(0).wGet(0).wStringValue());
assertEquals(e.getRule().wStringValue(), fd.getType().wStringValue());
assertEquals(e.getName().getValue(), f.getName().wStringValue());
assertEquals(e.getRule().wStringValue(), f.getType().wStringValue());
}
}
use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class ControlQueriesTest method testQueryDecl4.
@Test
public void testQueryDecl4() {
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("queryDecl4");
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 testCall7.
@Test
public void testCall7() {
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("call7");
int count = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
assertTrue(EntityUtils.isData(p));
assertEquals("myNameImpl", p.wStringValue());
count++;
}
assertEquals(1, count);
}
use of org.whole.lang.grammars.model.Grammar in project whole by wholeplatform.
the class ControlQueriesTest method testQueryDecl3.
@Test
public void testQueryDecl3() {
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("queryDecl3");
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);
}
Aggregations