diff options
author | Giacomo Cavalieri <giacomo.cavalieri@icloud.com> | 2023-08-26 13:50:42 +0200 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2023-09-04 12:50:50 +0100 |
commit | bb7798efd8b75c8770d3b17d0bd4683c2abd0ea0 (patch) | |
tree | 8556b63f6e96d3862e0388ff078b4487b69057c8 /test | |
parent | 5832ccd7189549dbb4ae4fb6b6cd249883446454 (diff) | |
download | gleam_stdlib-bb7798efd8b75c8770d3b17d0bd4683c2abd0ea0.tar.gz gleam_stdlib-bb7798efd8b75c8770d3b17d0bd4683c2abd0ea0.zip |
Change `iterator.flatten`'s type
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/iterator_test.gleam | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/gleam/iterator_test.gleam b/test/gleam/iterator_test.gleam index 8b7e01d..5d10cb2 100644 --- a/test/gleam/iterator_test.gleam +++ b/test/gleam/iterator_test.gleam @@ -193,7 +193,7 @@ pub fn append_test() { test([1, 2], [3, 4]) } -// a |> list.map(from_list) |> concat |> to_list == list.concat(a) +// a |> list.map(from_list) |> from_list |> concat |> to_list == list.concat(a) pub fn concat_test() { let test = fn(lists) { lists @@ -209,6 +209,21 @@ pub fn concat_test() { test([[1, 2], [3, 4]]) } +// a |> list.map(from_list) |> flatten |> to_list == list.concat(a) +pub fn flatten_test() { + let test = fn(lists) { + lists + |> list.map(iterator.from_list) + |> iterator.flatten + |> iterator.to_list + |> should.equal(list.concat(lists)) + } + + test([[], []]) + test([[1], [2]]) + test([[1, 2], [3, 4]]) +} + // a |> from_list |> filter(f) |> to_list == a |> list.filter(_, f) pub fn filter_test() { let test = fn(subject, f) { |