Search in sources :

Example 41 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestAstLambdaExpression method testSpec04.

@Test
public void testSpec04() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("v = (x,y)->x+y; v(3,4)", Integer.class);
    Assert.assertEquals(Integer.valueOf(7), result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 42 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestAstLambdaExpression method testInvocation01.

@Test
public void testInvocation01() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("(()->2)()", Integer.class);
    Assert.assertEquals(Integer.valueOf(2), result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 43 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestAstLambdaExpression method testNested06.

@Test
public void testNested06() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("(()->y->()->()->x->x-y)()(1)()(3)(2)", Integer.class);
    Assert.assertEquals(Integer.valueOf(1), result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 44 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestAstLambdaExpression method testLambdaAsFunction02.

@Test
public void testLambdaAsFunction02() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("v = (()->y->2-y); v()(1)", Integer.class);
    Assert.assertEquals(Integer.valueOf(1), result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 45 with ELProcessor

use of jakarta.el.ELProcessor in project tomcat by apache.

the class TestAstMapData method testLiteralWithVariable.

@Test
public void testLiteralWithVariable() {
    ELProcessor elp = new ELProcessor();
    String key = "myKey";
    String value = "myValue";
    elp.setVariable("aaa", "'" + key + "'");
    elp.setVariable("bbb", "'" + value + "'");
    Object result = elp.eval("{ aaa : bbb }.get(aaa)");
    Assert.assertEquals(value, result);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Aggregations

ELProcessor (jakarta.el.ELProcessor)138 Test (org.junit.Test)133 ArrayList (java.util.ArrayList)13 ELContext (jakarta.el.ELContext)8 ValueExpression (jakarta.el.ValueExpression)8 ExpressionFactory (jakarta.el.ExpressionFactory)7 TesterBeanA (org.apache.el.TesterBeanA)5 List (java.util.List)1