Search in sources :

Example 1 with ParameterNamesFunction

use of com.dexels.navajo.expression.compiled.ParameterNamesFunction in project navajo by Dexels.

the class TestCompiledExpression method testNestedNamedParams.

@Test
public void testNestedNamedParams() throws Exception {
    FunctionInterface testFunction = new ParameterNamesFunction();
    FunctionDefinition fd = new FunctionDefinition(testFunction.getClass().getName(), "description", "input", "result");
    FunctionFactoryFactory.getInstance().addExplicitFunctionDefinition("ParameterNamesFunction", fd);
    String expression = "ParameterNamesFunction(aap=1+1,noot=2+2)";
    StringReader sr = new StringReader(expression);
    CompiledParser cp = new CompiledParser(sr);
    List<String> problems = new ArrayList<>();
    cp.Expression();
    ContextExpression ss = cp.getJJTree().rootNode().interpretToLambda(problems, sr.toString(), fn -> FunctionClassification.DEFAULT, name -> Optional.empty());
    Assert.assertEquals("aap,noot", ss.apply().value);
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) ContextExpression(com.dexels.navajo.expression.api.ContextExpression) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) FunctionDefinition(com.dexels.navajo.expression.api.FunctionDefinition) ParameterNamesFunction(com.dexels.navajo.expression.compiled.ParameterNamesFunction) Test(org.junit.Test)

Aggregations

ContextExpression (com.dexels.navajo.expression.api.ContextExpression)1 FunctionDefinition (com.dexels.navajo.expression.api.FunctionDefinition)1 FunctionInterface (com.dexels.navajo.expression.api.FunctionInterface)1 ParameterNamesFunction (com.dexels.navajo.expression.compiled.ParameterNamesFunction)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1