diff options
author | Brett Snyder <bsnyder@digitalocean.com> | 2019-05-11 14:08:45 -0500 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2019-05-11 20:16:06 +0100 |
commit | ae854f69b8f40609c0ee6fb1aec8957bd3eac1c2 (patch) | |
tree | 24ae4e63429c1e45ffa549254a813ef87016aa1c /test | |
parent | f7d6fe3105fbf650f0f0f95568aca801048f6d15 (diff) | |
download | gleam_stdlib-ae854f69b8f40609c0ee6fb1aec8957bd3eac1c2.tar.gz gleam_stdlib-ae854f69b8f40609c0ee6fb1aec8957bd3eac1c2.zip |
list:split_while
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]}) +} |