use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.
the class FEELParserTest method testFunctionInvocationWithExpressionParameters.
@Test
public void testFunctionInvocationWithExpressionParameters() {
String inputExpression = "date and time( date(\"2016-07-29\"), time(\"19:47:53\") )";
BaseNode functionBase = parse(inputExpression);
assertThat(functionBase, is(instanceOf(FunctionInvocationNode.class)));
assertThat(functionBase.getText(), is(inputExpression));
FunctionInvocationNode function = (FunctionInvocationNode) functionBase;
assertThat(function.getName(), is(instanceOf(NameRefNode.class)));
assertThat(function.getName().getText(), is("date and time"));
assertThat(function.getParams(), is(instanceOf(ListNode.class)));
assertThat(function.getParams().getElements().size(), is(2));
assertThat(function.getParams().getElements().get(0), is(instanceOf(FunctionInvocationNode.class)));
assertThat(function.getParams().getElements().get(1), is(instanceOf(FunctionInvocationNode.class)));
}
use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.
the class FEELParserTest method testQuantifiedExpressionSome.
@Test
public void testQuantifiedExpressionSome() {
String inputExpression = "some item in order.items satisfies item.price > 100";
BaseNode someBase = parse(inputExpression);
assertThat(someBase, is(instanceOf(QuantifiedExpressionNode.class)));
assertThat(someBase.getText(), is(inputExpression));
assertThat(someBase.getResultType(), is(BuiltInType.BOOLEAN));
QuantifiedExpressionNode someExpr = (QuantifiedExpressionNode) someBase;
assertThat(someExpr.getQuantifier(), is(QuantifiedExpressionNode.Quantifier.SOME));
assertThat(someExpr.getIterationContexts().size(), is(1));
assertThat(someExpr.getIterationContexts().get(0).getText(), is("item in order.items"));
assertThat(someExpr.getExpression().getText(), is("item.price > 100"));
}
use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.
the class FEELParserTest method testParensWithLiteral.
@Test
public void testParensWithLiteral() {
String inputExpression = "(10.5 )";
BaseNode number = parse(inputExpression);
assertThat(number, is(instanceOf(NumberNode.class)));
assertThat(number.getResultType(), is(BuiltInType.NUMBER));
assertThat(number.getText(), is("10.5"));
}
use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.
the class FEELParserTest method testInUnaryTest.
@Test
public void testInUnaryTest() {
String inputExpression = "x - y in [(10+5)..(a*b))";
BaseNode inNode = parse(inputExpression);
assertThat(inNode, is(instanceOf(InNode.class)));
assertThat(inNode.getResultType(), is(BuiltInType.BOOLEAN));
assertThat(inNode.getText(), is(inputExpression));
InNode in = (InNode) inNode;
assertThat(in.getValue(), is(instanceOf(InfixOpNode.class)));
assertThat(in.getValue().getText(), is("x - y"));
assertThat(in.getExprs(), is(instanceOf(RangeNode.class)));
assertThat(in.getExprs().getText(), is("[(10+5)..(a*b))"));
}
use of org.kie.dmn.feel.lang.ast.BaseNode in project drools by kiegroup.
the class FEELParserTest method testPositiveIntegerLiteral.
@Test
public void testPositiveIntegerLiteral() {
String inputExpression = "+10";
BaseNode number = parse(inputExpression);
assertThat(number, is(instanceOf(SignedUnaryNode.class)));
assertThat(number.getResultType(), is(BuiltInType.NUMBER));
assertLocation(inputExpression, number);
SignedUnaryNode sun = (SignedUnaryNode) number;
assertThat(sun.getSign(), is(SignedUnaryNode.Sign.POSITIVE));
assertThat(sun.getExpression(), is(instanceOf(NumberNode.class)));
assertThat(sun.getExpression().getText(), is("10"));
}
Aggregations