use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.
the class FEELParserTest method testContextPathExpression2.
@Test
public void testContextPathExpression2() {
String inputExpression = "{ x : { y : \"foo\" } }.x.y";
BaseNode pathBase = parse(inputExpression);
assertThat(pathBase, is(instanceOf(PathExpressionNode.class)));
assertThat(pathBase.getText(), is(inputExpression));
assertThat(pathBase.getResultType(), is(BuiltInType.STRING));
PathExpressionNode pathExpr = (PathExpressionNode) pathBase;
assertThat(pathExpr.getExpression(), is(instanceOf(ContextNode.class)));
assertThat(pathExpr.getExpression().getText(), is("{ x : { y : \"foo\" } }"));
assertThat(pathExpr.getName(), is(instanceOf(QualifiedNameNode.class)));
assertThat(pathExpr.getName().getText(), is("x.y"));
}
use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.
the class FEELParserTest method testNullLiteral.
@Test
public void testNullLiteral() {
String inputExpression = "null";
BaseNode nullLit = parse(inputExpression);
assertThat(nullLit, is(instanceOf(NullNode.class)));
assertThat(nullLit.getResultType(), is(BuiltInType.UNKNOWN));
assertLocation(inputExpression, nullLit);
}
use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.
the class FEELParserTest method testContextPathExpression3.
@Test
public void testContextPathExpression3() {
String inputExpression = "{ first name : \"bob\" }.first name";
BaseNode pathBase = parse(inputExpression);
assertThat(pathBase, is(instanceOf(PathExpressionNode.class)));
assertThat(pathBase.getText(), is(inputExpression));
assertThat(pathBase.getResultType(), is(BuiltInType.STRING));
PathExpressionNode pathExpr = (PathExpressionNode) pathBase;
assertThat(pathExpr.getExpression(), is(instanceOf(ContextNode.class)));
assertThat(pathExpr.getExpression().getText(), is("{ first name : \"bob\" }"));
assertThat(pathExpr.getName(), is(instanceOf(NameRefNode.class)));
assertThat(pathExpr.getName().getText(), is("first name"));
}
use of org.kie.dmn.feel.lang.ast.BaseNode 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