aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/gleam_json_test.gleam20
1 files changed, 14 insertions, 6 deletions
diff --git a/test/gleam_json_test.gleam b/test/gleam_json_test.gleam
index 6460e51..95af8c0 100644
--- a/test/gleam_json_test.gleam
+++ b/test/gleam_json_test.gleam
@@ -27,9 +27,7 @@ pub fn decode_unexpected_byte_test() {
pub fn decode_unexpected_format_test() {
json.decode(from: "[]", using: dynamic.int)
- |> should.equal(Error(json.UnexpectedFormat([
- dynamic.DecodeError(expected: "Int", found: "List", path: []),
- ])))
+ |> should.equal(Error(json.UnexpectedFormat([empty_list_decode_error()])))
}
pub fn decode_bits_test() {
@@ -49,9 +47,7 @@ pub fn decode_bits_unexpected_byte_test() {
pub fn decode_bits_unexpected_format_test() {
json.decode_bits(from: <<"[]":utf8>>, using: dynamic.int)
- |> should.equal(Error(json.UnexpectedFormat([
- dynamic.DecodeError(expected: "Int", found: "List", path: []),
- ])))
+ |> should.equal(Error(json.UnexpectedFormat([empty_list_decode_error()])))
}
pub fn encode_string_test() {
@@ -126,3 +122,15 @@ fn should_encode(data: Json, expected: String) {
|> string_builder.to_string
|> should.equal(json.to_string(data))
}
+
+if erlang {
+ fn empty_list_decode_error() -> dynamic.DecodeError {
+ dynamic.DecodeError(expected: "Int", found: "List", path: [])
+ }
+}
+
+if javascript {
+ fn empty_list_decode_error() {
+ dynamic.DecodeError(expected: "Int", found: "Tuple of 0 elements", path: [])
+ }
+}