示例#1
0
  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"));
  }
示例#2
0
  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"));
  }
示例#3
0
  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"));
  }