hspec 1.9.0 → 1.9.1
raw patch · 3 files changed
+35/−6 lines, 3 filesdep ~QuickCheck
Dependency ranges changed: QuickCheck
Files
- hspec.cabal +2/−2
- src/Test/Hspec/Config.hs +2/−2
- src/Test/Hspec/Core/QuickCheckUtil.hs +31/−2
hspec.cabal view
@@ -1,5 +1,5 @@ name: hspec-version: 1.9.0+version: 1.9.1 license: MIT license-file: LICENSE copyright: (c) 2011-2014 Simon Hengel,@@ -48,7 +48,7 @@ , transformers >= 0.2.2.0 && < 0.4.0 , deepseq , HUnit >= 1.2.5- , QuickCheck >= 2.7+ , QuickCheck >= 2.5.1 , quickcheck-io , hspec-expectations == 0.5.0.* exposed-modules:
src/Test/Hspec/Config.hs view
@@ -12,7 +12,6 @@ import System.IO import System.Exit import qualified Test.QuickCheck as QC-import Test.QuickCheck.Random (mkQCGen) import Test.Hspec.Formatters import Test.Hspec.Util@@ -21,6 +20,7 @@ import Test.Hspec.Options import Test.Hspec.FailureReport+import Test.Hspec.Core.QuickCheckUtil (mkGen) data Config = Config { configDryRun :: Bool@@ -105,7 +105,7 @@ setMaxDiscardRatio n args = args {QC.maxDiscardRatio = n} setSeed :: Integer -> QC.Args -> QC.Args- setSeed n args = args {QC.replay = Just (mkQCGen (fromIntegral n), 0)}+ setSeed n args = args {QC.replay = Just (mkGen (fromIntegral n), 0)} getConfig :: Options -> String -> [String] -> IO Config getConfig opts_ prog args = do
src/Test/Hspec/Core/QuickCheckUtil.hs view
@@ -1,7 +1,7 @@+{-# LANGUAGE CPP #-} module Test.Hspec.Core.QuickCheckUtil where import Control.Applicative-import Control.Exception import Data.Int import Data.IORef import Test.QuickCheck hiding (Result(..))@@ -9,11 +9,21 @@ import Test.QuickCheck.Property hiding (Result(..)) import qualified Test.QuickCheck.Property as QCP import Test.QuickCheck.IO ()+++#if MIN_VERSION_QuickCheck(2,7,0)+import Control.Exception import Test.QuickCheck.Random+#endif+ import System.Random aroundProperty :: (IO () -> IO ()) -> Property -> Property+#if MIN_VERSION_QuickCheck(2,7,0) aroundProperty action (MkProperty p) = MkProperty $ MkProp . aroundRose action . unProp <$> p+#else+aroundProperty action p = MkProp . aroundRose action . unProp <$> p+#endif aroundRose :: (IO () -> IO ()) -> Rose QCP.Result -> Rose QCP.Result aroundRose action r = ioRose $ do@@ -23,8 +33,27 @@ isUserInterrupt :: QC.Result -> Bool isUserInterrupt r = case r of+#if MIN_VERSION_QuickCheck(2,7,0) QC.Failure {theException = me} -> (me >>= fromException) == Just UserInterrupt+#elif MIN_VERSION_QuickCheck(2,6,0)+ QC.Failure {QC.interrupted = x} -> x+#else+ QC.Failure {QC.reason = "Exception: 'user interrupt'"} -> True+#endif _ -> False newSeed :: IO Int-newSeed = fromIntegral <$> (fst . randomR (0, maxBound) <$> newQCGen :: IO Int32)+newSeed = fst . randomR (0, fromIntegral (maxBound :: Int32)) <$>+#if MIN_VERSION_QuickCheck(2,7,0)+ newQCGen+#else+ newStdGen+#endif++#if MIN_VERSION_QuickCheck(2,7,0)+mkGen :: Int -> QCGen+mkGen = mkQCGen+#else+mkGen :: Int -> StdGen+mkGen = mkStdGen+#endif