use of org.mvel2.tests.core.res.Foo in project mvel by mikebrock.
the class TypesAndInferenceTests method testStrictTypingCompilation4.
public void testStrictTypingCompilation4() throws NoSuchMethodException {
ParserContext ctx = new ParserContext();
ctx.addImport(Foo.class);
ctx.setStrictTypeEnforcement(true);
ExpressionCompiler compiler = new ExpressionCompiler("x_a = new Foo()");
compiler.compile(ctx);
assertEquals(Foo.class, ctx.getVariables().get("x_a"));
}
use of org.mvel2.tests.core.res.Foo in project mvel by mikebrock.
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);
compiler.compile(ctx);
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.mvel2.tests.core.res.Foo in project mvel by mikebrock.
the class TypesAndInferenceTests method testParameterizedTypeInStrictMode.
public void testParameterizedTypeInStrictMode() {
ParserContext ctx = new ParserContext();
ctx.setStrongTyping(true);
ctx.addInput("foo", HashMap.class, new Class[] { String.class, String.class });
ExpressionCompiler compiler = new ExpressionCompiler("foo.get('bar').toUpperCase()");
compiler.compile(ctx);
}
use of org.mvel2.tests.core.res.Foo in project mvel by mikebrock.
the class TypesAndInferenceTests method testSetAccessorOverloadedEqualsStrictMode2.
public void testSetAccessorOverloadedEqualsStrictMode2() {
ParserContext ctx = new ParserContext();
ctx.setStrongTyping(true);
ctx.addInput("foo", Foo.class);
try {
CompiledExpression expr = new ExpressionCompiler("foo.aValue = 'bar'").compile(ctx);
} catch (CompileException e) {
assertTrue(false);
}
}
use of org.mvel2.tests.core.res.Foo in project mvel by mikebrock.
the class TypesAndInferenceTests method testVarInputs2.
public void testVarInputs2() {
ExpressionCompiler compiler = new ExpressionCompiler("test != foo && bo.addSomething(trouble); String bleh = foo; twa = bleh;");
ParserContext ctx = new ParserContext();
compiler.compile(ctx);
System.out.println(ctx.getVarOrInputType("bleh"));
}
Aggregations