use of org.mule.mvel2.ParserContext in project mvel by mvel.
the class StaticMethodImportTests method testMVELUntyped.
private void testMVELUntyped(String text) {
String str = IMPORTS + text;
ParserContext pctx = new ParserContext();
Map<String, Object> vars = new HashMap<String, Object>();
Object o = MVEL.compileExpression(str, pctx);
MVEL.executeExpression(o, vars);
}
use of org.mule.mvel2.ParserContext in project mvel by mvel.
the class TypesAndInferenceTests method testStrongTyping3.
public void testStrongTyping3() {
ParserContext ctx = new ParserContext();
ctx.setStrongTyping(true);
try {
new ExpressionCompiler("foo.toUC(100.5", ctx).compile();
} catch (Exception e) {
// should fail.
return;
}
assertTrue(false);
}
use of org.mule.mvel2.ParserContext in project mvel by mvel.
the class TypesAndInferenceTests method testAnalysisCompile.
public void testAnalysisCompile() {
ParserContext pCtx = new ParserContext();
ExpressionCompiler e = new ExpressionCompiler("foo.aValue = 'bar'", pCtx);
e.setVerifyOnly(true);
e.compile();
assertTrue(pCtx.getInputs().keySet().contains("foo"));
assertEquals(1, pCtx.getInputs().size());
assertEquals(0, pCtx.getVariables().size());
}
use of org.mule.mvel2.ParserContext in project mvel by mvel.
the class TypesAndInferenceTests method testStrictTypingCompilation3.
public void testStrictTypingCompilation3() throws NoSuchMethodException {
ParserContext ctx = new ParserContext();
ctx.setStrictTypeEnforcement(true);
ExpressionCompiler compiler = new ExpressionCompiler("message='Hello';b=7;\nSystem.out.println(message + ';' + b);\n" + "System.out.println(message + ';' + b); b", ctx);
assertEquals(7, executeExpression(compiler.compile(), new DefaultLocalVariableResolverFactory()));
}
use of org.mule.mvel2.ParserContext in project mvel by mvel.
the class TypesAndInferenceTests method testMultiTypeVarDeclr2.
public void testMultiTypeVarDeclr2() {
String ex = "String a = 'foo', b = 'baz', c = 'bar'";
ParserContext ctx = new ParserContext();
ExpressionCompiler compiler = new ExpressionCompiler(ex, ctx);
compiler.compile();
assertNotNull(ctx.getVariables());
assertEquals(3, ctx.getVariables().entrySet().size());
for (Map.Entry<String, Class> entry : ctx.getVariables().entrySet()) {
assertEquals(String.class, entry.getValue());
}
}
Aggregations