use of org.kie.dmn.feel.lang.ast.InfixOpNode in project drools by kiegroup.
the class FEELParserTest method testSub1.
@Test
public void testSub1() {
String inputExpression = "(y - 5) ** 3";
BaseNode infix = parse(inputExpression, mapOf(entry("y", BuiltInType.NUMBER)));
assertThat(infix, is(instanceOf(InfixOpNode.class)));
assertThat(infix.getResultType(), is(BuiltInType.NUMBER));
assertThat(infix.getText(), is(inputExpression));
InfixOpNode sub = (InfixOpNode) infix;
assertThat(sub.getLeft(), is(instanceOf(InfixOpNode.class)));
assertThat(sub.getLeft().getText(), is("y - 5"));
assertThat(sub.getOperator(), is(InfixOpNode.InfixOperator.POW));
assertThat(sub.getRight(), is(instanceOf(NumberNode.class)));
assertThat(sub.getRight().getText(), is("3"));
InfixOpNode mult = (InfixOpNode) sub.getLeft();
assertThat(mult.getLeft(), is(instanceOf(NameRefNode.class)));
assertThat(mult.getLeft().getText(), is("y"));
assertThat(mult.getOperator(), is(InfixOpNode.InfixOperator.SUB));
assertThat(mult.getRight(), is(instanceOf(NumberNode.class)));
assertThat(mult.getRight().getText(), is("5"));
}
Aggregations