aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gleam/dynamic_test.gleam20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/gleam/dynamic_test.gleam b/test/gleam/dynamic_test.gleam
index 9d1aeba..0caf8c5 100644
--- a/test/gleam/dynamic_test.gleam
+++ b/test/gleam/dynamic_test.gleam
@@ -838,6 +838,26 @@ pub fn any_test() {
|> should.equal(Error([DecodeError("another type", "String", path: [])]))
}
+type One(a) {
+ One(a)
+}
+
+pub fn decode1_test() {
+ let decoder = dynamic.decode1(One, dynamic.element(0, dynamic.int))
+
+ #(1)
+ |> dynamic.from
+ |> decoder
+ |> should.equal(Ok(One(1)))
+
+ #(1.3)
+ |> dynamic.from
+ |> decoder
+ |> should.equal(Error([
+ DecodeError(expected: "Int", found: "Float", path: ["0"]),
+ ]))
+}
+
type Two(a, b) {
Two(a, b)
}