expressions icon indicating copy to clipboard operation
expressions copied to clipboard

Wrong answer

Open jaydangar opened this issue 5 years ago • 4 comments

This library is great, but shows wrong answer when for this expression. "-4+4" should be 0 instead it shows 8.

jaydangar avatar Jul 17 '20 03:07 jaydangar

Try 0-4+4 I think library needs something on left of minus sign

apgapg avatar Jul 17 '20 03:07 apgapg

Yes, but it shouldn't be the case. This should be added as a bug.

jaydangar avatar Jul 17 '20 06:07 jaydangar

I understand your concern, but internally lib calls left - right() to subtract expressions. In above case left is missing so it might give some issue. Still this needs to be fixed

apgapg avatar Jul 17 '20 16:07 apgapg

@jaydangar It worked fine in my case

 const expression1 = '-4+4';
 final result1 = ExpressionUtils.evaluate(
        expression: expression1,
        map: map,
      );
 expect(result1, 0);

The test case passed. Expression Utils is just a wrapper of the lib in my case

apgapg avatar Jul 17 '20 16:07 apgapg