@@ -49,10 +49,9 @@ import qualified Data.Aeson.Types
49
49
import qualified Data.Aeson.KeyMap as KM
50
50
import Data.Attoparsec.ByteString (Parser , parseOnly )
51
51
import Data.Char (toUpper , GeneralCategory (Control ,Surrogate ), generalCategory )
52
- import Data.Either.Compat (isLeft , isRight )
53
52
import Data.Hashable (hash )
54
53
import Data.HashMap.Strict (HashMap )
55
- import Data.List (sort , isSuffixOf )
54
+ import Data.List (isSuffixOf )
56
55
import Data.Maybe (fromMaybe )
57
56
import Data.Scientific (Scientific , scientific )
58
57
import Data.Tagged (Tagged (.. ))
@@ -63,16 +62,13 @@ import GHC.Generics (Generic)
63
62
import GHC.Generics.Generically (Generically (.. ))
64
63
import Instances ()
65
64
import Numeric.Natural (Natural )
66
- import System.Directory (getDirectoryContents )
67
- import System.FilePath ((</>) , takeExtension , takeFileName )
68
65
import Test.Tasty (TestTree , testGroup )
69
- import Test.Tasty.HUnit (Assertion , assertBool , assertFailure , assertEqual , testCase , (@?=) )
66
+ import Test.Tasty.HUnit (Assertion , assertFailure , assertEqual , testCase , (@?=) )
70
67
import Text.Printf (printf )
71
68
import UnitTests.NullaryConstructors (nullaryConstructors )
72
69
import qualified Data.ByteString as S
73
70
import qualified Data.ByteString.Base16.Lazy as LBase16
74
71
import qualified Data.ByteString.Lazy.Char8 as L
75
- import qualified Data.HashSet as HashSet
76
72
import qualified Data.Text.Lazy as LT
77
73
import qualified Data.Text.Lazy.Builder as TLB
78
74
import qualified Data.Text.Lazy.Encoding as LT
@@ -420,72 +416,7 @@ unescapeString = do
420
416
Surrogate -> False
421
417
_ -> True
422
418
423
- -- JSONTestSuite
424
-
425
- jsonTestSuiteTest :: FilePath -> TestTree
426
- jsonTestSuiteTest path = testCase fileName $ do
427
- payload <- L. readFile path
428
- let result = eitherDecode payload :: Either String Value
429
- assertBool fileName $ case take 2 fileName of
430
- " i_" -> isRight result
431
- " n_" -> isLeft result
432
- " y_" -> isRight result
433
- _ -> isRight result -- test_transform tests have inconsistent names
434
- where
435
- fileName = takeFileName path
436
-
437
- -- Build a collection of tests based on the current contents of the
438
- -- JSONTestSuite test directories.
439
-
440
- jsonTestSuite :: IO TestTree
441
- jsonTestSuite = do
442
- let suitePath = " tests/JSONTestSuite"
443
- let suites = [" test_parsing" , " test_transform" ]
444
- testPaths <- fmap (sort . concat ) . forM suites $ \ suite -> do
445
- let dir = suitePath </> suite
446
- entries <- getDirectoryContents dir
447
- let ok name = takeExtension name == " .json" &&
448
- not (name `HashSet.member` blacklist)
449
- return . map (dir </> ) . filter ok $ entries
450
- return $ testGroup " JSONTestSuite" $ map jsonTestSuiteTest testPaths
451
-
452
- -- The set expected-to-be-failing JSONTestSuite tests.
453
- -- Not all of these failures are genuine bugs.
454
- -- Of those that are bugs, not all are worth fixing.
455
-
456
- blacklist :: HashSet. HashSet String
457
- -- blacklist = HashSet.empty
458
- blacklist = _blacklist
459
-
460
- _blacklist :: HashSet. HashSet String
461
- _blacklist = HashSet. fromList [
462
- " i_object_key_lone_2nd_surrogate.json"
463
- , " i_string_1st_surrogate_but_2nd_missing.json"
464
- , " i_string_1st_valid_surrogate_2nd_invalid.json"
465
- , " i_string_UTF-16LE_with_BOM.json"
466
- , " i_string_UTF-16_invalid_lonely_surrogate.json"
467
- , " i_string_UTF-16_invalid_surrogate.json"
468
- , " i_string_UTF-8_invalid_sequence.json"
469
- , " i_string_incomplete_surrogate_and_escape_valid.json"
470
- , " i_string_incomplete_surrogate_pair.json"
471
- , " i_string_incomplete_surrogates_escape_valid.json"
472
- , " i_string_invalid_lonely_surrogate.json"
473
- , " i_string_invalid_surrogate.json"
474
- , " i_string_inverted_surrogates_U+1D11E.json"
475
- , " i_string_lone_second_surrogate.json"
476
- , " i_string_not_in_unicode_range.json"
477
- , " i_string_truncated-utf-8.json"
478
- , " i_structure_UTF-8_BOM_empty_object.json"
479
- , " string_1_escaped_invalid_codepoint.json"
480
- , " string_1_invalid_codepoint.json"
481
- , " string_1_invalid_codepoints.json"
482
- , " string_2_escaped_invalid_codepoints.json"
483
- , " string_2_invalid_codepoints.json"
484
- , " string_3_escaped_invalid_codepoints.json"
485
- , " string_3_invalid_codepoints.json"
486
- , " y_string_utf16BE_no_BOM.json"
487
- , " y_string_utf16LE_no_BOM.json"
488
- ]
419
+
489
420
490
421
-- A regression test for: https://github.com/bos/aeson/pull/455
491
422
data Foo a = FooNil | FooCons (Foo Int )
@@ -839,8 +770,7 @@ monadFixTests = testGroup "MonadFix"
839
770
ioTests :: IO [TestTree ]
840
771
ioTests = do
841
772
enc <- encoderComparisonTests
842
- js <- jsonTestSuite
843
- return [enc, js]
773
+ return [enc]
844
774
845
775
tests :: TestTree
846
776
tests = testGroup " unit" [
0 commit comments