use of org.whole.lang.bindings.IBindingManager 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.bindings.IBindingManager in project whole by wholeplatform.
the class SelectQueriesTest method testVariableScopes.
@Test
public void testVariableScopes() {
Model model = new XmlModel().create();
ITemplateManager tm = SelectQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("selectVariableScopes");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
Document d = (Document) tuple.wGet(0);
SimpleEntity se = (SimpleEntity) tuple.wGet(1);
assertFalse(bm.wIsSet("fromName"));
assertFalse(bm.wIsSet("oneTime"));
assertFalse(bm.wIsSet("featuresTimes"));
assertFalse(bm.wIsSet("featuresTimesInLine"));
assertFalse(bm.wIsSet("fTimes"));
assertFalse(bm.wIsSet("siblingTimes"));
// changed semantics: from variables are substituted multiple times
assertTrue(1 < d.wGet(0).wSize() - 1);
assertEquals(1, d.wGet(1).wSize() - 1);
assertEquals(se.getFeatures().wSize(), d.wGet(2).wSize() - 1);
assertEquals(se.getFeatures().wSize(), d.wGet(3).wSize() - 1);
assertEquals(model.getDeclarations().wSize() - 1 - model.getDeclarations().wIndexOf(se), d.wGet(4).wSize() - 1);
}
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplate1.
@Test
public void testSelectTemplate1() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Grammar model = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
PathExpression query = (PathExpression) tm.create("selectTemplate1");
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
Feature f = (Feature) tuple.wGet(0);
As e = (As) tuple.wGet(1);
assertEquals(e.getName().getValue(), f.getName().wStringValue());
assertEquals(e.getRule().wStringValue(), f.getType().wStringValue());
}
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class SelectQueriesTest method testBindingScopes3.
@Test
public void testBindingScopes3() {
Model model = new XmlModel().create();
ITemplateManager tm = SelectQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("selectBindingScopes3");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
Document d = (Document) tuple.wGet(0);
IEntity nameData = tuple.wGet(1);
String name = nameData.wStringValue();
String entityName = bm.wStringValue("entityName");
assertEquals(name, d.wGet(0).wGet(1).wStringValue());
assertEquals(name, entityName);
assertFalse(bm.wIsSet("fromName"));
}
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class SelectQueriesTest method testBindingScopes2.
@Test
public void testBindingScopes2() {
Model model = new XmlModel().create();
ITemplateManager tm = SelectQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("selectBindingScopes2");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
Document d = (Document) tuple.wGet(0);
SimpleEntity e = (SimpleEntity) tuple.wGet(1);
String eName = e.getName().getValue();
assertEquals(eName, d.wGet(0).wGet(1).wStringValue());
assertEquals(eName, d.wGet(0).wGet(2).wStringValue());
assertEquals(eName + eName, d.wGet(1).wGet(1).wStringValue());
}
}
Aggregations