aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSebastian Porto <s@porto5.com>2021-01-20 03:16:49 +1100
committerGitHub <noreply@github.com>2021-01-19 16:16:49 +0000
commit637e1f46bddbee4a4bb8a85e5c61e54d9197a57d (patch)
treeb0cbfd94b27bf2843bdd234813b4b85091332605 /test
parent400cd752db3e04dcad8bf2a199a4d136ed85cedc (diff)
downloadgleam_stdlib-637e1f46bddbee4a4bb8a85e5c61e54d9197a57d.tar.gz
gleam_stdlib-637e1f46bddbee4a4bb8a85e5c61e54d9197a57d.zip
Add list.window and list.window_by_2 (#156)
Diffstat (limited to 'test')
-rw-r--r--test/gleam/list_test.gleam28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam
index 3bd463a..2aa1b3e 100644
--- a/test/gleam/list_test.gleam
+++ b/test/gleam/list_test.gleam
@@ -536,3 +536,31 @@ pub fn permutations_test() {
|> list.permutations
|> should.equal([["a", "b"], ["b", "a"]])
}
+
+pub fn window_test() {
+ [1, 2, 3]
+ |> list.window(by: 2)
+ |> should.equal([[1, 2], [2, 3]])
+
+ [1, 2, 3]
+ |> list.window(3)
+ |> should.equal([[1, 2, 3]])
+
+ [1, 2, 3]
+ |> list.window(4)
+ |> should.equal([])
+
+ [1, 2, 3, 4, 5]
+ |> list.window(3)
+ |> should.equal([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
+}
+
+pub fn window_by_2_test() {
+ [1, 2, 3, 4]
+ |> list.window_by_2
+ |> should.equal([tuple(1, 2), tuple(2, 3), tuple(3, 4)])
+
+ [1]
+ |> list.window_by_2
+ |> should.equal([])
+}