Search in sources :

Example 1 with SignedUnaryNode

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

the class FEELParserTest method testNegativeIntegerLiteral.

@Test
public void testNegativeIntegerLiteral() {
    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.NEGATIVE));
    assertThat(sun.getExpression(), is(instanceOf(NumberNode.class)));
    assertThat(sun.getExpression().getText(), is("10"));
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) SignedUnaryNode(org.kie.dmn.feel.lang.ast.SignedUnaryNode) Test(org.junit.Test)

Example 2 with SignedUnaryNode

use of org.kie.dmn.feel.lang.ast.SignedUnaryNode 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"));
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) SignedUnaryNode(org.kie.dmn.feel.lang.ast.SignedUnaryNode) Test(org.junit.Test)

Example 3 with SignedUnaryNode

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

the class FEELParserTest method testPositiveFloatLiteral.

@Test
public void testPositiveFloatLiteral() {
    String inputExpression = "+10.5";
    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.5"));
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) SignedUnaryNode(org.kie.dmn.feel.lang.ast.SignedUnaryNode) Test(org.junit.Test)

Example 4 with SignedUnaryNode

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

the class FEELParserTest method testNegativeFloatLiteral.

@Test
public void testNegativeFloatLiteral() {
    String inputExpression = "-10.5";
    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.NEGATIVE));
    assertThat(sun.getExpression(), is(instanceOf(NumberNode.class)));
    assertThat(sun.getExpression().getText(), is("10.5"));
}
Also used : BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) SignedUnaryNode(org.kie.dmn.feel.lang.ast.SignedUnaryNode) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 BaseNode (org.kie.dmn.feel.lang.ast.BaseNode)4 SignedUnaryNode (org.kie.dmn.feel.lang.ast.SignedUnaryNode)4