@@ -10,7 +10,7 @@ import Test.Framework (Test, defaultMain, testGroup)
1010import Test.Framework.Providers.QuickCheck2 (testProperty)
1111import Test.Framework.Providers.HUnit (testCase)
1212import Test.HUnit (Assertion, assertFailure, assertEqual)
13−import Test.QuickCheck (Arbitrary(..))
13+import Test.QuickCheck (Arbitrary(..), Property, (===), property)
1414import qualified Data.Vector as V
1515import qualified Data.Attoparsec.Lazy as L
1616import qualified Data.ByteString.Lazy.Char8 as L
@@ -42,34 +42,35 @@ roundTripCamel name = assertEqual "" name (camelFrom '_' $ camelTo '_' name)
4242 split c s = map L.unpack $ L.split c $ L.pack s
4343 capitalize t = toUpper (head t) : tail t
4444
45−encodeDouble :: Double -> Double -> Bool
45+encodeDouble :: Double -> Double -> Property
4646encodeDouble num denom
47− | isInfinite d || isNaN d = encode d == "null"
48− | otherwise = (read . L.unpack . encode) d == d
47+ | isInfinite d || isNaN d = encode d === "null"
48+ | otherwise = (read . L.unpack . encode) d === d
4949 where d = num / denom
5050
51−encodeInteger :: Integer -> Bool
52−encodeInteger i = encode i == L.pack (show i)
51+encodeInteger :: Integer -> Property
52+encodeInteger i = encode i === L.pack (show i)
5353
54−toParseJSON :: (Arbitrary a, Eq a) => (Value -> Parser a) -> (a -> Value) -> a -> Bool
54+toParseJSON :: (Arbitrary a, Eq a, Show a) =>
55+ (Value -> Parser a) -> (a -> Value) -> a -> Property
5556toParseJSON parsejson tojson x =
5657 case parse parsejson . tojson $ x of
57− Error _ -> False
58− Success x' -> x == x'
58+ Error _ -> property False
59+ Success x' -> x === x'
5960
60−roundTrip :: (FromJSON a, ToJSON a) => (a -> a -> Bool) -> a -> a -> Bool
61+roundTrip :: (FromJSON a, ToJSON a) => (a -> a -> Property) -> a -> a -> Property
6162roundTrip eq _ i =
6263 case fmap fromJSON . L.parse value . encode . toJSON $ i of
6364 L.Done _ (Success v) -> v `eq` i
64− _ -> False
65+ _ -> property False
6566
66−roundTripEq :: (Eq a, FromJSON a, ToJSON a) => a -> a -> Bool
67−roundTripEq x y = roundTrip (==) x y
67+roundTripEq :: (Eq a, FromJSON a, ToJSON a, Show a) => a -> a -> Property
68+roundTripEq x y = roundTrip (===) x y
6869
69−toFromJSON :: (Arbitrary a, Eq a, FromJSON a, ToJSON a) => a -> Bool
70+toFromJSON :: (Arbitrary a, Eq a, FromJSON a, ToJSON a, Show a) => a -> Property
7071toFromJSON x = case fromJSON . toJSON $ x of
71− Error _ -> False
72− Success x' -> x == x'
72+ Error _ -> property False
73+ Success x' -> x === x'
7374
7475zonedTimeToJSON :: ZonedTime -> Bool
7576zonedTimeToJSON t = and $
@@ -209,11 +210,11 @@ tests = [
209210 ]
210211 ]
211212 , testGroup "toFromJSON" [
212− testProperty "Integer" (toFromJSON :: Integer -> Bool)
213− , testProperty "Double" (toFromJSON :: Double -> Bool)
214− , testProperty "Maybe Integer" (toFromJSON :: Maybe Integer -> Bool)
215− , testProperty "Either Integer Double" (toFromJSON :: Either Integer Double -> Bool)
216− , testProperty "Either Integer Integer" (toFromJSON :: Either Integer Integer -> Bool)
213+ testProperty "Integer" (toFromJSON :: Integer -> Property)
214+ , testProperty "Double" (toFromJSON :: Double -> Property)
215+ , testProperty "Maybe Integer" (toFromJSON :: Maybe Integer -> Property)
216+ , testProperty "Either Integer Double" (toFromJSON :: Either Integer Double -> Property)
217+ , testProperty "Either Integer Integer" (toFromJSON :: Either Integer Integer -> Property)
217218 , testProperty "ZonedTime" $ zonedTimeToJSON
218219 ]
219220 , testGroup "failure messages" [