From ae854f69b8f40609c0ee6fb1aec8957bd3eac1c2 Mon Sep 17 00:00:00 2001 From: Brett Snyder Date: Sat, 11 May 2019 14:08:45 -0500 Subject: list:split_while --- test/list_test.gleam | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test') 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]}) +} -- cgit v1.2.3