Skip to content

Commit

Permalink
test: fix existing test cases
Browse files Browse the repository at this point in the history
Expectations of these existing test cases were wrong. They would expect errors or booleans as a result, where we now return a ValNull.

Not all behaviours were clear! As a result some test cases have been ignored until this is clarified.
  • Loading branch information
remcowesterhoud committed Jul 7, 2023
1 parent 34ae560 commit c38488f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 26 deletions.
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]
}

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)
}

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

0 comments on commit c38488f

Please sign in to comment.