Search in sources :

Example 6 with Bar

use of org.mvel2.tests.core.res.Bar in project mvel by mikebrock.

the class InlineCollectionsPerformance method testMVELList.

//    public static void testMVELList() {
//
//        ExecutableAccessor s = (ExecutableAccessor) MVEL.compileExpression("['Foo244':'Bar','Foo244':'Bar','Foo244':'Bar','Foo244':'Bar','Foo244':'Bar']");
//        Map list;
//        s.getNode().getReducedValueAccelerated(null, null, null);
//        for (int i = 0; i < COUNT; i++) {
//            list = (Map) s.getNode().getAccessor().getValue(null, null, null);
//
//        }
//    }
//    public static void testMVELList() {
//
//        ExecutableAccessor s = (ExecutableAccessor) MVEL.compileExpression("{'Foo244','Bar','Foo244','Bar','Foo244','Bar','Foo244','Bar','Foo244','Bar'}");
//        Object[] list;
//        s.getNode().getReducedValueAccelerated(null, null, null);
//        for (int i = 0; i < COUNT; i++) {
//            list = (Object[]) s.getNode().getAccessor().getValue(null, null, null);
//
//            //     assert "Foo244".equals(list.get(0)) && "Foo244".equals(list.get(2)) && list.size() == 10;
//        }
//    }
public static void testMVELList() {
    ExecutableAccessor s = (ExecutableAccessor) MVEL.compileExpression("['Foo244','Bar','Foo244','Bar','Foo244','Bar','Foo244','Bar','Foo244','Bar']");
    List list;
    s.getNode().getReducedValueAccelerated(null, null, null);
    for (int i = 0; i < COUNT; i++) {
        list = (List) s.getNode().getAccessor().getValue(null, null, null);
        assert "Foo244".equals(list.get(0)) && "Foo244".equals(list.get(2)) && list.size() == 10;
    }
}
Also used : ExecutableAccessor(org.mvel2.compiler.ExecutableAccessor) List(java.util.List) FastList(org.mvel2.util.FastList)

Example 7 with Bar

use of org.mvel2.tests.core.res.Bar in project mvel by mikebrock.

the class InlineCollectionsPerformance method testJavaList.

public static void testJavaList() {
    FastList list;
    for (int i = 0; i < COUNT; i++) {
        list = new FastList(10);
        list.add("Foo244");
        list.add("Bar");
        list.add("Foo244");
        list.add("Bar");
        list.add("Foo244");
        list.add("Bar");
        list.add("Foo244");
        list.add("Bar");
        list.add("Foo244");
        list.add("Bar");
        assert "Foo244".equals(list.get(0)) && "Bar".equals(list.get(1)) && list.size() == 10;
    }
}
Also used : FastList(org.mvel2.util.FastList)

Example 8 with Bar

use of org.mvel2.tests.core.res.Bar in project mvel by mikebrock.

the class ProjectionsTests method testProjectionSupport3.

public void testProjectionSupport3() {
    String ex = "(toUpperCase() in ['bar', 'foo'])[1]";
    Map vars = createTestMap();
    assertEquals("FOO", MVEL.eval(ex, new Base(), vars));
    assertEquals("FOO", test("(toUpperCase() in ['bar', 'foo'])[1]"));
}
Also used : Map(java.util.Map) Base(org.mvel2.tests.core.res.Base)

Example 9 with Bar

use of org.mvel2.tests.core.res.Bar in project mvel by mikebrock.

the class TemplateTests method setupVarsMVEL219.

private Map<String, Object> setupVarsMVEL219() {
    Map<String, Object> vars = new LinkedHashMap<String, Object>();
    vars.put("bal", new BigDecimal("999.99"));
    vars.put("word", "ball");
    vars.put("object", new CoreConfidenceTests.Dog());
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("foo", "bar");
    map.put("fu", new CoreConfidenceTests.Dog());
    map.put("trueValue", true);
    map.put("falseValue", false);
    map.put("one", 1);
    map.put("zero", 0);
    vars.put("map", map);
    return vars;
}
Also used : BigDecimal(java.math.BigDecimal) CoreConfidenceTests(org.mvel2.tests.core.CoreConfidenceTests)

Example 10 with Bar

use of org.mvel2.tests.core.res.Bar 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());
}
Also used : ExpressionCompiler(org.mvel2.compiler.ExpressionCompiler)

Aggregations

ExpressionCompiler (org.mvel2.compiler.ExpressionCompiler)16 CompiledExpression (org.mvel2.compiler.CompiledExpression)9 Foo (org.mvel2.tests.core.res.Foo)9 ParserContext (org.mvel2.ParserContext)8 Serializable (java.io.Serializable)7 MapVariableResolverFactory (org.mvel2.integration.impl.MapVariableResolverFactory)5 HashMap (java.util.HashMap)4 VariableResolverFactory (org.mvel2.integration.VariableResolverFactory)4 DefaultLocalVariableResolverFactory (org.mvel2.integration.impl.DefaultLocalVariableResolverFactory)4 Map (java.util.Map)3 HashSet (java.util.HashSet)2 Macro (org.mvel2.Macro)2 Debugger (org.mvel2.debug.Debugger)2 Frame (org.mvel2.debug.Frame)2 Interceptor (org.mvel2.integration.Interceptor)2 Bar (org.mvel2.tests.core.res.Bar)2 FastList (org.mvel2.util.FastList)2 BigDecimal (java.math.BigDecimal)1 List (java.util.List)1 ASTNode (org.mvel2.ast.ASTNode)1