use of org.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class CoreConfidenceTests method testStaticNestedWithImport.
public void testStaticNestedWithImport() {
String expr = "Message.GOODBYE;\n";
ExpressionCompiler compiler = new ExpressionCompiler(expr);
ParserContext context = new ParserContext();
context.setStrictTypeEnforcement(false);
context.addImport("Message", Message.class);
assertEquals(1, executeExpression(compiler.compile(context)));
}
use of org.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class CoreConfidenceTests method testParsingStability2.
public void testParsingStability2() {
ExpressionCompiler compiler = new ExpressionCompiler("( dim.height == 1 || dim.height == ( 1+1) || dim.height == x )");
Map<String, Object> imports = new HashMap<String, Object>();
imports.put("java.awt.Dimension", Dimension.class);
final ParserContext parserContext = new ParserContext(imports, null, "sourceFile");
parserContext.setStrictTypeEnforcement(false);
compiler.compile(parserContext);
}
use of org.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class CoreConfidenceTests method testConcatWithLineBreaks.
public void testConcatWithLineBreaks() {
ExpressionCompiler parser = new ExpressionCompiler("\"foo\"+\n\"bar\"");
ParserContext ctx = new ParserContext();
ctx.setDebugSymbols(true);
ctx.setSourceFile("source.mv");
assertEquals("foobar", executeExpression(parser.compile(ctx)));
}
use of org.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class CoreConfidenceTests method testLateResolveOfClass.
public void testLateResolveOfClass() {
ExpressionCompiler compiler = new ExpressionCompiler("System.out.println(new Foo());");
ParserContext ctx = new ParserContext();
ctx.addImport(Foo.class);
compiler.removeParserContext();
System.out.println(executeExpression(compiler.compile(ctx)));
}
use of org.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class TypesAndInferenceTests method testDetermineRequiredInputsInConstructor.
public void testDetermineRequiredInputsInConstructor() throws Exception {
ParserContext ctx = new ParserContext();
ctx.setStrictTypeEnforcement(false);
ctx.setStrongTyping(false);
ctx.addImport(Foo.class);
ExpressionCompiler compiler = new ExpressionCompiler("new Foo244( $bar, $bar.age );");
Serializable compiled = compiler.compile(ctx);
Set<String> requiredInputs = compiler.getParserContextState().getInputs().keySet();
assertEquals(1, requiredInputs.size());
assertTrue(requiredInputs.contains("$bar"));
}
Aggregations