diff options
author | Louis Pilfold <louis@lpil.uk> | 2019-12-12 12:06:28 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2020-05-26 19:19:29 +0100 |
commit | 3bbd4a1bf2d66d75a5547dcc15049174857850f6 (patch) | |
tree | 0cd9fdd897d10a692e87a5a373a453c2c6f5c155 /test | |
parent | 20904ceb0f19d4d3fb6d8cf9a5a324c0938dc3fb (diff) | |
download | gleam_stdlib-3bbd4a1bf2d66d75a5547dcc15049174857850f6.tar.gz gleam_stdlib-3bbd4a1bf2d66d75a5547dcc15049174857850f6.zip |
unfold test
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/iterator_test.gleam | 10 |
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(_, []) +} |