diff options
author | Ahmad Sattar <thehabbos007@gmail.com> | 2020-06-17 22:35:27 +0200 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2020-06-18 21:54:48 +0100 |
commit | 56228f9a5ecfef7fb968d08894a7cc4ce0dfdbae (patch) | |
tree | 05800084aed8672ef0f689af1e2e330d59c856e1 /test | |
parent | a13164e370b17699797f616b9c8fd54a135ad490 (diff) | |
download | gleam_stdlib-56228f9a5ecfef7fb968d08894a7cc4ce0dfdbae.tar.gz gleam_stdlib-56228f9a5ecfef7fb968d08894a7cc4ce0dfdbae.zip |
Option then function
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/option_test.gleam | 14 |
1 files changed, 14 insertions, 0 deletions
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) +} |