aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2023-04-21 12:07:17 +0100
committerLouis Pilfold <louis@lpil.uk>2023-04-21 12:07:17 +0100
commit13f8dc62e08fb499e600a4bcacfae7a29008dbfa (patch)
treefd89fca7d173901c2f71fcd15496f123f6610946 /test
parent5a72c6977ab5a0bf0a4a78adb404d7f4783c51a8 (diff)
downloadgleam_stdlib-13f8dc62e08fb499e600a4bcacfae7a29008dbfa.tar.gz
gleam_stdlib-13f8dc62e08fb499e600a4bcacfae7a29008dbfa.zip
list.try_each returns the error
Diffstat (limited to 'test')
-rw-r--r--test/gleam/list_test.gleam35
1 files changed, 19 insertions, 16 deletions
diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam
index 07b2bae..e32c1a9 100644
--- a/test/gleam/list_test.gleam
+++ b/test/gleam/list_test.gleam
@@ -864,26 +864,29 @@ pub fn each_test() {
}
pub fn try_each_test() {
- list.try_each(
- over: [1, 1, 1],
- with: fn(x) {
- should.equal(x, 1)
- Ok(Nil)
- },
- )
+ let assert Ok(Nil) =
+ list.try_each(
+ over: [1, 1, 1],
+ with: fn(x) {
+ should.equal(x, 1)
+ Ok(Nil)
+ },
+ )
// `try_each` actually stops when `fun` returns error
- list.try_each(
- over: [1, 2, 3],
- with: fn(x) {
- should.equal(x, 1)
- Error(Nil)
- },
- )
+ let assert Error(1) =
+ list.try_each(
+ over: [1, 2, 3],
+ with: fn(x) {
+ should.equal(x, 1)
+ Error(x)
+ },
+ )
// TCO test
- list.repeat(1, recursion_test_cycles)
- |> list.try_each(with: fn(_) { Ok(Nil) })
+ let assert Ok(Nil) =
+ list.repeat(1, recursion_test_cycles)
+ |> list.try_each(with: fn(_) { Ok(Nil) })
}
pub fn partition_test() {