tarilabs commented on code in PR #5645:
URL:
https://github.com/apache/incubator-kie-drools/pull/5645#discussion_r1450911237
##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/FEELFunctionsTest.java:
##########
@@ -237,6 +237,12 @@ public static Collection<Object[]> data() {
{ "{a: -2, r: -sum( 1, -abs(a), 3 )}.r", BigDecimal.valueOf(
-2 ) , null},
{ "if list contains ([2.2, 3.0, 4.0], 3) then \"OK\" else
\"NOT_OK\"", "OK" , null},
{ "if list contains ([2.2, 3, 4], 3.000) then \"OK\" else
\"NOT_OK\"", "OK" , null},
+ {"list replace ( null, 3, 6)", null ,
FEELEvent.Severity.ERROR},
+ {"list replace ( [2, 4, 7, 8], null, 6)", null ,
FEELEvent.Severity.ERROR},
+ {"list replace ( [2, 4, 7, 8], 3, 6)",
Arrays.asList(BigDecimal.valueOf(2), BigDecimal.valueOf(4),
BigDecimal.valueOf(6), BigDecimal.valueOf(8)), null},
+ {"list replace ( [2, 4, 7, 8], function(item, newItem) item +
newItem, 6)", null , FEELEvent.Severity.ERROR},
+ {"list replace ( [\"El-1\", \"El-2\", \"El-3\", \"El-4\"],
function(item, newItem) item = \"El-2\", null)", Arrays.asList("El-1", null,
"El-3", "El-4"), null},
+ {"list replace ( [2, 4, 7, 8], function(item, newItem) item <
newItem, 5)", Arrays.asList(BigDecimal.valueOf(5), BigDecimal.valueOf(5),
BigDecimal.valueOf(7), BigDecimal.valueOf(8)), null}
Review Comment:
That's indeed what I would ask to the DMN RTF, since IBM is a member.
Here I can only comment personally as an external observer.
See even your example, you wrote:
```
list replace ( [2, 4, 7, 8], function(item, newItem) item < newItem, 5)
```
the 3rd argument, the item to be replaced into, is the value `5`.
it will always be a value.
and even if you place in there a function invocation, the intent of FEEL/DMN
is to be idempotent, so the resulting value should always be the same.
let's now focus on the 2nd argument of `list replace(`, the
predicate-function.
I personally don't see much of a case where you need then to specify
`newItem` as a second parameter of the predicate-function. It will always be
the value `5`.
So you just could have written it as `function(item) item < 5`.
It could be either of the two:
- in the DMN 1.5 Beta changebar they had a typo, it was not meant to be
signature of `function(item, newItem) ` but it was meant as signature of
`function(item) `
- they really meant `function(item, newItem) `, and I understand it can also
works this way, but to me seems a bit overcomplicated and I didn't understand
the reasoning behind the choice --should be asked to the DMN RTF, or maybe
someone in the TCK knows (as some also participate in the RTF as well)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]