Skip to content

Commit

Permalink
[#655] DMN 1.5: Explicit equality operators in unary tests (DMN15-108)
Browse files Browse the repository at this point in the history
  • Loading branch information
opatrascoiu committed Nov 26, 2024
1 parent e915805 commit 4ba3ca6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public OperatorRange(String operator, Expression<T> endpoint) {
this.endpoint = endpoint;
if (operator == null || "=".equals(operator)) {
this.endpointsRange = new EndpointsRange<>(false, endpoint, false, endpoint);
} else if ("!=".equals(operator)) {
this.endpointsRange = new EndpointsRange<>(false, endpoint, false, endpoint);
} else if ("<".equals(operator)) {
this.endpointsRange = new EndpointsRange<>(true, null, true, endpoint);
} else if ("<=".equals(operator)) {
Expand Down
11 changes: 8 additions & 3 deletions dmn-core/src/main/resources/dmn/1.5/FEELParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ positiveUnaryTest returns [Expression ast]:
{$ast = astFactory.toPositiveUnaryTest($expression.ast);}
;

opRel returns [String ast]:
(op = EQ | op = NE | op = LT | op = GT | op = LE | op = GE)
{$ast = $op.text;}
;

simplePositiveUnaryTest returns [Expression ast] :
( op = LT | op = LE | op = GT | op = GE ) opd = endpoint
{$ast = $op == null ? astFactory.toOperatorRange(null, $opd.ast) : astFactory.toOperatorRange($op.text, $opd.ast);}
op = opRel opd = endpoint
{$ast = astFactory.toOperatorRange($op.ast, $opd.ast);}
|
opd2 = interval
{$ast = $opd2.ast;}
Expand Down Expand Up @@ -235,7 +240,7 @@ comparison returns [Expression ast] :
ae1 = arithmeticExpression
{$ast = $ae1.ast;}
(
(op = EQ | op = NE | op = LT | op = GT | op = LE | op = GE) ae2 = arithmeticExpression
op = opRel ae2 = arithmeticExpression
{$ast = astFactory.toComparison($op.text, $ae1.ast, $ae2.ast);}
|
BETWEEN leftEndpoint = expression AND rightEndpoint = expression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,18 @@ public void testOperatorRange() {
//
// Simple Types
//
doUnaryTestsTest(entries, "number", "= 123.45",
"PositiveUnaryTests(OperatorRange(=,NumericLiteral(123.45)))",
"TupleType(boolean)",
"numericEqual(number, number(\"123.45\"))",
this.lib.numericEqual(number, this.lib.number("123.45")),
false);
doUnaryTestsTest(entries, "number", "!= 123.45",
"PositiveUnaryTests(OperatorRange(!=,NumericLiteral(123.45)))",
"TupleType(boolean)",
"numericNotEqual(number, number(\"123.45\"))",
this.lib.numericNotEqual(number, this.lib.number("123.45")),
true);
doUnaryTestsTest(entries, "number", "< 123.45",
"PositiveUnaryTests(OperatorRange(<,NumericLiteral(123.45)))",
"TupleType(boolean)",
Expand Down

0 comments on commit 4ba3ca6

Please sign in to comment.