Skip to content

Commit 5233387

Browse files
committed
Add TH error messages test
1 parent 4d12557 commit 5233387

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

tests/ErrorMessages.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ tests :: [TestTree]
3131
tests =
3232
[ aesonGoldenTest "simple" "tests/golden/simple.expected" output
3333
, aesonGoldenTest "generic" "tests/golden/generic.expected" (outputGeneric G)
34+
, aesonGoldenTest "generic" "tests/golden/th.expected" (outputGeneric TH)
3435
]
3536

3637
output :: Output

tests/golden/th.expected

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
OneConstructor
2+
Error in $: When parsing the constructor OneConstructor of type Types.OneConstructor expected Array but got String.
3+
Error in $: When parsing the constructor OneConstructor of type Types.OneConstructor expected an empty Array but got Array of length 1.
4+
Nullary
5+
Error in $: When parsing Types.Nullary expected a String with the tag of a constructor but got X.
6+
Error in $: When parsing Types.Nullary expected String but got Array.
7+
SomeType (tagged)
8+
Error in $: parsing Int failed, expected Number, but encountered Boolean
9+
Error in $: key "contents" not found
10+
Error in $: When parsing the record record of type Types.SomeType the key testone was not present.
11+
Error in $.testone: parsing Double failed, unexpected Boolean
12+
Error in $: When parsing Types.SomeType expected an Object with a tag field where the value is one of [nullary, unary, product, record, list], but got X.
13+
Error in $: key "tag" not found
14+
Error in $: When parsing Types.SomeType expected Object but got Array.
15+
SomeType (single-field)
16+
Error in $: parsing Int failed, expected Number, but encountered Object
17+
Error in $: parsing Int failed, expected Number, but encountered Array
18+
Error in $: When parsing Types.SomeType expected an Object with a single tag/contents pair where the tag is one of [nullary, unary, product, record, list], but got X.
19+
Error in $: When parsing Types.SomeType expected an Object with a single tag/contents pair but got 2 pairs.
20+
Error in $: When parsing Types.SomeType expected an Object with a single tag/contents pair but got 0 pairs.
21+
Error in $: When parsing Types.SomeType expected Object but got Array.
22+
Error in $: not enough input. Expecting ':'
23+
Error in $: not enough input. Expecting object value
24+
Error in $: not enough input. Expecting ',' or '}'
25+
SomeType (two-element array)
26+
Error in $: parsing Int failed, expected Number, but encountered Boolean
27+
Error in $: When parsing the constructor Record of type Types.SomeType expected Object but got Null.
28+
Error in $: When parsing Types.SomeType expected a 2-element Array with a tag and contents element where the tag is one of [nullary, unary, product, record, list], but got X.
29+
Error in $: When parsing Types.SomeType expected an Array of 2 elements where the first element is a String but got Null at the first element.
30+
Error in $: When parsing Types.SomeType expected an Array of 2 elements but got 0 elements
31+
Error in $: When parsing Types.SomeType expected Array but got Object.
32+
Error in $: not enough input. Expecting ',' or ']'
33+
Error in $: not enough input. Expecting json list value
34+
SomeType (reject unknown fields)
35+
Error in $: Unknown fields: ["testZero"]
36+
Error in $: key "tag" not found
37+
Error in $: Unknown fields: ["testtwo","testone","testthree"]
38+
Foo (reject unknown fields)
39+
Error in $: Unknown fields: ["tag"]
40+
Foo (reject unknown fields, tagged single)
41+
Error in $: Unknown fields: ["unknownField"]
42+
EitherTextInt
43+
Error in $: When parsing the constructor NoneNullary of type Types.EitherTextInt expected String but got String.
44+
Error in $: When parsing the constructor NoneNullary of type Types.EitherTextInt expected String but got Array.
45+
Product2 Int Bool
46+
Error in $: expected Bool, but encountered Null
47+
Error in $: When parsing the constructor Product2 of type Types.Product2 expected Array of length 2 but got Array of length 0.
48+
Error in $: When parsing the constructor Product2 of type Types.Product2 expected Array but got Object.

0 commit comments

Comments
 (0)