use of org.mule.mvel2.compiler.ExpressionCompiler in project mvel by mvel.
the class TypesAndInferenceTests method testProvidedExternalTypes.
public void testProvidedExternalTypes() {
ParserContext ctx = new ParserContext();
ctx.setStrictTypeEnforcement(true);
ctx.addInput("foo", Foo.class);
ExpressionCompiler compiler = new ExpressionCompiler("foo.bar", ctx);
compiler.compile();
}
use of org.mule.mvel2.compiler.ExpressionCompiler in project mvel by mvel.
the class TypesAndInferenceTests method testMapAsContextWithStrictTyping.
public void testMapAsContextWithStrictTyping() {
ParserContext ctx = new ParserContext();
ctx.setStrictTypeEnforcement(true);
ctx.setStrongTyping(true);
ctx.addInput("$msg", String.class);
ctx.addInput("this", Map.class);
ExpressionCompiler compiler = new ExpressionCompiler("this['KEY1'] == $msg", ctx);
Serializable expr = compiler.compile();
Map map = new HashMap();
map.put("KEY1", "MSGONE");
Map vars = new HashMap();
vars.put("$msg", "MSGONE");
Boolean bool = (Boolean) executeExpression(expr, map, vars);
assertEquals(Boolean.TRUE, bool);
}
use of org.mule.mvel2.compiler.ExpressionCompiler in project mvel by mvel.
the class TypesAndInferenceTests method testMultiTypeVarDeclr.
public void testMultiTypeVarDeclr() {
String ex = "String a, b, c";
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());
}
}
use of org.mule.mvel2.compiler.ExpressionCompiler 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.ExpressionCompiler in project mvel by mvel.
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));
}
Aggregations