@@ -56,6 +56,12 @@ toFromJSON x = case fromJSON . toJSON $ x of
56 Error _ -> False
56 Error _ -> False
57 Success x' -> x == x'
57 Success x' -> x == x'
59+genericToFromJSON :: (Arbitrary a, Eq a, Data a) => a -> Bool
60+genericToFromJSON x = case G.fromJSON . G.toJSON $ x of
62+ Success x' -> x == x'
59data Foo = Foo {
65data Foo = Foo {
60 fooInt :: Int
66 fooInt :: Int
61 , fooDouble :: Double
67 , fooDouble :: Double
@@ -94,6 +100,20 @@ instance (Ord k, Arbitrary k, Arbitrary v) => Arbitrary (Map.Map k v) where
94instance Arbitrary Foo where
100instance Arbitrary Foo where
95 arbitrary = liftM4 Foo arbitrary arbitrary arbitrary arbitrary
101 arbitrary = liftM4 Foo arbitrary arbitrary arbitrary arbitrary
105+ Test for Data.Aeson.Generic handling '_' names
110+ } deriving (Show, Eq, Data, Typeable)
112+instance Arbitrary UFoo where
113+ arbitrary = UFoo <$> arbitrary <*> arbitrary
97main :: IO ()
117main :: IO ()
98main = defaultMain tests
118main = defaultMain tests
@@ -130,5 +150,8 @@ tests = [
130 , testProperty "Maybe Integer" (toFromJSON :: Maybe Integer -> Bool)
150 , testProperty "Maybe Integer" (toFromJSON :: Maybe Integer -> Bool)
131 , testProperty "Either Integer Double" (toFromJSON :: Either Integer Double -> Bool)
151 , testProperty "Either Integer Double" (toFromJSON :: Either Integer Double -> Bool)
132 , testProperty "Either Integer Integer" (toFromJSON :: Either Integer Integer -> Bool)
152 , testProperty "Either Integer Integer" (toFromJSON :: Either Integer Integer -> Bool)
154+ testGroup "genericToFromJSON" [
155+ testProperty "_UFoo" (genericToFromJSON :: UFoo -> Bool)