diff options
Diffstat (limited to 'test/list_test.gleam')
-rw-r--r-- | test/list_test.gleam | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/list_test.gleam b/test/list_test.gleam index f9882c0..9c510c4 100644 --- a/test/list_test.gleam +++ b/test/list_test.gleam @@ -1,5 +1,6 @@ import expect import list +import str pub fn length_test() { list:length([]) |> expect:equal(_, 0) @@ -248,3 +249,14 @@ pub fn sort_test() { list:sort([{1,2}, {4,5}, {3,2}]) |> expect:equal(_, [{1,2}, {3,2}, {4,5}]) } + +pub fn index_map_test() { + list:index_map([3,4,5], fn(i, x) { {i, x} }) + |> expect:equal(_, [{0,3},{1,4},{2,5}]) + + let f = fn(i, x) { + str:append(x, str:from_int(i)) + } + list:index_map(["a","b","c"], f) + |> expect:equal(_, ["a0", "b1", "c2"]) +} |