Commits

Bryan O'Sullivan committed 74378d8 Merge

Merge tests

Comments (0)

Files changed (2)

Data/Aeson/Types.hs

File contents unchanged.

tests/Properties.hs

 import Data.Attoparsec.Number
 import Test.Framework (Test, defaultMain, testGroup)
 import Test.Framework.Providers.QuickCheck2 (testProperty)
+import Test.QuickCheck (Arbitrary)
 import qualified Data.ByteString.Lazy.Char8 as L
 import qualified Data.Attoparsec.Lazy as L
 
           maxAbsoluteError = 1e-15
           maxRelativeError = 1e-15
 
+toFromJSON :: (Arbitrary a, Eq a, FromJSON a, ToJSON a) => a -> Bool
+toFromJSON x = case fromJSON . toJSON $ x of
+                Error _ -> False
+                Success x' -> x == x'
+
 main :: IO ()
 main = defaultMain tests
 
       testProperty "roundTripBool" roundTripBool
     , testProperty "roundTripDouble" roundTripDouble
     , testProperty "roundTripInteger" roundTripInteger
+    ],
+  testGroup "toFromJSON" [
+      testProperty "Integer" (toFromJSON :: Integer -> Bool)
+    , testProperty "Double" (toFromJSON :: Double -> Bool)
+    , testProperty "Maybe Integer" (toFromJSON :: Maybe Integer -> Bool)
+    , testProperty "Either Integer Double" (toFromJSON :: Either Integer Double -> Bool)
+    , testProperty "Either Integer Integer" (toFromJSON :: Either Integer Integer -> Bool)
     ]
   ]