diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/list_test.gleam | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/list_test.gleam b/test/list_test.gleam index 2311365..32484da 100644 --- a/test/list_test.gleam +++ b/test/list_test.gleam @@ -332,3 +332,20 @@ pub fn split_test() { list:split([0, 1, 2, 3, 4], 9) |> expect:equal(_, {[0, 1, 2, 3, 4], []}) } + +pub fn split_while_test() { + list:split_while([], fn(x) { x <= 5 }) + |> expect:equal(_, {[], []}) + + list:split_while([1, 2, 3, 4, 5], fn(x) { x <= 5 }) + |> expect:equal(_, {[1, 2, 3, 4, 5], []}) + + list:split_while([1, 2, 3, 4, 5], fn(x) { x == 2 }) + |> expect:equal(_, {[], [1, 2, 3, 4, 5]}) + + list:split_while([1, 2, 3, 4, 5], fn(x) { x <= 3 }) + |> expect:equal(_, {[1, 2, 3], [4, 5]}) + + list:split_while([1, 2, 3, 4, 5], fn(x) { x <= -3 }) + |> expect:equal(_, {[], [1, 2, 3, 4, 5]}) +} |