aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gleam/iterator_test.gleam10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/gleam/iterator_test.gleam b/test/gleam/iterator_test.gleam
index 447e912..fe0a854 100644
--- a/test/gleam/iterator_test.gleam
+++ b/test/gleam/iterator_test.gleam
@@ -107,3 +107,13 @@ pub fn cycle_test() {
|> iterator.take(_, 9)
|> expect.equal(_, [1, 2, 3, 1, 2, 3, 1, 2, 3])
}
+
+pub fn unfold_test() {
+ iterator.unfold(2, fn(acc) { iterator.Next(acc, acc * 2) })
+ |> iterator.take(_, 5)
+ |> expect.equal(_, [2, 4, 8, 16, 32])
+
+ iterator.unfold(2, fn(_) { iterator.Done })
+ |> iterator.take(_, 5)
+ |> expect.equal(_, [])
+}