aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarcin Puc <5671049+tranzystorek-io@users.noreply.github.com>2021-03-10 10:49:59 +0100
committerGitHub <noreply@github.com>2021-03-10 09:49:59 +0000
commit134708f2082dbf66a1dd1398483d00acb25c2e18 (patch)
tree823dbad5798c54ab671428376c848b73700088fd /test
parent1643c557b5e7e5fcbaf70a689a9b9d8f74e3ee83 (diff)
downloadgleam_stdlib-134708f2082dbf66a1dd1398483d00acb25c2e18.tar.gz
gleam_stdlib-134708f2082dbf66a1dd1398483d00acb25c2e18.zip
Add iterator.{take_while, drop_while} (#174)
Diffstat (limited to 'test')
-rw-r--r--test/gleam/iterator_test.gleam14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/gleam/iterator_test.gleam b/test/gleam/iterator_test.gleam
index f1ee880..b2ca8ac 100644
--- a/test/gleam/iterator_test.gleam
+++ b/test/gleam/iterator_test.gleam
@@ -265,6 +265,20 @@ pub fn iterate_test() {
|> should.equal([1, 3, 9, 27, 81])
}
+pub fn take_while_test() {
+ iterator.from_list([1, 2, 3, 2, 4])
+ |> iterator.take_while(satisfying: fn(x) { x < 3 })
+ |> iterator.to_list
+ |> should.equal([1, 2])
+}
+
+pub fn drop_while_test() {
+ iterator.from_list([1, 2, 3, 4, 2, 5])
+ |> iterator.drop_while(satisfying: fn(x) { x < 4 })
+ |> iterator.to_list
+ |> should.equal([4, 2, 5])
+}
+
pub fn scan_test() {
iterator.from_list([1, 2, 3, 4, 5])
|> iterator.scan(from: 0, with: fn(el, acc) { acc + el })