From 957b0dd730b16270c6d2b783825b629858571879 Mon Sep 17 00:00:00 2001 From: inoas Date: Mon, 27 Jun 2022 22:59:05 +0200 Subject: naming, attempt to add tests that proof short circuit --- test/gleam/list_test.gleam | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test') diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam index 82350a2..7373ef9 100644 --- a/test/gleam/list_test.gleam +++ b/test/gleam/list_test.gleam @@ -308,6 +308,18 @@ pub fn all_test() { list.repeat(True, 16999) |> list.all(fn(item) { item }) |> should.equal(True) + + [1, 2, 3] + |> list.all(fn(x) { + case x { + 1 -> True + 2 -> False + // Crash to ensure we short-circuit + _ -> { + assert True = False + } + } + }) } pub fn any_test() { @@ -327,6 +339,18 @@ pub fn any_test() { list.repeat(False, 16999) |> list.any(fn(item) { item }) |> should.equal(False) + + [1, 2, 3] + |> list.any(fn(x) { + case x { + 1 -> False + 2 -> True + // Crash to ensure we short-circuit + _ -> { + assert True = False + } + } + }) } pub fn zip_test() { -- cgit v1.2.3