Skip to content

Commit

Permalink
test: Verify unary-test negation
Browse files Browse the repository at this point in the history
Add test cases for the unary-test negation using not().

(cherry picked from commit b2edd82)
  • Loading branch information
saig0 authored and github-actions[bot] committed Jan 21, 2025
1 parent f1fb818 commit 56f95ca
Showing 1 changed file with 95 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -675,4 +675,99 @@ class InterpreterUnaryTest
evaluateUnaryTests(expression = "list contains([1,2], 3)", 3) should returnResult(false)
}

"A negation" should "return true if it evaluates to a value that is not equal to the implicit value" in {

evaluateUnaryTests("not(1)", 3) should returnResult(true)
evaluateUnaryTests(""" not("a") """, "b") should returnResult(true)
}

it should "return false if it evaluates to a value that is equal to the implicit value" in {

evaluateUnaryTests("not(3)", 3) should returnResult(false)
evaluateUnaryTests(""" not("b") """, "b") should returnResult(false)
}

it should "return null if it evaluates to a value that has a different type than the implicit value" in {

evaluateUnaryTests("not(1)", "b") should returnNull()
evaluateUnaryTests(""" not("a") """, 2) should returnNull()
}

it should "return true if it evaluates to false when the implicit value is applied to it" in {

evaluateUnaryTests("not(< 3)", 5) should returnResult(true)
evaluateUnaryTests("not([1..3])", 5) should returnResult(true)
evaluateUnaryTests("not(> x)", inputValue = 5, variables = Map("x" -> 10)) should returnResult(
true
)
}

it should "return false if it evaluates to true when the implicit value is applied to it" in {

evaluateUnaryTests("not(< 10)", 5) should returnResult(false)
evaluateUnaryTests("not([1..10])", 5) should returnResult(false)
evaluateUnaryTests("not(> x)", inputValue = 5, variables = Map("x" -> 3)) should returnResult(
false
)
}

it should "return null if it evaluates to null when the implicit value is applied to it" in {

evaluateUnaryTests("not(< 3)", "a") should returnNull()
evaluateUnaryTests("not(< 3)", inputValue = null) should returnNull()
}

it should "return true if it evaluates to false" in {

evaluateUnaryTests("not(x)", inputValue = 3, variables = Map("x" -> false)) should returnResult(
true
)
evaluateUnaryTests("not(4 > 10)", 3) should returnResult(true)
evaluateUnaryTests("not(odd(4))", 3) should returnResult(true)
evaluateUnaryTests("not(list contains([1,2], 3))", 3) should returnResult(true)
}

it should "return false if it evaluates to true" in {

evaluateUnaryTests("not(x)", inputValue = 3, variables = Map("x" -> true)) should returnResult(
false
)
evaluateUnaryTests("not(4 < 10)", 3) should returnResult(false)
evaluateUnaryTests("not(even(4))", 3) should returnResult(false)
evaluateUnaryTests("not(list contains([1,2,3], 3))", 3) should returnResult(false)
}

it should "return true if it evaluates to null and the implicit value is not null" in {

evaluateUnaryTests("not(null)", 5) should returnResult(true)
evaluateUnaryTests("not(not_existing)", 5) should returnResult(true)
}

it should "return false if it evaluates to null and the implicit value is null" in {

evaluateUnaryTests("not(null)", inputValue = null) should returnResult(false)
evaluateUnaryTests("not(not_existing)", inputValue = null) should returnResult(false)
}

it should "return true if a disjunction evaluates to false" in {

evaluateUnaryTests("not(2,3)", 5) should returnResult(true)
evaluateUnaryTests("not(< 3, > 10)", 5) should returnResult(true)
evaluateUnaryTests("not([0..3], [10..20])", 5) should returnResult(true)
}

it should "return false if a disjunction evaluates to true" in {

evaluateUnaryTests("not(2,3)", 3) should returnResult(false)
evaluateUnaryTests("not(< 3, > 10)", 1) should returnResult(false)
evaluateUnaryTests("not([0..3], [10..20])", 1) should returnResult(false)
}

it should "return null if a disjunction evaluates to null" in {

evaluateUnaryTests("not(2,3)", "a") should returnNull()
evaluateUnaryTests("not(< 3, > 10)", "a") should returnNull()
evaluateUnaryTests("not([0..3], [10..20])", "a") should returnNull()
}

}

0 comments on commit 56f95ca

Please sign in to comment.