Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse unary-tests expression with boolean and conjunction/disjunction #435

Merged
merged 4 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
saig0 marked this conversation as resolved.
Show resolved Hide resolved

private def anyInput[_: P]: P[Exp] =
P(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ class InterpreterUnaryTest
evalUnaryTests(true, """ "a" = "b" """) should be(ValBoolean(false))
}

it should "compare to a conjunction (and)" in {
evalUnaryTests(true, "true and true") shouldBe ValBoolean(true)
evalUnaryTests(true, "false and true") shouldBe ValBoolean(false)
}

it should "compare to a disjunction (or)" in {
evalUnaryTests(true, "true or true") shouldBe ValBoolean(true)
evalUnaryTests(true, "false or true") shouldBe ValBoolean(true)
evalUnaryTests(true, "false or false") shouldBe ValBoolean(false)
}

korthout marked this conversation as resolved.
Show resolved Hide resolved
"A date" should "compare with '<'" in {

evalUnaryTests(date("2015-09-17"), """< date("2015-09-18")""") should be(
Expand Down