diff --git a/src/main/scala/org/camunda/feel/impl/parser/FeelParser.scala b/src/main/scala/org/camunda/feel/impl/parser/FeelParser.scala index 7b1bb289b..e1fed305a 100644 --- a/src/main/scala/org/camunda/feel/impl/parser/FeelParser.scala +++ b/src/main/scala/org/camunda/feel/impl/parser/FeelParser.scala @@ -574,7 +574,7 @@ object FeelParser { // boolean literals are ambiguous for unary-tests. give precedence to comparison with input. private def positiveUnaryTest[_: P]: P[Exp] = - boolean.map(InputEqualTo) | expression.map(UnaryTestExpression) + (boolean.map(InputEqualTo) ~ End) | expression.map(UnaryTestExpression) private def anyInput[_: P]: P[Exp] = P( diff --git a/src/test/scala/org/camunda/feel/impl/interpreter/InterpreterUnaryTest.scala b/src/test/scala/org/camunda/feel/impl/interpreter/InterpreterUnaryTest.scala index 53b2ed2ea..2d23f4124 100644 --- a/src/test/scala/org/camunda/feel/impl/interpreter/InterpreterUnaryTest.scala +++ b/src/test/scala/org/camunda/feel/impl/interpreter/InterpreterUnaryTest.scala @@ -182,6 +182,34 @@ class InterpreterUnaryTest evalUnaryTests(true, """ "a" = "b" """) should be(ValBoolean(false)) } + it should "compare to a conjunction (and)" in { + // it is uncommon to use a conjunction in a unary-tests but the engine should be able to parse + evalUnaryTests(true, "true and true") shouldBe ValBoolean(true) + evalUnaryTests(true, "false and true") shouldBe ValBoolean(false) + + evalUnaryTests(true, "true and null") shouldBe ValBoolean(false) + evalUnaryTests(true, "false and null") shouldBe ValBoolean(false) + + evalUnaryTests(true, """true and "otherwise" """) shouldBe ValBoolean( + false) + evalUnaryTests(true, """false and "otherwise" """) shouldBe ValBoolean( + false) + } + + it should "compare to a disjunction (or)" in { + // it is uncommon to use a disjunction in a unary-tests but the engine should be able to parse + evalUnaryTests(true, "true or true") shouldBe ValBoolean(true) + evalUnaryTests(true, "false or true") shouldBe ValBoolean(true) + evalUnaryTests(true, "false or false") shouldBe ValBoolean(false) + + evalUnaryTests(true, "true or null") shouldBe ValBoolean(true) + evalUnaryTests(true, "false or null") shouldBe ValBoolean(false) + + evalUnaryTests(true, """true or "otherwise" """) shouldBe ValBoolean(true) + evalUnaryTests(true, """false or "otherwise" """) shouldBe ValBoolean( + false) + } + "A date" should "compare with '<'" in { evalUnaryTests(date("2015-09-17"), """< date("2015-09-18")""") should be(