aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarcin Puc <marcin.e.puc@gmail.com>2021-03-14 09:39:40 +0100
committerLouis Pilfold <louis@lpil.uk>2021-03-14 15:39:49 +0000
commit875c3b785fc6936c365d41eb6d05f1be8db9de37 (patch)
tree9611a3f721064de378aa955701a78e4ebd9face1 /test
parent57327135fb9a625db60c26f3c7789a386072c610 (diff)
downloadgleam_stdlib-875c3b785fc6936c365d41eb6d05f1be8db9de37.tar.gz
gleam_stdlib-875c3b785fc6936c365d41eb6d05f1be8db9de37.zip
Make iterator.take return an iterator instead of a list
Diffstat (limited to 'test')
-rw-r--r--test/gleam/iterator_test.gleam6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/gleam/iterator_test.gleam b/test/gleam/iterator_test.gleam
index b2ca8ac..9250f9c 100644
--- a/test/gleam/iterator_test.gleam
+++ b/test/gleam/iterator_test.gleam
@@ -47,6 +47,7 @@ pub fn take_test() {
subject
|> iterator.from_list
|> iterator.take(n)
+ |> iterator.to_list
|> should.equal(list.take(subject, n))
}
@@ -173,6 +174,7 @@ pub fn repeat_test() {
1
|> iterator.repeat
|> iterator.take(5)
+ |> iterator.to_list
|> should.equal([1, 1, 1, 1, 1])
}
@@ -181,16 +183,19 @@ pub fn cycle_test() {
|> iterator.from_list
|> iterator.cycle
|> iterator.take(9)
+ |> iterator.to_list
|> should.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)
+ |> iterator.to_list
|> should.equal([2, 4, 8, 16, 32])
iterator.unfold(2, fn(_) { iterator.Done })
|> iterator.take(5)
+ |> iterator.to_list
|> should.equal([])
fn(n) {
@@ -262,6 +267,7 @@ pub fn iterate_test() {
fn(x) { x * 3 }
|> iterator.iterate(from: 1)
|> iterator.take(5)
+ |> iterator.to_list
|> should.equal([1, 3, 9, 27, 81])
}