1{-# LANGUAGE ScopedTypeVariables #-}
3import Data.Aeson.Encode
4import Data.Aeson.Parser (value)
6import Data.Attoparsec.Number
7import Test.Framework (defaultMain, testGroup)
8import Test.Framework.Providers.QuickCheck2 (testProperty)
9import Test.QuickCheck (Arbitrary(..))
10import Test.QuickCheck.Monadic (assert, monadicIO, run)
11import qualified Data.ByteString.Lazy.Char8 as L
12import qualified Data.Attoparsec.Lazy as L
14encodeDouble d = encode (Number (D d)) == L.pack (show d)
15encodeInteger i = encode (Number (I i)) == L.pack (show i)
17roundTrip :: (Eq a, FromJSON a, ToJSON a) => a -> Bool
18roundTrip i = (fmap fromJSON . L.maybeResult . L.parse value . encode . toJSON) i == Just (Success i)
20roundTripBool (v::Bool) = roundTrip v
21roundTripDouble (v::Double) = roundTrip v
22roundTripInteger (v::Integer) = roundTrip v
24main = defaultMain tests
28 testProperty "encodeDouble" encodeDouble
29 , testProperty "encodeInteger" encodeInteger
31 testGroup "roundTrip" [
32 testProperty "roundTripBool" roundTripBool
33 , testProperty "roundTripDouble" roundTripDouble
34 , testProperty "roundTripInteger" roundTripInteger
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list