on master help sign in
Make test suite require generics support
commit12ab1431c583a599377959be2e69e1b67a19ebb3 authorBryan O'Sullivan <bos@serpentine.com> dateMon 25 May 2015, 12:56 (11 years ago) parent774f388
5 files changed+3−26
aeson.cabal−1 tests/Encoders.hs+1−5 tests/Instances.hs+1−4 tests/Properties.hs−9 tests/Types.hs+1−7
aeson.cabal−1
@@ -141,7 +141,6 @@ test-suite tests
141141 Types
142142
143143 ghc-options: -Wall -threaded -rtsopts
144− cpp-options: -DGHC_GENERICS
145144
146145 build-depends:
147146 HUnit,
tests/Encoders.hs+1−5
@@ -1,4 +1,4 @@
1−{-# Language CPP, TemplateHaskell #-}
1+{-# Language TemplateHaskell #-}
22
33module Encoders where
44
@@ -38,7 +38,6 @@ thNullaryToJSONObjectWithSingleField = $(mkToJSON optsObjectWithSingleField ''Nu
3838thNullaryParseJSONObjectWithSingleField :: Value -> Parser Nullary
3939thNullaryParseJSONObjectWithSingleField = $(mkParseJSON optsObjectWithSingleField ''Nullary)
4040
41−#ifdef GHC_GENERICS
4241gNullaryToJSONString :: Nullary -> Value
4342gNullaryToJSONString = genericToJSON defaultOptions
4443
@@ -65,7 +64,6 @@ gNullaryToJSONObjectWithSingleField = genericToJSON optsObjectWithSingleField
6564
6665gNullaryParseJSONObjectWithSingleField :: Value -> Parser Nullary
6766gNullaryParseJSONObjectWithSingleField = genericParseJSON optsObjectWithSingleField
68−#endif
6967
7068
7169--------------------------------------------------------------------------------
@@ -95,7 +93,6 @@ thSomeTypeParseJSONObjectWithSingleField :: FromJSON a => Value -> Parser (SomeT
9593thSomeTypeParseJSONObjectWithSingleField = $(mkParseJSON optsObjectWithSingleField ''SomeType)
9694
9795
98−#ifdef GHC_GENERICS
9996gSomeTypeToJSON2ElemArray :: ToJSON a => SomeType a -> Value
10097gSomeTypeToJSON2ElemArray = genericToJSON opts2ElemArray
10198
@@ -115,4 +112,3 @@ gSomeTypeToJSONObjectWithSingleField = genericToJSON optsObjectWithSingleField
115112
116113gSomeTypeParseJSONObjectWithSingleField :: FromJSON a => Value -> Parser (SomeType a)
117114gSomeTypeParseJSONObjectWithSingleField = genericParseJSON optsObjectWithSingleField
118−#endif
tests/Instances.hs+1−4
@@ -1,8 +1,5 @@
1−{-# Language CPP, OverloadedStrings, RecordWildCards, StandaloneDeriving #-}
1+{-# Language OverloadedStrings, RecordWildCards, StandaloneDeriving #-}
22{-# OPTIONS_GHC -fno-warn-orphans #-}
3−#if __GLASGOW_HASKELL__ < 702
4−{-# OPTIONS_GHC -fno-warn-missing-methods #-}
5−#endif
63
74module Instances where
85
tests/Properties.hs−9
@@ -25,11 +25,8 @@ import Encoders
2525import Properties.Deprecated (deprecatedTests)
2626import System.IO
2727import System.IO.Unsafe (unsafePerformIO)
28−
29−#ifdef GHC_GENERICS
3028import Data.Int
3129import qualified Data.Map as Map
32−#endif
3330
3431#if !MIN_VERSION_time(1,5,0)
3532import System.Locale (defaultTimeLocale, dateTimeFmt)
@@ -153,10 +150,8 @@ main = do
153150 comparisonTest <- encoderComparisonTests
154151 defaultMain (comparisonTest : tests)
155152
156−#ifdef GHC_GENERICS
157153type P6 = Product6 Int Bool String (Approx Double) (Int, Approx Double) ()
158154type S4 = Sum4 Int8 ZonedTime T.Text (Map.Map String Int)
159−#endif
160155
161156--------------------------------------------------------------------------------
162157-- Value properties
@@ -207,14 +202,12 @@ tests = [
207202 , testProperty "DotNetTime" $ roundTripEq (undefined :: DotNetTime)
208203 , testProperty "UTCTime" $ roundTripEq (undefined :: UTCTime)
209204 , testProperty "ZonedTime" $ roundTripEq (undefined :: ZonedTime)
210−#ifdef GHC_GENERICS
211205 , testGroup "ghcGenerics" [
212206 testProperty "OneConstructor" $ roundTripEq OneConstructor
213207 , testProperty "Product2" $ roundTripEq (undefined :: Product2 Int Bool)
214208 , testProperty "Product6" $ roundTripEq (undefined :: P6)
215209 , testProperty "Sum4" $ roundTripEq (undefined :: S4)
216210 ]
217−#endif
218211 ],
219212 testGroup "toFromJSON" [
220213 testProperty "Integer" (toFromJSON :: Integer -> Bool)
@@ -254,7 +247,6 @@ tests = [
254247 ]
255248 ]
256249 ]
257−#ifdef GHC_GENERICS
258250 , testGroup "GHC-generics" [
259251 testGroup "Nullary" [
260252 testProperty "string" (isString . gNullaryToJSONString)
@@ -291,7 +283,6 @@ tests = [
291283 ]
292284 ]
293285 ]
294−#endif
295286 ]
296287
297288
tests/Types.hs+1−7
@@ -1,16 +1,12 @@
1−{-# LANGUAGE CPP, DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
2−#ifdef GHC_GENERICS
1+{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
32{-# LANGUAGE DeriveGeneric, StandaloneDeriving #-}
4−#endif
53
64module Types where
75
86import qualified Data.Map as Map
97import Data.Data
108import Data.Text
11−#ifdef GHC_GENERICS
129import GHC.Generics
13−#endif
1410
1511data Foo = Foo {
1612 fooInt :: Int
@@ -57,7 +53,6 @@ data SomeType a = Nullary
5753 , testThree :: Maybe a
5854 } deriving (Eq, Show)
5955
60−#ifdef GHC_GENERICS
6156deriving instance Generic Foo
6257deriving instance Generic UFoo
6358deriving instance Generic OneConstructor
@@ -67,4 +62,3 @@ deriving instance Generic (Sum4 a b c d)
6762deriving instance Generic (Approx a)
6863deriving instance Generic Nullary
6964deriving instance Generic (SomeType a)
70−#endif