From f7d6fe3105fbf650f0f0f95568aca801048f6d15 Mon Sep 17 00:00:00 2001 From: Alice Dee Date: Sat, 11 May 2019 17:16:06 +0100 Subject: Adds split to list stdlib --- test/list_test.gleam | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test') diff --git a/test/list_test.gleam b/test/list_test.gleam index fb32387..2311365 100644 --- a/test/list_test.gleam +++ b/test/list_test.gleam @@ -312,3 +312,23 @@ pub fn repeat_test() { list:repeat("x", 5) |> expect:equal(_, ["x", "x", "x", "x", "x"]) } + +pub fn split_test() { + list:split([], 0) + |> expect:equal(_, {[], []}) + + list:split([0, 1, 2, 3, 4], 0) + |> expect:equal(_, {[], [0, 1, 2, 3, 4]}) + + list:split([0, 1, 2, 3, 4], -2) + |> expect:equal(_, {[], [0, 1, 2, 3, 4]}) + + list:split([0, 1, 2, 3, 4], 1) + |> expect:equal(_, {[0], [1, 2, 3, 4]}) + + list:split([0, 1, 2, 3, 4], 3) + |> expect:equal(_, {[0, 1, 2], [3, 4]}) + + list:split([0, 1, 2, 3, 4], 9) + |> expect:equal(_, {[0, 1, 2, 3, 4], []}) +} -- cgit v1.2.3