summaryrefslogtreecommitdiff
path: root/dev-haskell/aeson/files/aeson-1.5.6.0-fix-tests-ghc_9.patch
blob: bf6f2eb92c1e61cd9a3d16f0324910a8e71a15aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
From 083691aa10e802a1b9b57922f3d0a234cafdb90d Mon Sep 17 00:00:00 2001
From: Oleg Grenrus <oleg.grenrus@iki.fi>
Date: Sat, 20 Feb 2021 23:15:41 +0200
Subject: [PATCH] Add GHC-9.0.1 CI job

Not for benchmarks yet though, cassava etc need bounds relaxed first

We need to reorder stuff in UnitTests, GHC-9.0 is stricter about
which instances are visible.
---
 aeson.cabal                                 |   2 +-
 tests/UnitTests.hs                          | 144 ++++++++++----------

diff --git a/aeson.cabal b/aeson.cabal
index 91eacd7d..6152e509 100644
--- a/aeson.cabal
+++ b/aeson.cabal
@@ -8,7 +8,7 @@ copyright:       (c) 2011-2016 Bryan O'Sullivan
 author:          Bryan O'Sullivan <bos@serpentine.com>
 maintainer:      Adam Bergmark <adam@bergmark.nl>
 stability:       experimental
-tested-with:     GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.3, GHC == 8.10.1
+tested-with:     GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.3, GHC == 8.10.4, GHC == 9.0.1
 synopsis:        Fast JSON parsing and encoding
 cabal-version:   >= 1.10
 homepage:        https://github.com/haskell/aeson
 
diff --git a/tests/UnitTests.hs b/tests/UnitTests.hs
index a0651dda..e5c73f46 100644
--- a/tests/UnitTests.hs
+++ b/tests/UnitTests.hs
@@ -76,59 +76,7 @@ import qualified SerializationFormatSpec
 import Data.Aeson.Parser.UnescapeFFI ()
 import Data.Aeson.Parser.UnescapePure ()
 
-tests :: TestTree
-tests = testGroup "unit" [
-    testGroup "SerializationFormatSpec" SerializationFormatSpec.tests
-  , testGroup "ErrorMessages" ErrorMessages.tests
-  , testGroup "camelCase" [
-      testCase "camelTo" $ roundTripCamel "aName"
-    , testCase "camelTo" $ roundTripCamel "another"
-    , testCase "camelTo" $ roundTripCamel "someOtherName"
-    , testCase "camelTo" $
-        assertEqual "" "camel_apicase" (camelTo '_' "CamelAPICase")
-    , testCase "camelTo2" $ roundTripCamel2 "aName"
-    , testCase "camelTo2" $ roundTripCamel2 "another"
-    , testCase "camelTo2" $ roundTripCamel2 "someOtherName"
-    , testCase "camelTo2" $
-        assertEqual "" "camel_api_case" (camelTo2 '_' "CamelAPICase")
-    ]
-  , testGroup "encoding" [
-      testCase "goodProducer" goodProducer
-    ]
-  , testGroup "utctime" [
-      testCase "good" utcTimeGood
-    , testCase "bad"  utcTimeBad
-    ]
-  , testGroup "formatError" [
-      testCase "example 1" formatErrorExample
-    ]
-  , testGroup ".:, .:?, .:!" $ fmap (testCase "-") dotColonMark
-  , testGroup "Hashable laws" $ fmap (testCase "-") hashableLaws
-  , testGroup "Object construction" $ fmap (testCase "-") objectConstruction
-  , testGroup "Issue #351" $ fmap (testCase "-") issue351
-  , testGroup "Nullary constructors" $ fmap (testCase "-") nullaryConstructors
-  , testGroup "FromJSONKey" $ fmap (testCase "-") fromJSONKeyAssertions
-  , testCase "PR #455" pr455
-  , testCase "Unescape string (PR #477)" unescapeString
-  , testCase "Show Options" showOptions
-  , testGroup "SingleMaybeField" singleMaybeField
-  , testCase "withEmbeddedJSON" withEmbeddedJSONTest
-  , testCase "SingleFieldCon" singleFieldCon
-  , testGroup "UnknownFields" unknownFields
-  , testGroup "Ordering of object keys" keyOrdering
-  , testCase "Ratio with denominator 0" ratioDenominator0
-  , testCase "Rational parses number"   rationalNumber
-  , testCase "Big rational"             bigRationalDecoding
-  , testCase "Small rational"           smallRationalDecoding
-  , testCase "Big scientific exponent" bigScientificExponent
-  , testCase "Big integer decoding" bigIntegerDecoding
-  , testCase "Big natural decading" bigNaturalDecoding
-  , testCase "Big integer key decoding" bigIntegerKeyDecoding
-  , testGroup "QQ.Simple"
-    [ testCase "example" $
-      assertEqual "" (object ["foo" .= True]) [aesonQQ| {"foo": true } |]
-    ]
-  ]
+
 
 roundTripCamel :: String -> Assertion
 roundTripCamel name = assertEqual "" name (camelFrom '_' $ camelTo '_' name)
