Search in sources :

Example 61 with ELProcessor

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

the class TestAstLambdaExpression method testNested04.

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

Example 62 with ELProcessor

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

the class TestAstLambdaExpression method testNested07.

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

Example 63 with ELProcessor

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

the class TestAstLambdaExpression method testNested03.

@Test(expected = ELException.class)
public void testNested03() {
    ELProcessor processor = new ELProcessor();
    // More method parameters than there are nested lambda expressions
    processor.getValue("(()->y->()->2-y)()(1)()()", Integer.class);
}
Also used : ELProcessor(jakarta.el.ELProcessor) Test(org.junit.Test)

Example 64 with ELProcessor

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

the class TestAstLambdaExpression method testLambdaAsFunction05.

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

Example 65 with ELProcessor

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

the class TestAstLambdaExpression method testSpec05.

@Test
public void testSpec05() {
    ELProcessor processor = new ELProcessor();
    Object result = processor.getValue("fact = n -> n==0? 1: n*fact(n-1); fact(5)", Integer.class);
    Assert.assertEquals(Integer.valueOf(120), 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