Commit 2a84d670 authored by Lennart Kolmodin's avatar Lennart Kolmodin
Browse files

Add roundtrip tests for GHC.Fingerprint.

parent 66146ae3
......@@ -10,6 +10,10 @@
#define HAS_NATURAL
#endif
#if __GLASGOW_HASKELL__ >= 704
#define HAS_GHC_FINGERPRINT
#endif
-----------------------------------------------------------------------------
-- |
-- Module : Data.Binary.Class
......@@ -77,7 +81,7 @@ import qualified Data.Sequence as Seq
import qualified Data.Foldable as Fold
#endif
#if __GLASGOW_HASKELL__ >= 704
#ifdef HAS_GHC_FINGERPRINT
import GHC.Fingerprint
#endif
......@@ -591,7 +595,7 @@ instance (Binary i, Ix i, Binary e, IArray UArray e) => Binary (UArray i e) wher
------------------------------------------------------------------------
-- Fingerprints
#if __GLASGOW_HASKELL__ >= 704
#ifdef HAS_GHC_FINGERPRINT
instance Binary Fingerprint where
put (Fingerprint x1 x2) = do
put x1
......
......@@ -5,10 +5,14 @@ module Main ( main ) where
#define HAS_NATURAL
#endif
#if __GLASGOW_HASKELL__ >= 704
#define HAS_GHC_FINGERPRINT
#endif
import Control.Applicative
import Control.Exception as C (SomeException,
catch, evaluate)
import Control.Monad (unless)
import Control.Monad (unless, liftM2)
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString.Lazy.Internal as L
......@@ -20,6 +24,10 @@ import System.IO.Unsafe
import Numeric.Natural
#endif
#ifdef HAS_GHC_FINGERPRINT
import GHC.Fingerprint
#endif
import Test.Framework
import Test.Framework.Providers.QuickCheck2
import Test.QuickCheck
......@@ -376,6 +384,16 @@ prop_test_Natural = forAll (gen :: Gen Natural) test
------------------------------------------------------------------------
#ifdef HAS_GHC_FINGERPRINT
prop_test_GHC_Fingerprint :: Property
prop_test_GHC_Fingerprint = forAll gen test
where
gen :: Gen Fingerprint
gen = liftM2 Fingerprint arbitrary arbitrary
#endif
------------------------------------------------------------------------
type T a = a -> Property
type B a = a -> Bool
......@@ -454,7 +472,10 @@ tests =
, ("Int", p (test :: T Int ))
, ("Integer", p (test :: T Integer ))
#ifdef HAS_NATURAL
, ("Natural", (prop_test_Natural :: Property ))
, ("Natural", prop_test_Natural )
#endif
#ifdef HAS_GHC_FINGERPRINT
, ("GHC.Fingerprint", prop_test_GHC_Fingerprint )
#endif
, ("Float", p (test :: T Float ))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment