From 56228f9a5ecfef7fb968d08894a7cc4ce0dfdbae Mon Sep 17 00:00:00 2001 From: Ahmad Sattar Date: Wed, 17 Jun 2020 22:35:27 +0200 Subject: Option then function --- test/gleam/option_test.gleam | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/gleam/option_test.gleam b/test/gleam/option_test.gleam index 03f4186..7271769 100644 --- a/test/gleam/option_test.gleam +++ b/test/gleam/option_test.gleam @@ -68,3 +68,17 @@ pub fn flatten_option_test() { |> option.flatten() |> should.equal(None) } + +pub fn then_option_test() { + Some(1) + |> option.then(fn(x) { Some(x + 1) }) + |> should.equal(Some(2)) + + Some(1) + |> option.then(fn(x) { Some("2") }) + |> should.equal(Some("2")) + + None + |> option.then(fn(x) { Some(x + 1) }) + |> should.equal(None) +} -- cgit v1.2.3