hspec 1.11.3 → 1.11.4
raw patch · 4 files changed
+45/−64 lines, 4 filesdep ~basedep ~hspec-metaPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, hspec-meta
API changes (from Hackage documentation)
Files
- hspec.cabal +25/−26
- test/Helper.hs +2/−2
- test/Test/Hspec/Core/TypeSpec.hs +12/−20
- test/Test/Hspec/RunnerSpec.hs +6/−16
hspec.cabal view
@@ -1,5 +1,5 @@ name: hspec-version: 1.11.3+version: 1.11.4 license: MIT license-file: LICENSE copyright: (c) 2011-2014 Simon Hengel,@@ -46,16 +46,16 @@ hs-source-dirs: src build-depends:- base == 4.*+ base == 4.* , random , tf-random , setenv , ansi-terminal >= 0.5 , time- , transformers >= 0.2.2.0+ , transformers >= 0.2.2.0 , deepseq- , HUnit >= 1.2.5- , QuickCheck >= 2.5.1+ , HUnit >= 1.2.5+ , QuickCheck >= 2.5.1 , quickcheck-io , hspec-expectations == 0.6.1.* , async >= 2@@ -79,6 +79,21 @@ Test.Hspec.Formatters.Internal Test.Hspec.Timer +executable hspec-discover+ ghc-options:+ -Wall+ hs-source-dirs:+ hspec-discover/src+ main-is:+ Main.hs+ other-modules:+ Run+ Config+ build-depends:+ base == 4.*+ , filepath+ , directory+ test-suite spec type: exitcode-stdio-1.0@@ -104,11 +119,11 @@ ghc-options: -Wall -Werror build-depends:- base == 4.*+ base == 4.* , random , tf-random , setenv- , silently >= 1.2.4+ , silently >= 1.2.4 , ansi-terminal , time , transformers@@ -119,7 +134,7 @@ , hspec-expectations , async - , hspec-meta >= 1.9.1+ , hspec-meta == 1.11.4 , process , ghc-paths @@ -133,26 +148,10 @@ ghc-options: -Wall -Werror build-depends:- base == 4.*+ base == 4.* , hspec , QuickCheck --- hspec-discover-executable hspec-discover- ghc-options:- -Wall- hs-source-dirs:- hspec-discover/src- main-is:- Main.hs- other-modules:- Run- Config- build-depends:- base == 4.*- , filepath- , directory- test-suite hspec-discover-spec type: exitcode-stdio-1.0@@ -167,7 +166,7 @@ RunSpec ConfigSpec build-depends:- base == 4.*+ base == 4.* , filepath , directory , hspec-meta
test/Helper.hs view
@@ -57,7 +57,7 @@ -- replace times in summary with zeroes normalizeSummary :: [String] -> [String]-normalizeSummary xs = map f xs+normalizeSummary = map f where f x | "Finished in " `isPrefixOf` x = map g x | otherwise = x@@ -65,7 +65,7 @@ | otherwise = x defaultParams :: H.Params-defaultParams = H.Params stdArgs {replay = Just (mkGen 23, 0)} (H.configSmallCheckDepth H.defaultConfig)+defaultParams = H.Params stdArgs {replay = Just (mkGen 23, 0), maxSuccess = 1000} (H.configSmallCheckDepth H.defaultConfig) noOpProgressCallback :: H.ProgressCallback noOpProgressCallback _ = return ()
test/Test/Hspec/Core/TypeSpec.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP #-}+{-# LANGUAGE CPP, ScopedTypeVariables #-} module Test.Hspec.Core.TypeSpec (main, spec) where import Helper@@ -70,13 +70,9 @@ return () it "shows what falsified it" $ do- H.Fail r <- evaluateExample $ property $ \x y -> x + y == (x * y :: Int)- r `shouldBe` intercalate "\n" [-#if MIN_VERSION_QuickCheck(2,7,0)- "Falsifiable (after 2 tests and 2 shrinks): "-#else- "Falsifiable (after 1 test and 3 shrinks): "-#endif+ H.Fail r <- evaluateExample $ property $ \ (x :: Int) (y :: Int) -> (x == 0 && y == 1) ==> False+ r `shouldBe` intercalate "\n" [+ "Falsifiable (after 1 test): " , "0" , "1" ]@@ -90,30 +86,26 @@ readIORef ref `shouldReturn` succ n modifyIORef ref succ H.Success <- evaluateExampleWith action (property $ modifyIORef ref succ)- readIORef ref `shouldReturn` 200+ readIORef ref `shouldReturn` 2000 it "pretty-prints exceptions" $ do- -- pendingWith "this probably needs a patch to QuickCheck"- evaluateExample (property $ (error "foobar" :: Int -> Bool)) `shouldReturn` (H.Fail . intercalate "\n") [+ H.Fail r <- evaluateExample $ property (\ (x :: Int) -> (x == 0) ==> (error "foobar" :: Bool))+ r `shouldBe` intercalate "\n" [ #if MIN_VERSION_QuickCheck(2,7,0) "uncaught exception: ErrorCall (foobar) (after 1 test)" #else- "Exception: 'foobar' (after 1 test and 2 shrinks): "+ "Exception: 'foobar' (after 1 test): " #endif , "0" ] context "when used with shouldBe" $ do it "shows what falsified it" $ do- H.Fail r <- evaluateExample $ property $ \x y -> x + y `shouldBe` (x * y :: Int)+ H.Fail r <- evaluateExample $ property $ \ (x :: Int) (y :: Int) -> (x == 0 && y == 1) ==> 23 `shouldBe` (42 :: Int) r `shouldBe` intercalate "\n" [-#if MIN_VERSION_QuickCheck(2,7,0)- "Falsifiable (after 2 tests and 2 shrinks): "-#else- "Falsifiable (after 1 test and 3 shrinks): "-#endif- , "expected: 0"- , " but got: 1"+ "Falsifiable (after 1 test): "+ , "expected: 42"+ , " but got: 23" , "0" , "1" ]
test/Test/Hspec/RunnerSpec.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} module Test.Hspec.RunnerSpec (main, spec) where import Helper@@ -17,6 +16,7 @@ import qualified Test.Hspec.Runner as H import qualified Test.Hspec.Core as H (Result(..)) import qualified Test.Hspec.Formatters as H (silent)+import qualified Test.Hspec.QuickCheck as H import qualified Test.QuickCheck as QC @@ -26,21 +26,11 @@ quickCheckOptions :: [([Char], Args -> Int)] quickCheckOptions = [("--qc-max-success", QC.maxSuccess), ("--qc-max-size", QC.maxSize), ("--qc-max-discard", QC.maxDiscardRatio)] -prop_foo :: Integer -> Bool-prop_foo = (/= 26)- runPropFoo :: [String] -> IO String-runPropFoo args = fmap (unlines . normalizeSummary . lines) . capture_ . ignoreExitCode . withArgs args . H.hspec $ H.it "foo" $ property prop_foo--prop_foo_result_with_seed_42 :: String-prop_foo_result_with_seed_42 = unlines [-#if MIN_VERSION_QuickCheck(2,7,0)- "Falsifiable (after 31 tests): "-#else- "Falsifiable (after 30 tests): "-#endif- , "26"- ]+runPropFoo args = unlines . normalizeSummary . lines <$> do+ capture_ . ignoreExitCode . withArgs args . H.hspec . H.modifyMaxSuccess (const 1000000) $ do+ H.it "foo" $ do+ property (/= (23 :: Int)) spec :: Spec spec = do@@ -316,7 +306,7 @@ context "with --seed" $ do it "uses specified seed" $ do r <- runPropFoo ["--seed", "42"]- r `shouldContain` prop_foo_result_with_seed_42+ runPropFoo ["--seed", "42"] `shouldReturn` r context "when run with --rerun" $ do it "takes precedence" $ do