use of com.dexels.navajo.parser.Expression in project navajo by Dexels.
the class TestCompiledExpression method testNamedExpression.
@Test
public void testNamedExpression() throws ParseException {
String expression = "aap=1+1";
StringReader sr = new StringReader(expression);
CompiledParser cp = new CompiledParser(sr);
cp.KeyValue();
ASTKeyValueNode atn = (ASTKeyValueNode) cp.getJJTree().rootNode();
List<String> problems = new ArrayList<>();
NamedExpression ne = (NamedExpression) atn.interpretToLambda(problems, expression, fn -> FunctionClassification.DEFAULT, name -> Optional.empty());
Assert.assertEquals(0, problems.size());
Assert.assertEquals("aap", ne.name);
Assert.assertEquals(2, ne.apply().value);
}
Aggregations