aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarcin Puc <tranzystorek.io@protonmail.com>2022-12-19 18:03:44 +0100
committerLouis Pilfold <louis@lpil.uk>2022-12-22 20:18:07 +0000
commit0ece235f60b612bcb3c4b20bc7eaf44d6cf01cd1 (patch)
tree74e59b30d8e35b18ecaf9e10758830e16d9b253d /test
parent0053dbc726174937bfaf342bad013bd90e6a8e5c (diff)
downloadgleam_stdlib-0ece235f60b612bcb3c4b20bc7eaf44d6cf01cd1.tar.gz
gleam_stdlib-0ece235f60b612bcb3c4b20bc7eaf44d6cf01cd1.zip
add test for iterator.transform
Diffstat (limited to 'test')
-rw-r--r--test/gleam/iterator_test.gleam8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/gleam/iterator_test.gleam b/test/gleam/iterator_test.gleam
index 976e209..e31b628 100644
--- a/test/gleam/iterator_test.gleam
+++ b/test/gleam/iterator_test.gleam
@@ -69,6 +69,14 @@ pub fn take_test() {
test(22, [0, 1, 2, 3, 4])
}
+pub fn transform_test() {
+ ["a", "b", "c", "d"]
+ |> iterator.from_list
+ |> iterator.transform(0, fn(i, el) { Next(#(i, el), i + 1) })
+ |> iterator.to_list
+ |> should.equal([#(0, "a"), #(1, "b"), #(2, "c"), #(3, "d")])
+}
+
// a |> from_list |> fold(a, f) == a |> list.fold(_, a, f)
pub fn fold_test() {
let test = fn(subject, acc, f) {