From 13f8dc62e08fb499e600a4bcacfae7a29008dbfa Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Fri, 21 Apr 2023 12:07:17 +0100 Subject: list.try_each returns the error --- test/gleam/list_test.gleam | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'test') 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() { -- cgit v1.2.3