use of org.whole.lang.grammars.util.TestXmlGrammar in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testVariablesInQuantifiedPredicate.
@Test
public void testVariablesInQuantifiedPredicate() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("recursiveProduction6");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
IEntityIterator<Production> iterator = BehaviorUtils.<Production>compileAndLazyEvaluate(pe1, g, bm);
iterator.next();
Assert.assertTrue(bm.wIsSet("pname"));
Assert.assertTrue(bm.wIsSet("nt"));
pe1 = (PathExpression) tm.create("exactlyOneDefUse");
bm = BindingManagerFactory.instance.createArguments();
iterator = BehaviorUtils.<Production>compileAndLazyEvaluate(pe1, g, bm);
iterator.next();
Assert.assertTrue(bm.wIsSet("pname"));
Assert.assertTrue(bm.wIsSet("nt"));
pe1 = (PathExpression) tm.create("unusedProduction");
bm = BindingManagerFactory.instance.createArguments();
iterator = BehaviorUtils.<Production>compileAndLazyEvaluate(pe1, g, bm);
iterator.next();
Assert.assertTrue(bm.wNames().isEmpty());
}
use of org.whole.lang.grammars.util.TestXmlGrammar in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testSingleVariableTestInPathExpPredicateOfPathInternalStep.
@Test
public void testSingleVariableTestInPathExpPredicateOfPathInternalStep() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("findAllNonTerminalsUsed");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
// FIXME bm.wDefValue("pname", "Element");
bm.wDef("pname", GrammarsEntityFactory.instance.createNonTerminal("IName"));
int count = 0;
for (NonTerminal nt : BehaviorUtils.<NonTerminal>compileAndLazyEvaluate(pe1, g, bm)) count++;
Assert.assertEquals(4, count);
}
use of org.whole.lang.grammars.util.TestXmlGrammar in project whole by wholeplatform.
the class RewriteQueriesTest method testDelete3.
@Test
public void testDelete3() {
Grammar model = new TestXmlGrammar().create();
ITemplateManager tm = RewriteQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("delete3");
for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Name, entity) || EntityUtils.isResolver(entity));
for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(EntityUtils.isResolver(entity));
}
use of org.whole.lang.grammars.util.TestXmlGrammar in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplateWithTwoNestedSimpleQueries.
@Test
public void testSelectTemplateWithTwoNestedSimpleQueries() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("selectTemplateWithTwoNestedSimpleQueries");
for (Feature f : BehaviorUtils.<Feature>compileAndLazyEvaluate(pe1, g)) {
assertEquals(ModelsEntityDescriptorEnum.Feature, f.wGetEntityDescriptor());
}
}
use of org.whole.lang.grammars.util.TestXmlGrammar in project whole by wholeplatform.
the class SelectQueriesTest method testSelectPathExpression2.
@Test
public void testSelectPathExpression2() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Grammar model = new TestXmlGrammar().create();
PathExpression query = (PathExpression) tm.create("selectPath2");
StringBuilder names = new StringBuilder();
for (NonTerminal nt : BehaviorUtils.<NonTerminal>compileAndLazyEvaluate(query, model)) names.append(nt.getValue());
assertEquals("DocumentElementINameIContent", names.toString());
}
Aggregations