public void testVarInputs5() { ParserContext pCtx = ParserContext.create().withInput("list", List.class); MVEL.analysisCompile( "String nodeName = list[0];\nSystem.out.println(nodeName);nodeName = list[1];\nSystem.out.println(nodeName);", pCtx); assertEquals(1, pCtx.getInputs().size()); assertTrue(pCtx.getInputs().containsKey("list")); assertEquals(1, pCtx.getVariables().size()); assertTrue(pCtx.getVariables().containsKey("nodeName")); assertEquals(List.class, pCtx.getVarOrInputType("list")); assertEquals(String.class, pCtx.getVarOrInputType("nodeName")); }
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")); }
public void testVarInputs() { ParserContext pCtx = ParserContext.create(); MVEL.analysisCompile( "test != foo && bo.addSomething(trouble) " + "&& 1 + 2 / 3 == 1; String bleh = foo; twa = bleh;", pCtx); assertEquals(4, pCtx.getInputs().size()); assertTrue(pCtx.getInputs().containsKey("test")); assertTrue(pCtx.getInputs().containsKey("foo")); assertTrue(pCtx.getInputs().containsKey("bo")); assertTrue(pCtx.getInputs().containsKey("trouble")); assertEquals(2, pCtx.getVariables().size()); assertTrue(pCtx.getVariables().containsKey("bleh")); assertTrue(pCtx.getVariables().containsKey("twa")); assertEquals(String.class, pCtx.getVarOrInputType("bleh")); }