aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSebastian <s@porto5.com>2021-01-20 11:57:25 +1100
committerLouis Pilfold <louis@lpil.uk>2021-01-21 15:16:56 +0000
commit6ad66f973f4a26d67983fae645b79585d4e12c47 (patch)
treef4eb1a571a6724bd1188a50e5f23fab34b16038d /test
parent637e1f46bddbee4a4bb8a85e5c61e54d9197a57d (diff)
downloadgleam_stdlib-6ad66f973f4a26d67983fae645b79585d4e12c47.tar.gz
gleam_stdlib-6ad66f973f4a26d67983fae645b79585d4e12c47.zip
Add list.fold_until
Diffstat (limited to 'test')
-rw-r--r--test/gleam/list_test.gleam14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam
index 2aa1b3e..3277e47 100644
--- a/test/gleam/list_test.gleam
+++ b/test/gleam/list_test.gleam
@@ -177,6 +177,20 @@ pub fn index_fold_test() {
|> should.equal([tuple(2, "c"), tuple(1, "b"), tuple(0, "a")])
}
+pub fn fold_until_test() {
+ [1, 2, 3, 4]
+ |> list.fold_until(
+ from: 0,
+ with: fn(n, acc) {
+ case n < 4 {
+ True -> list.Continue(acc + n)
+ False -> list.Stop(acc)
+ }
+ },
+ )
+ |> should.equal(6)
+}
+
pub fn try_fold_test() {
[1, 2, 3]
|> list.try_fold(