use of org.mvel2.ParserContext in project mvel by mvel.
the class CoreConfidenceTests method testParserErrorHandling.
public void testParserErrorHandling() {
final ParserContext ctx = new ParserContext();
ExpressionCompiler compiler = new ExpressionCompiler("a[", ctx);
try {
compiler.compile();
} catch (Exception e) {
return;
}
assertTrue(false);
}
use of org.mvel2.ParserContext in project mvel by mvel.
the class CoreConfidenceTests method testContextFieldNotFound.
public void testContextFieldNotFound() {
String str = "'stilton'.equals( type );";
ParserConfiguration pconf = new ParserConfiguration();
ParserContext pctx = new ParserContext(pconf);
pctx.addInput("this", Cheese.class);
pctx.setStrictTypeEnforcement(true);
pctx.setStrongTyping(true);
ExecutableStatement stmt = (ExecutableStatement) MVEL.compileExpression(str, pctx);
MVEL.executeExpression(stmt, new Cheese(), new HashMap());
}
use of org.mvel2.ParserContext in project mvel by mvel.
the class CoreConfidenceTests method testFieldNameWithUnderscore.
public void testFieldNameWithUnderscore() {
final ParserContext parserContext = new ParserContext();
parserContext.setStrictTypeEnforcement(true);
parserContext.setStrongTyping(true);
parserContext.addInput("this", Underscore.class);
Underscore underscore = new Underscore();
assertEquals(true, MVEL.executeExpression(MVEL.compileExpression("_id == \"test\"", parserContext), underscore));
}
use of org.mvel2.ParserContext in project mvel by mvel.
the class CoreConfidenceTests method testRegExWithCast.
public void testRegExWithCast() {
final ParserContext parserContext = new ParserContext();
parserContext.setStrongTyping(true);
parserContext.addInput("this", Foo.class);
assertEquals(Boolean.class, MVEL.analyze("(String)bar.name ~= '[a-z].+'", parserContext));
}
use of org.mvel2.ParserContext in project mvel by mvel.
the class CoreConfidenceTests method testEmpty.
public void testEmpty() {
ParserContext ctx = new ParserContext();
ctx.setStrongTyping(true);
Serializable s = compileExpression("list = new java.util.ArrayList(); list == empty", ctx);
Map vars = new HashMap();
Boolean x = (Boolean) executeExpression(s, vars);
assertNotNull(x);
assertTrue(x.booleanValue());
}
Aggregations