@@ -21,9 +21,7 @@ func (r Test) CompareJSON(want, have any) Test {
21
21
case []any :
22
22
return r .cmpJSONArrays (w , have )
23
23
default :
24
- return r .fail (
25
- "Key '%s' in expected output should be a map or a list of maps, but it's a %s" ,
26
- r .Key , fmtType (want ))
24
+ return r .fail ("Key '%s' in expected output should be a map or a list of maps, but it's a %s" , r .Key , fmtType (want ))
27
25
}
28
26
}
29
27
@@ -35,14 +33,10 @@ func (r Test) cmpJSONMaps(want map[string]any, have any) Test {
35
33
36
34
// Check to make sure both or neither are values.
37
35
if isValue (want ) && ! isValue (haveMap ) {
38
- return r .fail (
39
- "Key '%s' is supposed to be a value, but the parser reports it as a table" ,
40
- r .Key )
36
+ return r .fail ("Key '%s' is supposed to be a value, but the parser reports it as a table" , r .Key )
41
37
}
42
38
if ! isValue (want ) && isValue (haveMap ) {
43
- return r .fail (
44
- "Key '%s' is supposed to be a table, but the parser reports it as a value" ,
45
- r .Key )
39
+ return r .fail ("Key '%s' is supposed to be a table, but the parser reports it as a value" , r .Key )
46
40
}
47
41
if isValue (want ) && isValue (haveMap ) {
48
42
return r .cmpJSONValues (want , haveMap )
@@ -52,15 +46,13 @@ func (r Test) cmpJSONMaps(want map[string]any, have any) Test {
52
46
for k := range want {
53
47
if _ , ok := haveMap [k ]; ! ok {
54
48
bunk := r .kjoin (k )
55
- return bunk .fail ("Could not find key '%s' in parser output." ,
56
- bunk .Key )
49
+ return bunk .fail ("Could not find key '%s' in parser output." , bunk .Key )
57
50
}
58
51
}
59
52
for k := range haveMap {
60
53
if _ , ok := want [k ]; ! ok {
61
54
bunk := r .kjoin (k )
62
- return bunk .fail ("Could not find key '%s' in expected output." ,
63
- bunk .Key )
55
+ return bunk .fail ("Could not find key '%s' in expected output." , bunk .Key )
64
56
}
65
57
}
66
58
@@ -241,10 +233,10 @@ func isValue(m map[string]any) bool {
241
233
}
242
234
243
235
func (r Test ) mismatch (wantType string , want , have any ) Test {
244
- return r .fail ("Key %[1]q is not %[2]q but %[5]q :\n " +
236
+ return r .fail ("Key %[1]q (type %[2]q) :\n " +
245
237
" Expected: %s\n " +
246
238
" Your encoder: %s" ,
247
- r .Key , wantType , fmtHashV (want ), fmtHashV ( have ), fmtType (have ))
239
+ r .Key , wantType , fmtHashV (have ), fmtType (have ))
248
240
}
249
241
250
242
func (r Test ) valMismatch (wantType , haveType string , want , have any ) Test {
0 commit comments