Skip to content

Commit fd29544

Browse files
committed
Update accepted/rejected i_ and tranform JSONTestSuite tests
1 parent 6bddcc3 commit fd29544

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

tests/JSONTestSuite.hs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ jsonTestSuiteTest path = testCase fileName $ do
1818
payload <- L.readFile path
1919
let result = eitherDecode payload :: Either String Value
2020
assertBool (show result) $ case take 2 fileName of
21-
"i_" -> isRight result
22-
"n_" -> isLeft result
23-
"y_" -> isRight result
24-
_ -> isRight result -- test_transform tests have inconsistent names
21+
"n_" -> isLeft result
22+
"y_" -> isRight result
23+
"i_" | fileName `HashSet.member` ignore_accepted -> isRight result
24+
| otherwise -> isLeft result
25+
_ | fileName `HashSet.member` transform_rejected -> isLeft result
26+
| otherwise -> isRight result -- test_transform tests have inconsistent names
2527
where
2628
fileName = takeFileName path
2729

@@ -35,46 +37,44 @@ tests = do
3537
testPaths <- fmap (sort . concat) . forM suites $ \suite -> do
3638
let dir = suitePath </> suite
3739
entries <- getDirectoryContents dir
38-
let ok name = takeExtension name == ".json" &&
39-
not (name `HashSet.member` blacklist)
40+
let ok name = takeExtension name == ".json"
4041
return . map (dir </>) . filter ok $ entries
4142
return $ testGroup "JSONTestSuite" $ map jsonTestSuiteTest testPaths
4243

4344
-- The set expected-to-be-failing JSONTestSuite tests.
4445
-- Not all of these failures are genuine bugs.
4546
-- Of those that are bugs, not all are worth fixing.
4647

47-
blacklist :: HashSet.HashSet String
48-
-- blacklist = HashSet.empty
49-
blacklist = _blacklist
48+
-- | The @i@ cases we can ignore. We don't.
49+
--
50+
-- @i_@ - parsers are free to accept or reject content
51+
--
52+
-- We specify which @i_@ case we accept, so we can catch changes even in unspecified behavior.
53+
-- (There is less case we accept)
54+
ignore_accepted :: HashSet.HashSet FilePath
55+
ignore_accepted = HashSet.fromList
56+
[ "i_number_double_huge_neg_exp.json"
57+
, "i_number_huge_exp.json"
58+
, "i_number_neg_int_huge_exp.json"
59+
, "i_number_pos_double_huge_exp.json"
60+
, "i_number_real_neg_overflow.json"
61+
, "i_number_real_pos_overflow.json"
62+
, "i_number_real_underflow.json"
63+
, "i_number_too_big_neg_int.json"
64+
, "i_number_too_big_pos_int.json"
65+
, "i_number_very_big_negative_int.json"
66+
, "i_structure_500_nested_arrays.json"
67+
]
5068

51-
_blacklist :: HashSet.HashSet String
52-
_blacklist = HashSet.fromList
53-
[ "i_string_UTF8_surrogate_U+D800.json"
54-
, "i_object_key_lone_2nd_surrogate.json"
55-
, "i_string_1st_surrogate_but_2nd_missing.json"
56-
, "i_string_1st_valid_surrogate_2nd_invalid.json"
57-
, "i_string_UTF-16LE_with_BOM.json"
58-
, "i_string_UTF-16_invalid_lonely_surrogate.json"
59-
, "i_string_UTF-16_invalid_surrogate.json"
60-
, "i_string_UTF-8_invalid_sequence.json"
61-
, "i_string_incomplete_surrogate_and_escape_valid.json"
62-
, "i_string_incomplete_surrogate_pair.json"
63-
, "i_string_incomplete_surrogates_escape_valid.json"
64-
, "i_string_invalid_lonely_surrogate.json"
65-
, "i_string_invalid_surrogate.json"
66-
, "i_string_inverted_surrogates_U+1D11E.json"
67-
, "i_string_lone_second_surrogate.json"
68-
, "i_string_not_in_unicode_range.json"
69-
, "i_string_truncated-utf-8.json"
70-
, "i_structure_UTF-8_BOM_empty_object.json"
71-
, "string_1_escaped_invalid_codepoint.json"
72-
, "string_1_invalid_codepoint.json"
73-
, "string_1_invalid_codepoints.json"
74-
, "string_2_escaped_invalid_codepoints.json"
75-
, "string_2_invalid_codepoints.json"
76-
, "string_3_escaped_invalid_codepoints.json"
77-
, "string_3_invalid_codepoints.json"
78-
, "y_string_utf16BE_no_BOM.json"
79-
, "y_string_utf16LE_no_BOM.json"
80-
]
69+
-- | Transform folder contain weird structures and characters that parsers may understand differently.
70+
--
71+
-- We don't even try to understand some.
72+
transform_rejected :: HashSet.HashSet FilePath
73+
transform_rejected = HashSet.fromList
74+
[ "string_1_escaped_invalid_codepoint.json"
75+
, "string_1_invalid_codepoint.json"
76+
, "string_2_escaped_invalid_codepoints.json"
77+
, "string_2_invalid_codepoints.json"
78+
, "string_3_escaped_invalid_codepoints.json"
79+
, "string_3_invalid_codepoints.json"
80+
]

0 commit comments

Comments
 (0)