aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBrett Snyder <bsnyder@digitalocean.com>2019-05-11 14:08:45 -0500
committerLouis Pilfold <louis@lpil.uk>2019-05-11 20:16:06 +0100
commitae854f69b8f40609c0ee6fb1aec8957bd3eac1c2 (patch)
tree24ae4e63429c1e45ffa549254a813ef87016aa1c /test
parentf7d6fe3105fbf650f0f0f95568aca801048f6d15 (diff)
downloadgleam_stdlib-ae854f69b8f40609c0ee6fb1aec8957bd3eac1c2.tar.gz
gleam_stdlib-ae854f69b8f40609c0ee6fb1aec8957bd3eac1c2.zip
list:split_while
Diffstat (limited to 'test')
-rw-r--r--test/list_test.gleam17
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]})
+}