use of com.avaloq.tools.ddk.xtext.expression.generator.CompilationContext in project dsl-devkit by dsldevkit.
the class CodeGenerationXTest method beforeAllTests.
@Override
protected void beforeAllTests() {
super.beforeAllTests();
final ExecutionContextImpl executionContext = new ExecutionContextImpl();
executionContext.registerMetaModel(new JavaBeansMetaModel());
executionContext.registerMetaModel(new EmfRegistryMetaModel());
final CompilationContext context = new CompilationContext(executionContext, new GenModelUtilX());
getTestInformation().putTestObject(CompilerX.class, new CompilerX(context));
}
use of com.avaloq.tools.ddk.xtext.expression.generator.CompilationContext 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\'"));
}
use of com.avaloq.tools.ddk.xtext.expression.generator.CompilationContext in project dsl-devkit by dsldevkit.
the class CompilationContextTest method isExtension.
@Test
public void isExtension() {
ExecutionContextImpl executionContext = new ExecutionContextImpl();
executionContext.registerMetaModel(new JavaBeansMetaModel());
ExtensionFile extensionFile = ParseFacade.file(new InputStreamReader(getClass().getResourceAsStream("/com/avaloq/tools/ddk/xtext/generator/expression/TestExtensions.ext")), "TestExtensions.ext");
executionContext = (ExecutionContextImpl) executionContext.cloneWithResource(extensionFile);
final CompilationContext context = new CompilationContext(executionContext, null);
assertTrue("test extension not identified", context.isExtension("test"));
}
Aggregations