Search in sources :

Example 1 with InstanceOfNode

use of org.kie.dmn.feel.lang.ast.InstanceOfNode in project drools by kiegroup.

the class FEELParserTest method testInstanceOfExpressionAnd.

@Test
public void testInstanceOfExpressionAnd() {
    String inputExpression = "\"foo\" instance of string and 10 instance of number";
    BaseNode andExpr = parse(inputExpression);
    assertThat(andExpr, is(instanceOf(InfixOpNode.class)));
    assertThat(andExpr.getText(), is(inputExpression));
    assertThat(andExpr.getResultType(), is(BuiltInType.BOOLEAN));
    InfixOpNode and = (InfixOpNode) andExpr;
    assertThat(and.getOperator(), is(InfixOpNode.InfixOperator.AND));
    assertThat(and.getLeft(), is(instanceOf(InstanceOfNode.class)));
    assertThat(and.getRight(), is(instanceOf(InstanceOfNode.class)));
    assertThat(and.getLeft().getText(), is("\"foo\" instance of string"));
    assertThat(and.getRight().getText(), is("10 instance of number"));
    assertThat(and.getLeft().getResultType(), is(BuiltInType.BOOLEAN));
    assertThat(and.getRight().getResultType(), is(BuiltInType.BOOLEAN));
    InstanceOfNode ioExpr = (InstanceOfNode) and.getLeft();
    assertThat(ioExpr.getExpression(), is(instanceOf(StringNode.class)));
    assertThat(ioExpr.getExpression().getText(), is("\"foo\""));
    assertThat(ioExpr.getType(), is(instanceOf(TypeNode.class)));
    assertThat(ioExpr.getType().getText(), is("string"));
    ioExpr = (InstanceOfNode) and.getRight();
    assertThat(ioExpr.getExpression(), is(instanceOf(NumberNode.class)));
    assertThat(ioExpr.getExpression().getText(), is("10"));
    assertThat(ioExpr.getType(), is(instanceOf(TypeNode.class)));
    assertThat(ioExpr.getType().getText(), is("number"));
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) InfixOpNode(org.kie.dmn.feel.lang.ast.InfixOpNode) InstanceOfNode(org.kie.dmn.feel.lang.ast.InstanceOfNode) Test(org.junit.Test)

Example 2 with InstanceOfNode

use of org.kie.dmn.feel.lang.ast.InstanceOfNode in project drools by kiegroup.

the class FEELParserTest method testInstanceOfExpressionFunction.

@Test
public void testInstanceOfExpressionFunction() {
    String inputExpression = "duration instance of function";
    BaseNode instanceOfBase = parse(inputExpression);
    assertThat(instanceOfBase, is(instanceOf(InstanceOfNode.class)));
    assertThat(instanceOfBase.getText(), is(inputExpression));
    assertThat(instanceOfBase.getResultType(), is(BuiltInType.BOOLEAN));
    InstanceOfNode ioExpr = (InstanceOfNode) instanceOfBase;
    assertThat(ioExpr.getExpression(), is(instanceOf(NameRefNode.class)));
    assertThat(ioExpr.getExpression().getText(), is("duration"));
    assertThat(ioExpr.getType(), is(instanceOf(TypeNode.class)));
    assertThat(ioExpr.getType().getText(), is("function"));
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) InstanceOfNode(org.kie.dmn.feel.lang.ast.InstanceOfNode) Test(org.junit.Test)

Example 3 with InstanceOfNode

use of org.kie.dmn.feel.lang.ast.InstanceOfNode in project drools by kiegroup.

the class FEELParserTest method testInstanceOfExpression.

@Test
public void testInstanceOfExpression() {
    String inputExpression = "\"foo\" instance of string";
    BaseNode instanceOfBase = parse(inputExpression);
    assertThat(instanceOfBase, is(instanceOf(InstanceOfNode.class)));
    assertThat(instanceOfBase.getText(), is(inputExpression));
    assertThat(instanceOfBase.getResultType(), is(BuiltInType.BOOLEAN));
    InstanceOfNode ioExpr = (InstanceOfNode) instanceOfBase;
    assertThat(ioExpr.getExpression(), is(instanceOf(StringNode.class)));
    assertThat(ioExpr.getExpression().getText(), is("\"foo\""));
    assertThat(ioExpr.getType(), is(instanceOf(TypeNode.class)));
    assertThat(ioExpr.getType().getText(), is("string"));
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) InstanceOfNode(org.kie.dmn.feel.lang.ast.InstanceOfNode) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 BaseNode (org.kie.dmn.feel.lang.ast.BaseNode)3 InstanceOfNode (org.kie.dmn.feel.lang.ast.InstanceOfNode)3 InfixOpNode (org.kie.dmn.feel.lang.ast.InfixOpNode)1