Search in sources :

Example 1 with Type

use of org.eclipse.xtend.typesystem.Type in project dsl-devkit by dsldevkit.

the class CompilationContextTest method analyze.

@Test
public void analyze() {
    ExecutionContextImpl executionContext = new ExecutionContextImpl();
    executionContext.registerMetaModel(new JavaBeansMetaModel());
    final CompilationContext context = new CompilationContext(executionContext, null);
    Type expectedType = executionContext.getTypeForName("Integer");
    assertSame("Cannot analyze Integer", expectedType, context.analyze("1 + 3"));
    expectedType = executionContext.getTypeForName("Real");
    assertSame("Cannot analyze Real", expectedType, context.analyze("1 + 3.33"));
    expectedType = executionContext.getTypeForName("String");
    assertSame("Cannot analyse String 'foo'", expectedType, context.analyze("\'foo\'"));
    assertSame("Cannot analyse String \"foo \" ", expectedType, context.analyze("\"foo\""));
    assertSame("Cannot analyse String \"foo\" + \'bar\'", expectedType, context.analyze("\"foo\" + \'bar\'"));
}
Also used : Type(org.eclipse.xtend.typesystem.Type) ExecutionContextImpl(org.eclipse.xtend.expression.ExecutionContextImpl) CompilationContext(com.avaloq.tools.ddk.xtext.expression.generator.CompilationContext) JavaBeansMetaModel(org.eclipse.xtend.type.impl.java.JavaBeansMetaModel) Test(org.junit.Test)

Aggregations

CompilationContext (com.avaloq.tools.ddk.xtext.expression.generator.CompilationContext)1 ExecutionContextImpl (org.eclipse.xtend.expression.ExecutionContextImpl)1 JavaBeansMetaModel (org.eclipse.xtend.type.impl.java.JavaBeansMetaModel)1 Type (org.eclipse.xtend.typesystem.Type)1 Test (org.junit.Test)1