use of org.mvel2.ParserContext in project mvel by mikebrock.
the class TypesAndInferenceTests method testMultiTypeVarDeclr.
public void testMultiTypeVarDeclr() {
String ex = "String a, b, c";
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.ParserContext in project mvel by mikebrock.
the class TypesAndInferenceTests method testEgressType.
public void testEgressType() {
ExpressionCompiler compiler = new ExpressionCompiler("( $cheese )");
ParserContext context = new ParserContext();
context.addInput("$cheese", Cheese.class);
assertEquals(Cheese.class, compiler.compile(context).getKnownEgressType());
}
use of org.mvel2.ParserContext in project mvel by mikebrock.
the class TypesAndInferenceTests method testAnalysisCompile.
public void testAnalysisCompile() {
ParserContext pCtx = new ParserContext();
ExpressionCompiler e = new ExpressionCompiler("foo.aValue = 'bar'");
e.setVerifyOnly(true);
e.compile(pCtx);
assertTrue(pCtx.getInputs().keySet().contains("foo"));
assertEquals(1, pCtx.getInputs().size());
assertEquals(0, pCtx.getVariables().size());
}
use of org.mvel2.ParserContext in project mvel by mikebrock.
the class TypesAndInferenceTests method testDetermineEgressParametricType2.
public final void testDetermineEgressParametricType2() {
final ParserContext parserContext = new ParserContext();
parserContext.setStrongTyping(true);
parserContext.addInput("strings", List.class, new Class[] { String.class });
final CompiledExpression expr = new ExpressionCompiler("strings", parserContext).compile();
assertTrue(STRINGS.equals(executeExpression(expr, new A())));
final Type[] typeParameters = expr.getParserContext().getLastTypeParameters();
assertTrue(null != typeParameters);
assertTrue(String.class.equals(typeParameters[0]));
}
use of org.mvel2.ParserContext in project mvel by mikebrock.
the class TypesAndInferenceTests method testDetermineEgressParametricType.
public final void testDetermineEgressParametricType() {
final ParserContext parserContext = new ParserContext();
parserContext.setStrongTyping(true);
parserContext.addInput("strings", List.class, new Class[] { String.class });
final CompiledExpression expr = new ExpressionCompiler("strings").compile(parserContext);
assertTrue(STRINGS.equals(executeExpression(expr, new A())));
final Type[] typeParameters = expr.getParserContext().getLastTypeParameters();
assertTrue(typeParameters != null);
assertTrue(String.class.equals(typeParameters[0]));
}
Aggregations