From 7198eab42221bd99a0aa82795688aecc27533bc1 Mon Sep 17 00:00:00 2001 From: Ahmad Sattar Date: Thu, 18 Jun 2020 18:59:58 +0200 Subject: Option or function --- test/gleam/option_test.gleam | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/gleam/option_test.gleam b/test/gleam/option_test.gleam index 7271769..0db3adf 100644 --- a/test/gleam/option_test.gleam +++ b/test/gleam/option_test.gleam @@ -47,7 +47,7 @@ pub fn map_option_test() { |> should.equal(Some(2)) Some(1) - |> option.map(fn(x) { "2" }) + |> option.map(fn(_) { "2" }) |> should.equal(Some("2")) None @@ -75,10 +75,28 @@ pub fn then_option_test() { |> should.equal(Some(2)) Some(1) - |> option.then(fn(x) { Some("2") }) + |> option.then(fn(_) { Some("2") }) |> should.equal(Some("2")) None |> option.then(fn(x) { Some(x + 1) }) |> should.equal(None) } + +pub fn or_option_test() { + Some(1) + |> option.or(Some(2)) + |> should.equal(Some(1)) + + Some(1) + |> option.or(None) + |> should.equal(Some(1)) + + None + |> option.or(Some(2)) + |> should.equal(Some(2)) + + None + |> option.or(None) + |> should.equal(None) +} -- cgit v1.2.3