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));
}
use of org.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class TypesAndInferenceTests method testVarInputs3.
public void testVarInputs3() {
ExpressionCompiler compiler = new ExpressionCompiler("addresses['home'].street");
compiler.compile();
assertFalse(compiler.getParserContextState().getInputs().keySet().contains("home"));
}
use of org.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class TypesAndInferenceTests method testProvidedExternalTypes.
public void testProvidedExternalTypes() {
ExpressionCompiler compiler = new ExpressionCompiler("foo.bar");
ParserContext ctx = new ParserContext();
ctx.setStrictTypeEnforcement(true);
ctx.addInput("foo", Foo.class);
compiler.compile(ctx);
}
Aggregations