use of org.mvel2.tests.core.res.Foo in project mvel by mikebrock.
the class TypesAndInferenceTests method testProvidedExternalTypes.
public void testProvidedExternalTypes() {
ExpressionCompiler compiler = new ExpressionCompiler("foo.bar");
ParserContext ctx = new ParserContext();
ctx.setStrictTypeEnforcement(true);
ctx.addInput("foo", Foo.class);
compiler.compile(ctx);
}
use of org.mvel2.tests.core.res.Foo in project mvel by mikebrock.
the class MacroProcessorTest method testMacroSupportWithDebugging.
public void testMacroSupportWithDebugging() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("foo", new Foo());
Map<String, Interceptor> interceptors = new HashMap<String, Interceptor>();
Map<String, Macro> macros = new HashMap<String, Macro>();
interceptors.put("Modify", new Interceptor() {
public int doBefore(ASTNode node, VariableResolverFactory factory) {
((WithNode) node).getNestedStatement().getValue(null, factory);
factory.createVariable("mod", "FOOBAR!");
return 0;
}
public int doAfter(Object val, ASTNode node, VariableResolverFactory factory) {
return 0;
}
});
macros.put("modify", new Macro() {
public String doMacro() {
return "@Modify with";
}
});
ExpressionCompiler compiler = new ExpressionCompiler(parseMacros("System.out.println('hello');\n" + "System.out.println('bye');\n" + "modify (foo) { aValue = 'poo', \n" + " aValue = 'poo' };\n mod", macros));
// compiler.setDebugSymbols(true);
ParserContext ctx = new ParserContext(null, interceptors, null);
ctx.setSourceFile("test.mv");
ctx.setDebugSymbols(true);
CompiledExpression compiled = compiler.compile(ctx);
MVELRuntime.setThreadDebugger(new Debugger() {
public int onBreak(Frame frame) {
System.out.println(frame.getSourceName() + ":" + frame.getLineNumber());
return Debugger.STEP;
}
});
MVELRuntime.registerBreakpoint("test.mv", 3);
System.out.println(DebugTools.decompile(compiled));
Assert.assertEquals("FOOBAR!", MVEL.executeDebugger(compiled, null, new MapVariableResolverFactory(vars)));
}
use of org.mvel2.tests.core.res.Foo in project mvel by mikebrock.
the class PropertyAccessTests method testInterfaceResolution.
public void testInterfaceResolution() {
Serializable ex = compileExpression("foo.collectionTest.size()");
Map map = createTestMap();
Foo foo = (Foo) map.get("foo");
foo.setCollectionTest(new HashSet());
Object result1 = executeExpression(ex, foo, map);
foo.setCollectionTest(new ArrayList());
Object result2 = executeExpression(ex, foo, map);
assertEquals(result1, result2);
}
use of org.mvel2.tests.core.res.Foo 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.tests.core.res.Foo 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)));
}
Aggregations