aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAhmad Sattar <thehabbos007@gmail.com>2020-06-18 18:59:58 +0200
committerLouis Pilfold <louis@lpil.uk>2020-06-18 21:55:49 +0100
commit7198eab42221bd99a0aa82795688aecc27533bc1 (patch)
tree3d68ee963f8fce5c5f0bd69090bd80e6872f9d1e /test
parent4847d930304dc6873d01da3fc290650b21c9a9bc (diff)
downloadgleam_stdlib-7198eab42221bd99a0aa82795688aecc27533bc1.tar.gz
gleam_stdlib-7198eab42221bd99a0aa82795688aecc27533bc1.zip
Option or function
Diffstat (limited to 'test')
-rw-r--r--test/gleam/option_test.gleam22
1 files changed, 20 insertions, 2 deletions
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)
+}