use of org.mule.mvel2.compiler.CompiledExpression in project mvel by mvel.
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.mule.mvel2.compiler.CompiledExpression in project mvel by mvel.
the class TypesAndInferenceTests method testDetermineEgressParametricType2.
public final void testDetermineEgressParametricType2() {
final ParserContext parserContext = new ParserContext();
parserContext.setStrongTyping(true);
parserContext.addInput("strings", List.class, new Class[] { String.class });
final CompiledExpression expr = new ExpressionCompiler("strings", parserContext).compile();
assertTrue(STRINGS.equals(executeExpression(expr, new A())));
/*
final Type[] typeParameters = expr.getParserContext().getLastTypeParameters();
assertTrue(null != typeParameters);
assertTrue(String.class.equals(typeParameters[0]));
*/
}
use of org.mule.mvel2.compiler.CompiledExpression in project mvel by mvel.
the class TypesAndInferenceTests method testDetermineEgressParametricType.
public final void testDetermineEgressParametricType() {
final ParserContext parserContext = new ParserContext();
parserContext.setStrongTyping(true);
parserContext.addInput("strings", List.class, new Class[] { String.class });
final CompiledExpression expr = new ExpressionCompiler("strings", parserContext).compile();
assertTrue(STRINGS.equals(executeExpression(expr, new A())));
/*
final Type[] typeParameters = expr.getParserContext().getLastTypeParameters();
assertTrue(typeParameters != null);
assertTrue(String.class.equals(typeParameters[0]));
*/
}
use of org.mule.mvel2.compiler.CompiledExpression in project mvel by mvel.
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.mule.mvel2.compiler.CompiledExpression in project mvel by mvel.
the class WithTests method testExecuteCoercionTwice2.
public void testExecuteCoercionTwice2() {
OptimizerFactory.setDefaultOptimizer("ASM");
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("foo", new Foo());
vars.put("$value", new Long(5));
ParserContext ctx = new ParserContext();
ctx.setSourceFile("test.mv");
ctx.setDebugSymbols(true);
ExpressionCompiler compiler = new ExpressionCompiler("with (foo) { countTest = $value };", ctx);
CompiledExpression compiled = compiler.compile();
executeExpression(compiled, null, vars);
executeExpression(compiled, null, vars);
}
Aggregations