@@ -389,11 +337,7 @@ issue351 = [
 -- Comparison between bytestring and text encoders
 ------------------------------------------------------------------------------
 
-ioTests :: IO [TestTree]
-ioTests = do
-  enc <- encoderComparisonTests
-  js <- jsonTestSuite
-  return [enc, js]
+
 
 encoderComparisonTests :: IO TestTree
 encoderComparisonTests = do
@@ -427,6 +371,7 @@ encoderComparisonTests = do
 
 -- A regression test for: https://github.com/bos/aeson/issues/293
 data MyRecord = MyRecord {_field1 :: Maybe Int, _field2 :: Maybe Bool}
+deriveJSON defaultOptions{omitNothingFields=True} ''MyRecord
 
 data MyRecord2 = MyRecord2 {_field3 :: Maybe Int, _field4 :: Maybe Bool}
   deriving Generic
@@ -522,6 +467,8 @@ _blacklist = HashSet.fromList [
 
 -- A regression test for: https://github.com/bos/aeson/pull/455
 data Foo a = FooNil | FooCons (Foo Int)
+deriveToJSON  defaultOptions ''Foo
+deriveToJSON1 defaultOptions ''Foo
 
 pr455 :: Assertion
 pr455 = assertEqual "FooCons FooNil"
@@ -548,6 +495,7 @@ showOptions =
 
 newtype SingleMaybeField = SingleMaybeField { smf :: Maybe Int }
   deriving (Eq, Show, Generic)
+deriveJSON defaultOptions{omitNothingFields=True,unwrapUnaryRecords=True} ''SingleMaybeField
 
 singleMaybeField :: [TestTree]
 singleMaybeField = do
@@ -589,14 +537,21 @@ singleFieldCon =
 
 newtype UnknownFields = UnknownFields { knownField :: Int }
   deriving (Eq, Show, Generic)
+deriveJSON defaultOptions{rejectUnknownFields=True} ''UnknownFields
+
 newtype UnknownFieldsTag = UnknownFieldsTag { tag :: Int }
   deriving (Eq, Show, Generic)
+deriveJSON defaultOptions{rejectUnknownFields=True} ''UnknownFieldsTag
+
 newtype UnknownFieldsUnaryTagged = UnknownFieldsUnaryTagged { knownFieldUnaryTagged :: Int }
   deriving (Eq, Show, Generic)
+deriveJSON defaultOptions{tagSingleConstructors=True,rejectUnknownFields=True} ''UnknownFieldsUnaryTagged
+
 data UnknownFieldsSum
   = UnknownFields1 { knownField1 :: Int }
   | UnknownFields2 { knownField2 :: Int }
   deriving (Eq, Show, Generic)
+deriveJSON defaultOptions{rejectUnknownFields=True} ''UnknownFieldsSum
 
 unknownFields :: [TestTree]
 unknownFields = concat
@@ -753,17 +708,68 @@ bigNaturalKeyDecoding =
 type family Fam757 :: * -> *
 type instance Fam757 = Maybe
 newtype Newtype757 a = MkNewtype757 (Fam757 a)
+deriveToJSON1 defaultOptions ''Newtype757
 
-deriveJSON defaultOptions{omitNothingFields=True} ''MyRecord
-
-deriveToJSON  defaultOptions ''Foo
-deriveToJSON1 defaultOptions ''Foo
-
-deriveJSON defaultOptions{omitNothingFields=True,unwrapUnaryRecords=True} ''SingleMaybeField
+-------------------------------------------------------------------------------
+-- Tests trees
+-------------------------------------------------------------------------------
 
-deriveJSON defaultOptions{rejectUnknownFields=True} ''UnknownFields
-deriveJSON defaultOptions{rejectUnknownFields=True} ''UnknownFieldsTag
-deriveJSON defaultOptions{tagSingleConstructors=True,rejectUnknownFields=True} ''UnknownFieldsUnaryTagged
-deriveJSON defaultOptions{rejectUnknownFields=True} ''UnknownFieldsSum
+ioTests :: IO [TestTree]
+ioTests = do
+  enc <- encoderComparisonTests
+  js <- jsonTestSuite
+  return [enc, js]
 
-deriveToJSON1 defaultOptions ''Newtype757
+tests :: TestTree
+tests = testGroup "unit" [
+    testGroup "SerializationFormatSpec" SerializationFormatSpec.tests
+  , testGroup "ErrorMessages" ErrorMessages.tests
+  , testGroup "camelCase" [
+      testCase "camelTo" $ roundTripCamel "aName"
+    , testCase "camelTo" $ roundTripCamel "another"
+    , testCase "camelTo" $ roundTripCamel "someOtherName"
+    , testCase "camelTo" $
+        assertEqual "" "camel_apicase" (camelTo '_' "CamelAPICase")
+    , testCase "camelTo2" $ roundTripCamel2 "aName"
+    , testCase "camelTo2" $ roundTripCamel2 "another"
+    , testCase "camelTo2" $ roundTripCamel2 "someOtherName"
+    , testCase "camelTo2" $
+        assertEqual "" "camel_api_case" (camelTo2 '_' "CamelAPICase")
+    ]
+  , testGroup "encoding" [
+      testCase "goodProducer" goodProducer
+    ]
+  , testGroup "utctime" [
+      testCase "good" utcTimeGood
+    , testCase "bad"  utcTimeBad
+    ]
+  , testGroup "formatError" [
+      testCase "example 1" formatErrorExample
+    ]
+  , testGroup ".:, .:?, .:!" $ fmap (testCase "-") dotColonMark
+  , testGroup "Hashable laws" $ fmap (testCase "-") hashableLaws
+  , testGroup "Object construction" $ fmap (testCase "-") objectConstruction
+  , testGroup "Issue #351" $ fmap (testCase "-") issue351
+  , testGroup "Nullary constructors" $ fmap (testCase "-") nullaryConstructors
+  , testGroup "FromJSONKey" $ fmap (testCase "-") fromJSONKeyAssertions
+  , testCase "PR #455" pr455
+  , testCase "Unescape string (PR #477)" unescapeString
+  , testCase "Show Options" showOptions
+  , testGroup "SingleMaybeField" singleMaybeField
+  , testCase "withEmbeddedJSON" withEmbeddedJSONTest
+  , testCase "SingleFieldCon" singleFieldCon
+  , testGroup "UnknownFields" unknownFields
+  , testGroup "Ordering of object keys" keyOrdering
+  , testCase "Ratio with denominator 0" ratioDenominator0
+  , testCase "Rational parses number"   rationalNumber
+  , testCase "Big rational"             bigRationalDecoding
+  , testCase "Small rational"           smallRationalDecoding
+  , testCase "Big scientific exponent" bigScientificExponent
+  , testCase "Big integer decoding" bigIntegerDecoding
+  , testCase "Big natural decading" bigNaturalDecoding
+  , testCase "Big integer key decoding" bigIntegerKeyDecoding
+  , testGroup "QQ.Simple"
+    [ testCase "example" $
+      assertEqual "" (object ["foo" .= True]) [aesonQQ| {"foo": true } |]
+    ]
+  ]