use of org.mule.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class CoreConfidenceTests method testTestIntToLong.
public void testTestIntToLong() {
String s = "1+(long)a";
ParserContext pc = new ParserContext();
pc.addInput("a", Integer.class);
ExpressionCompiler compiler = new ExpressionCompiler(s, pc);
CompiledExpression expr = compiler.compile();
Map vars = new HashMap();
vars.put("a", 1);
Object r = ((ExecutableStatement) expr).getValue(null, new MapVariableResolverFactory(vars));
assertEquals(new Long(2), r);
}
use of org.mule.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class CoreConfidenceTests method testEqualityRegression.
public void testEqualityRegression() {
ExpressionCompiler compiler = new ExpressionCompiler("price == (new Integer( 5 ) + 5 ) ");
compiler.compile();
}
use of org.mule.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class ArithmeticTests method testJIRA161.
public void testJIRA161() {
Serializable s = MVEL.compileExpression("1==-(-1)", ParserContext.create().stronglyTyped());
assertEquals(1 == -(-1), MVEL.executeExpression(s));
ParserContext ctx = new ParserContext();
ctx.setStrongTyping(true);
CompiledExpression compiledExpression = new ExpressionCompiler("1==-(-1)").compile(ctx);
assertEquals(1 == -(-1), MVEL.executeExpression(compiledExpression));
}
use of org.mule.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class ArithmeticTests method testStrongTypingModeComparison.
public void testStrongTypingModeComparison() {
ParserContext parserContext = new ParserContext();
parserContext.setStrongTyping(true);
parserContext.addInput("a", Long.class);
CompiledExpression compiledExpression = new ExpressionCompiler("a==0").compile(parserContext);
HashMap<String, Object> variables = new HashMap<String, Object>();
variables.put("a", 0l);
MVEL.executeExpression(compiledExpression, variables);
}
use of org.mule.mvel2.compiler.ExpressionCompiler in project drools by kiegroup.
the class ResultVerifier method isSuccess.
protected Boolean isSuccess(VerifyField currentField) {
String s = "__fact__." + currentField.getFieldName() + " " + currentField.getOperator() + " __expected__";
CompiledExpression expression = new ExpressionCompiler(s, parserContext).compile();
return (Boolean) MVELSafeHelper.getEvaluator().executeExpression(expression, variables);
}
Aggregations