camunda / feel-scala

FEEL parser and interpreter written in Scala
https://camunda.github.io/feel-scala/
Apache License 2.0
120 stars 50 forks source link

String conversion of negative duration #631

Closed s-frick closed 1 year ago

s-frick commented 1 year ago

Describe the bug A negative duration is converted to a wrong format.

To Reproduce

Compiling /mnt/c/git/scala/feel-scala/feel-repl.sc
===== FEEL Engine REPL (1.11.2) ======
Evaluate FEEL expressions using 'feel("1 + 3")'
Evaluate FEEL unary-tests using 'unaryTests("[2..5]", 4)'
Provide variables as Map using 'feel("x + 3", Map("x" -> 2))'
Provide variables as JSON string using 'feel("x + 3", "{ \"x\" : 2 }")'
Welcome to the Ammonite Repl 2.4.0 (Scala 2.13.6 Java 18.0.1)
@ feel("string(duration(\"-P1Y\"))")
> P-1Y

Expected behavior -P1Y Related test case in the DMN TCK

    <decision name="ym_duration_002" id="_ym_duration_002">
        <description>Tests FEEL expression: 'string(duration("-P1Y"))' and expects result: '"-P1Y" (string)'</description>
        <question>Result of FEEL expression 'string(duration("-P1Y"))'?</question>
        <allowedAnswers>"-P1Y" (string)</allowedAnswers>
        <variable typeRef="string" name="ym_duration_002"/>
        <literalExpression>
            <text>string(duration("-P1Y"))</text>
        </literalExpression>
    </decision>

Environment