aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsharno <sharnoby3@gmail.com>2020-10-26 22:01:48 -0400
committerLouis Pilfold <louis@lpil.uk>2020-10-27 15:14:56 +0100
commitcbdd74a5e78a85be8d4d49a93b87e501e5b0aef5 (patch)
tree1837f4b1763ec8b712832ac13db5297b1d655e2b /test
parent5239830bc8bf6d8c1df566e7bfe995ff24d8514a (diff)
downloadgleam_stdlib-cbdd74a5e78a85be8d4d49a93b87e501e5b0aef5.tar.gz
gleam_stdlib-cbdd74a5e78a85be8d4d49a93b87e501e5b0aef5.zip
Closes #115: Add dynamic.option
Diffstat (limited to 'test')
-rw-r--r--test/gleam/dynamic_test.gleam18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/gleam/dynamic_test.gleam b/test/gleam/dynamic_test.gleam
index 2b272d4..f4e78a0 100644
--- a/test/gleam/dynamic_test.gleam
+++ b/test/gleam/dynamic_test.gleam
@@ -5,6 +5,7 @@ import gleam/list
import gleam/should
import gleam/result
import gleam/map
+import gleam/option.{None, Some}
pub fn bit_string_test() {
""
@@ -220,6 +221,23 @@ pub fn typed_list_test() {
|> should.be_error
}
+pub fn option_test() {
+ let Ok(null) = atom.from_string("null")
+
+ 1
+ |> dynamic.from
+ |> dynamic.option(dynamic.int)
+ |> should.equal(Ok(Some(1)))
+ null
+ |> dynamic.from
+ |> dynamic.option(dynamic.int)
+ |> should.equal(Ok(None))
+ 1
+ |> dynamic.from
+ |> dynamic.option(dynamic.string)
+ |> should.be_error
+}
+
pub fn field_test() {
let Ok(ok_atom) = atom.from_string("ok")
let Ok(error_atom) = atom.from_string("error")