Skip to content

Commit

Permalink
[incubator-kie-issues#1744] Don't fail a range comparison in FEEL whe…
Browse files Browse the repository at this point in the history
…n a unary test range is used (#6231)

* [incubator-kie-issues#1744] WIP

* [incubator-kie-issues#1744] Disabling uncompatible (?) test. Add comparison test.

---------

Co-authored-by: Gabriele-Cardosi <gabriele.cardosi@ibm.com>
  • Loading branch information
gitgabrio and Gabriele-Cardosi authored Jan 27, 2025
1 parent afde373 commit ffc421a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down Expand Up @@ -680,6 +681,7 @@ void decisionTableOutputMessageRowIndex(boolean useExecModelCompiler) {

@ParameterizedTest
@MethodSource("params")
@Disabled("Disabled due to required clarifications on DMN specs")
void dTand(boolean useExecModelCompiler) {
init(useExecModelCompiler);
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DTand.dmn", this.getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ public BaseNode visitInterval(FEEL_1_1Parser.IntervalContext ctx) {
public BaseNode visitPositiveUnaryTestIneq(FEEL_1_1Parser.PositiveUnaryTestIneqContext ctx) {
BaseNode value = visit( ctx.endpoint() );
String op = ctx.op.getText();
return ASTBuilderFactory.newUnaryTestNode( ctx, op, value );
UnaryOperator unaryOperator = UnaryOperator.determineOperator(op);
return unaryOperator.equals(UnaryOperator.EQ) ? ASTBuilderFactory.newIntervalNode(ctx, RangeNode.IntervalBoundary.CLOSED, value, value, RangeNode.IntervalBoundary.CLOSED) :
ASTBuilderFactory.newUnaryTestNode( ctx, op, value );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ protected void instanceTest(String expression, Object result, FEELEvent.Severity
private static Collection<Object[]> data() {
final Object[][] cases = new Object[][]{
// when converting from unary tests, boundaries are dictated by comparison
{"(=1)", new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.ONE, BigDecimal.ONE, Range.RangeBoundary.CLOSED), null},
{"(>1)", new RangeImpl(Range.RangeBoundary.OPEN, BigDecimal.ONE, new UndefinedValueComparable(), Range.RangeBoundary.OPEN), null},
{"(>=1)", new RangeImpl(Range.RangeBoundary.CLOSED, BigDecimal.ONE, new UndefinedValueComparable(), Range.RangeBoundary.OPEN), null},
{"(<1)", new RangeImpl(Range.RangeBoundary.OPEN, new UndefinedValueComparable(), BigDecimal.ONE, Range.RangeBoundary.OPEN), null},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ private static Collection<Object[]> data() {
{ "false != false", Boolean.FALSE , null},
{ "false != true", Boolean.TRUE , null},
{ "true != false", Boolean.TRUE , null},

// other comparisons
{ "duration(\"P1Y\") < duration(\"P2Y\")", Boolean.TRUE , null},
{ "duration(\"P1Y\") > duration(\"P2Y\")", Boolean.FALSE , null},

// other types of equalities
{ "[ 1..3 ] = [ 1..3 ]", Boolean.TRUE , null},
{ "(=10) = (=10)", Boolean.TRUE , null},
{ "[ \"1\"..\"3\" ] = [ \"1\"..\"3\" ]", Boolean.TRUE , null},
{ "[\"1978-09-12\"..\"1978-10-12\"] = [\"1978-09-12\"..\"1978-10-12\"]", Boolean.TRUE, null},
{ "[ 1, 2, 3] = [1, 2, 3]", Boolean.TRUE , null},
Expand Down Expand Up @@ -107,12 +108,12 @@ private static Collection<Object[]> data() {
{ "null = null", Boolean.TRUE , null},
{ "null != null", Boolean.FALSE , null},

// RHDM-1119
// RHDM-1119
{ "{ m: <18 }.m(16)", true, null}, // Working expression, for the expr raising compilation Warn test have been moved.
{ "{list : 1, r: list < 3}.r", Boolean.TRUE , null}, // strange name for a number literal, intended this way.
{ "{list : 1, r: list< 3}.r", Boolean.TRUE , null},
{ "{list : 1, r: list< 3}.r", Boolean.TRUE , null},
{ "{context : 1, r: context < 3}.r", Boolean.TRUE , null}, // strange name for a number literal, intended this way.
{ "{context : 1, r: context< 3}.r", Boolean.TRUE , null},
{ "{context : 1, r: context< 3}.r", Boolean.TRUE , null},
};
return addAdditionalParameters(cases, false);
}
Expand Down

0 comments on commit ffc421a

Please sign in to comment.