Package org.mvel2.compiler

Examples of org.mvel2.compiler.ExpressionCompiler.compile()


    ParserContext ctx = new ParserContext(null, null, null);
    ctx.setSourceFile("test.mv");
    ctx.setDebugSymbols(true);

    assertEquals("This is an modify()", executeExpression(compiler.compile(ctx), null, vars));
  }


  public void testMacroSupportWithDebugging() {
    Map<String, Object> vars = new HashMap<String, Object>();
View Full Code Here


    ParserContext ctx = new ParserContext(null, interceptors, null);
    ctx.setSourceFile("test.mv");
    ctx.setDebugSymbols(true);

    CompiledExpression compiled = compiler.compile(ctx);

    MVELRuntime.setThreadDebugger(new Debugger() {

      public int onBreak(Frame frame) {
        System.out.println(frame.getSourceName() + ":" + frame.getLineNumber());
View Full Code Here

        String.class);

    ctx.setStrictTypeEnforcement(true);
    ExpressionCompiler compiler = new ExpressionCompiler(text);

    List list = (List) executeExpression(compiler.compile(ctx),
        createTestMap());

    assertSame("dog",
        list.get(0));
    assertEquals("hello",
View Full Code Here

    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 testVarInputs3() {
View Full Code Here

    System.out.println(ctx.getVarOrInputType("bleh"));
  }

  public void testVarInputs3() {
    ExpressionCompiler compiler = new ExpressionCompiler("addresses['home'].street");
    compiler.compile();

    assertFalse(compiler.getParserContextState().getInputs().keySet().contains("home"));
  }

  public void testVarInputs4() {
View Full Code Here

    assertFalse(compiler.getParserContextState().getInputs().keySet().contains("home"));
  }

  public void testVarInputs4() {
    ExpressionCompiler compiler = new ExpressionCompiler("System.out.println( message );");
    compiler.compile();

    assertTrue(compiler.getParserContextState().getInputs().keySet().contains("message"));
  }

  public void testVarInputs5() {
View Full Code Here

    ctx.setStrongTyping(false);
    ctx.addImport(Foo.class);

    ExpressionCompiler compiler = new ExpressionCompiler("new Foo244( $bar,  $bar.age );");

    Serializable compiled = compiler.compile(ctx);

    Set<String> requiredInputs = compiler.getParserContextState().getInputs().keySet();
    assertEquals(1, requiredInputs.size());
    assertTrue(requiredInputs.contains("$bar"));
View Full Code Here

  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,
View Full Code Here

    String ex = "var a, b, c";

    ParserContext ctx = new ParserContext();
    ExpressionCompiler compiler = new ExpressionCompiler(ex);
    compiler.setVerifyOnly(true);
    compiler.compile(ctx);

    assertEquals(3,
            ctx.getVariables().size());
  }
View Full Code Here

    String ex = "var a";

    ParserContext ctx = new ParserContext();
    ExpressionCompiler compiler = new ExpressionCompiler(ex);
    compiler.setVerifyOnly(true);
    compiler.compile(ctx);

    assertEquals(1,
            ctx.getVariables().size());
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.