Skip to content

Commit

Permalink
test: no longer fail on incorrect filters
Browse files Browse the repository at this point in the history
When the filter doesn't (always) return a boolean or a number (to filter
by index), then we no longer want to fail. Instead, we want to provide a
list of all the elements that did match the filter expression.

So, when the filter does not even evaluate to a boolean value, then we
want to product an empty list.

And, if the filter sometimes evaluates to a boolean value and sometimes
doesn't, then we want a list of those values for which the filter did
evaluate to the boolean `true`.

As both these cases are very similar, it makes sense to combine them
into a single test.

Co-authored-by: berkaycanbc <berkay.can@camunda.com>
Co-authored-by: Nicola Puppa <nicola.puppa@camunda.com>
Co-authored-by: Remco Westerhoud <remco@westerhoud.nl>
  • Loading branch information
4 people committed Jul 20, 2023
1 parent aed6d96 commit a22cd23
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,12 @@ class InterpreterListExpressionTest
ValNumber(1))
}

it should "fail if the filter doesn't return a boolean or a number" in {
it should "be filtered if the filter doesn't always return a boolean or a number" in {
eval(""" [1,2,3,4]["not a valid filter"] """) should be (
ValError("Expected boolean filter or number but found 'ValString(not a valid filter)'")
ValList(List())
)
}

it should "fail if the filter doesn't return always a boolean" in {
eval("[1,2,3,4][if item < 3 then true else null]") should be (
ValError("expected Boolean but found 'ValNull'")
ValList(List(ValNumber(1), ValNumber(2)))
)
}

Expand Down

0 comments on commit a22cd23

Please sign in to comment.