use of org.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class TypesAndInferenceTests method testVarDeclr.
public void testVarDeclr() {
String ex = "var a";
ParserContext ctx = new ParserContext();
ExpressionCompiler compiler = new ExpressionCompiler(ex);
compiler.setVerifyOnly(true);
compiler.compile(ctx);
assertEquals(1, ctx.getVariables().size());
}
use of org.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class TypesAndInferenceTests method testStrictStrongTypingCompilationErrors1.
public void testStrictStrongTypingCompilationErrors1() throws Exception {
ParserContext ctx = new ParserContext();
ctx.setStrictTypeEnforcement(true);
ctx.setStrongTyping(true);
ctx.addImport(Foo.class);
ctx.addInput("$bar", Bar.class);
try {
ExpressionCompiler compiler = new ExpressionCompiler("System.out.println( $ba );");
compiler.compile(ctx);
fail("This should not compileShared");
} catch (Exception e) {
}
}
use of org.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class TypesAndInferenceTests method testParameterizedTypeInStrictMode3.
public void testParameterizedTypeInStrictMode3() {
ParserContext ctx = new ParserContext();
ctx.setStrongTyping(true);
ctx.addInput("base", Base.class);
ExpressionCompiler compiler = new ExpressionCompiler("base.list");
assertTrue(compiler.compile(ctx).getParserContext().getLastTypeParameters()[0].equals(String.class));
}
use of org.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class TypesAndInferenceTests method testMultiVarDeclr.
public void testMultiVarDeclr() {
String ex = "var a, b, c";
ParserContext ctx = new ParserContext();
ExpressionCompiler compiler = new ExpressionCompiler(ex);
compiler.setVerifyOnly(true);
compiler.compile(ctx);
assertEquals(3, ctx.getVariables().size());
}
use of org.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class TypesAndInferenceTests method testStrictStaticMethodCall.
public void testStrictStaticMethodCall() {
ExpressionCompiler compiler = new ExpressionCompiler("Bar.staticMethod()");
ParserContext ctx = new ParserContext();
ctx.addImport("Bar", Bar.class);
ctx.setStrictTypeEnforcement(true);
Serializable s = compiler.compile(ctx);
assertEquals(1, executeExpression(s));
}
Aggregations