aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRobert Peterson <robert.peterson@gmail.com>2019-04-18 07:41:38 -0700
committerLouis Pilfold <louis@lpil.uk>2019-04-18 16:16:05 +0100
commit108d01c3efda55d63193f33e29fb878b07313dfc (patch)
tree82750c1490569b6c986803697dd2b9f72d6e3c80 /test
parentf2b09ca44f9448cf351093abdf50f9bb6e411423 (diff)
downloadgleam_stdlib-108d01c3efda55d63193f33e29fb878b07313dfc.tar.gz
gleam_stdlib-108d01c3efda55d63193f33e29fb878b07313dfc.zip
Add list:index_map
Diffstat (limited to 'test')
-rw-r--r--test/list_test.gleam12
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"])
+}