use of org.mvel2.compiler.CompiledExpression in project mvel by mikebrock.
the class TypesAndInferenceTests method testParameterizedTypeInStrictMode4.
public void testParameterizedTypeInStrictMode4() {
ParserContext ctx = new ParserContext();
ctx.setStrongTyping(true);
ctx.addInput("base", Base.class);
ExpressionCompiler compiler = new ExpressionCompiler("base.list.get(1).toUpperCase()");
CompiledExpression ce = compiler.compile(ctx);
assertEquals(String.class, ce.getKnownEgressType());
}
use of org.mvel2.compiler.CompiledExpression in project mvel by mikebrock.
the class TypesAndInferenceTests method testMVEL232.
public void testMVEL232() {
ParserContext ctx = new ParserContext();
ctx.setStrongTyping(true);
ctx.setStrictTypeEnforcement(true);
String script = "for(int i=0;i<2;i++) { " + " System.out.println(i+\"\");" + "} " + " return true;";
try {
CompiledExpression compiled = (CompiledExpression) MVEL.compileExpression(script, ctx);
HashMap<String, Object> map = new HashMap<String, Object>();
MVEL.executeExpression(compiled, map);
} catch (Exception e) {
e.printStackTrace();
fail("should now throw an exception");
}
}
use of org.mvel2.compiler.CompiledExpression in project mvel by mikebrock.
the class TypesAndInferenceTests method testSetAccessorOverloadedEqualsStrictMode2.
public void testSetAccessorOverloadedEqualsStrictMode2() {
ParserContext ctx = new ParserContext();
ctx.setStrongTyping(true);
ctx.addInput("foo", Foo.class);
try {
CompiledExpression expr = new ExpressionCompiler("foo.aValue = 'bar'").compile(ctx);
} catch (CompileException e) {
assertTrue(false);
}
}
use of org.mvel2.compiler.CompiledExpression in project mvel by mikebrock.
the class WithTests method testInlineWithImpliedThis.
public void testInlineWithImpliedThis() {
Base b = new Base();
ExpressionCompiler expr = new ExpressionCompiler(".{ data = 'foo' }");
CompiledExpression compiled = expr.compile();
executeExpression(compiled, b);
assertEquals(b.data, "foo");
}
use of org.mvel2.compiler.CompiledExpression in project mvel by mikebrock.
the class WithTests method testInlineWith.
public void testInlineWith() {
CompiledExpression expr = new ExpressionCompiler("foo.{name='poopy', aValue='bar'}").compile();
Foo f = (Foo) executeExpression(expr, createTestMap());
assertEquals("poopy", f.getName());
assertEquals("bar", f.aValue);
}
Aggregations