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

Handle non-existing variable in comparison #676

Merged
merged 4 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class BuiltinValueMapperInputTest extends AnyFlatSpec with Matchers {
engine
.evalExpression("bar.foo = \"baz\"",
context = Context.StaticContext(variables, null))
.getOrElse() shouldBe ()
.getOrElse() shouldBe false
}

it should "read scala string from object getter with attribute notation" in {
Expand Down Expand Up @@ -292,7 +292,7 @@ class BuiltinValueMapperInputTest extends AnyFlatSpec with Matchers {
engine
.evalExpression("bar.baz = \"foo\"",
context = Context.StaticContext(variables, null))
.getOrElse() shouldBe ()
.getOrElse() shouldBe false
}

it should "read java.util.Map" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,22 +264,22 @@ class InterpreterExpressionTest

"A variable name" should "not be a key-word" in {

eval("some = true") shouldBe a[ValError]
eval("every = true") shouldBe a[ValError]
eval("if = true") shouldBe a[ValError]
eval("then = true") shouldBe a[ValError]
eval("else = true") shouldBe a[ValError]
eval("function = true") shouldBe a[ValError]
eval("for = true") shouldBe a[ValError]
eval("between = true") shouldBe a[ValError]
eval("instance = true") shouldBe a[ValError]
eval("of = true") shouldBe a[ValError]
eval("not = true") shouldBe a[ValError]
eval("in = true") shouldBe a[ValError]
eval("satisfies = true") shouldBe a[ValError]
eval("and = true") shouldBe a[ValError]
eval("or = true") shouldBe a[ValError]
eval("return = true") shouldBe a[ValError]
eval("some = true", Map("some" -> 1)) shouldBe a[ValError]
eval("every = true", Map("every" -> 1)) shouldBe a[ValError]
eval("if = true", Map("if" -> 1)) shouldBe a[ValError]
eval("then = true", Map("then" -> 1)) shouldBe a[ValError]
eval("else = true", Map("else" -> 1)) shouldBe a[ValError]
eval("function = true", Map("function" -> 1)) shouldBe a[ValError]
eval("for = true", Map("for" -> 1)) shouldBe a[ValError]
eval("between = true", Map("between" -> 1)) shouldBe a[ValError]
eval("instance = true", Map("instance" -> 1)) shouldBe a[ValError]
eval("of = true", Map("of" -> 1)) shouldBe a[ValError]
eval("not = true", Map("not" -> 1)) shouldBe a[ValError]
eval("in = true", Map("in" -> 1)) shouldBe a[ValError]
eval("satisfies = true", Map("satisfies" -> 1)) shouldBe a[ValError]
eval("and = true", Map("and" -> 1)) shouldBe a[ValError]
eval("or = true", Map("or" -> 1)) shouldBe a[ValError]
eval("return = true", Map("return" -> 1)) shouldBe a[ValError]
remcowesterhoud marked this conversation as resolved.
Show resolved Hide resolved
}

List(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,13 @@ class InterpreterNumberExpressionTest
eval("null = 2") should be(ValBoolean(false))
eval("null != 2") should be(ValBoolean(true))

eval("2 > null") should be(ValBoolean(false))
eval("null < 2") should be(ValBoolean(false))
eval("2 > null") should be(ValNull)
eval("null < 2") should be(ValNull)
}

eval("null in < 2") should be(ValBoolean(false))
eval("null in (2..4)") should be(ValBoolean(false))
ignore should "compare with 'null in'" in {
eval("null in < 2") should be(ValNull)
eval("null in (2..4)") should be(ValNull)
remcowesterhoud marked this conversation as resolved.
Show resolved Hide resolved
}

it should "compare with 'between _ and _'" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,13 @@ class InterpreterUnaryTest
}

it should "compare to null" in {

evalUnaryTests(null, "3") should be(ValBoolean(false))
evalUnaryTests(null, "< 3") should be(ValBoolean(false))
evalUnaryTests(null, "> 3") should be(ValBoolean(false))
evalUnaryTests(null, "(0..10)") should be(ValBoolean(false))
}

ignore should "compare to null with < or >" in {
evalUnaryTests(null, "< 3") should be(ValNull)
evalUnaryTests(null, "> 3") should be(ValNull)
evalUnaryTests(null, "(0..10)") should be(ValNull)
}

"A string" should "be equal to another string" in {
Expand Down