Search in sources :

Example 81 with ITemplateManager

use of org.whole.lang.templates.ITemplateManager 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);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Production(org.whole.lang.grammars.model.Production) IBindingManager(org.whole.lang.bindings.IBindingManager) ITemplateManager(org.whole.lang.templates.ITemplateManager) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Grammar(org.whole.lang.grammars.model.Grammar) Test(org.junit.Test)

Example 82 with ITemplateManager

use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.

the class ControlQueriesTest method testQueryDecl7.

@Test
public void testQueryDecl7() {
    QueriesEntityFactory qef = QueriesEntityFactory.instance;
    JavaEntityFactory jef = JavaEntityFactory.instance;
    IEntity queryExp1 = qef.createDivision(qef.createMultiplication(qef.createIntLiteral(10), qef.createIntLiteral(8)), qef.createAddition(qef.createIntLiteral(2), qef.createIntLiteral(1)));
    IEntity queryExp2 = qef.createDivision(qef.createIntLiteral(10), qef.createAddition(qef.createIntLiteral(2), qef.createIntLiteral(1)));
    IEntity javaExp1 = jef.createInfixExpression(jef.createInfixExpression(jef.createIntLiteral(10), jef.createInfixOperator(InfixOperatorEnum.times), jef.createIntLiteral(8), jef.createExpressions(0)), jef.createInfixOperator(InfixOperatorEnum.divide), jef.createInfixExpression(jef.createIntLiteral(2), jef.createInfixOperator(InfixOperatorEnum.plus), jef.createIntLiteral(1), jef.createExpressions(0)), jef.createExpressions(0));
    IEntity javaExp2 = EntityUtils.clone(javaExp1);
    javaExp2.wSet(JavaFeatureDescriptorEnum.leftOperand, jef.createIntLiteral(10));
    ITemplateManager tm = ControlQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("queryDecl7");
    assertTrue(Matcher.match(javaExp2, BehaviorUtils.evaluateFirstResult(query, queryExp2)));
    assertTrue(Matcher.match(javaExp1, BehaviorUtils.evaluateFirstResult(query, queryExp1)));
}
Also used : JavaEntityFactory(org.whole.lang.java.factories.JavaEntityFactory) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) ITemplateManager(org.whole.lang.templates.ITemplateManager) Test(org.junit.Test)

Example 83 with ITemplateManager

use of org.whole.lang.templates.ITemplateManager 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);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) IBindingManager(org.whole.lang.bindings.IBindingManager) ITemplateManager(org.whole.lang.templates.ITemplateManager) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Grammar(org.whole.lang.grammars.model.Grammar) Test(org.junit.Test)

Example 84 with ITemplateManager

use of org.whole.lang.templates.ITemplateManager 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);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Production(org.whole.lang.grammars.model.Production) IBindingManager(org.whole.lang.bindings.IBindingManager) ITemplateManager(org.whole.lang.templates.ITemplateManager) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Grammar(org.whole.lang.grammars.model.Grammar) Test(org.junit.Test)

Example 85 with ITemplateManager

use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.

the class ControlQueriesTest method testCall1.

// TODO choose5
@Test
public void testCall1() {
    Grammar grammar = new TestXmlGrammar().create();
    IBindingManager bm = BindingManagerFactory.instance.createArguments();
    ITemplateManager tm = ControlQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("call1");
    int count = 0;
    for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
        assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Production, p));
        count++;
    }
    assertEquals(16, count);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) IBindingManager(org.whole.lang.bindings.IBindingManager) ITemplateManager(org.whole.lang.templates.ITemplateManager) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Grammar(org.whole.lang.grammars.model.Grammar) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)96 ITemplateManager (org.whole.lang.templates.ITemplateManager)96 PathExpression (org.whole.lang.queries.model.PathExpression)87 IEntity (org.whole.lang.model.IEntity)61 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)47 Grammar (org.whole.lang.grammars.model.Grammar)46 Model (org.whole.lang.models.model.Model)41 IBindingManager (org.whole.lang.bindings.IBindingManager)40 XmlModel (org.whole.lang.models.codebase.XmlModel)27 Production (org.whole.lang.grammars.model.Production)26 QueriesGrammar (org.whole.lang.grammars.codebase.QueriesGrammar)25 ModelsModel (org.whole.lang.models.codebase.ModelsModel)23 ModelDeclarations (org.whole.lang.models.model.ModelDeclarations)18 SimpleEntity (org.whole.lang.models.model.SimpleEntity)13 ClassDeclaration (org.whole.lang.java.model.ClassDeclaration)11 DataEntity (org.whole.lang.models.model.DataEntity)10 NonTerminal (org.whole.lang.grammars.model.NonTerminal)9 Feature (org.whole.lang.models.model.Feature)9 FieldDeclaration (org.whole.lang.java.model.FieldDeclaration)7 PrettyPrinterOperation.toPrettyPrintString (org.whole.lang.operations.PrettyPrinterOperation.toPrettyPrintString)7