packages feed

hspec-meta 1.9.1 → 1.9.2

raw patch · 5 files changed

+42/−21 lines, 5 filesdep ~QuickCheck

Dependency ranges changed: QuickCheck

Files

hspec-meta.cabal view
@@ -1,5 +1,6 @@ name:             hspec-meta version:          1.9.1+version:          1.9.2 license:          MIT license-file:     LICENSE copyright:        (c) 2011-2014 Simon Hengel,@@ -42,7 +43,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   exposed-modules:
src/Test/Hspec/Core/QuickCheckUtil.hs view
@@ -18,6 +18,8 @@  import           System.Random +import           Test.Hspec.Util+ aroundProperty :: (IO () -> IO ()) -> Property -> Property #if MIN_VERSION_QuickCheck(2,7,0) aroundProperty action (MkProperty p) = MkProperty $ MkProp . aroundRose action . unProp <$> p@@ -41,6 +43,13 @@   QC.Failure {QC.reason = "Exception: 'user interrupt'"} -> True #endif   _ -> False++formatNumbers :: Result -> String+formatNumbers r = "(after " ++ pluralize (numTests r) "test" ++ shrinks ++ ")"+  where+    shrinks+      | 0 < numShrinks r = " and " ++ pluralize (numShrinks r) "shrink"+      | otherwise = ""  newSeed :: IO Int newSeed = fst . randomR (0, fromIntegral (maxBound :: Int32)) <$>
src/Test/Hspec/Core/Type.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, GeneralizedNewtypeDeriving, DeriveDataTypeable #-}+{-# LANGUAGE CPP, TypeSynonymInstances, FlexibleInstances, GeneralizedNewtypeDeriving, DeriveDataTypeable #-} module Test.Hspec.Core.Type (   Spec , SpecM (..)@@ -134,15 +134,24 @@     return $       case r of         QC.Success {}               -> Success-        QC.Failure {QC.output = m}  -> fromMaybe (Fail $ sanitizeFailureMessage m) (parsePending m)+        QC.Failure {QC.output = m}  -> fromMaybe (Fail $ sanitizeFailureMessage r) (parsePending m)         QC.GaveUp {QC.numTests = n} -> Fail ("Gave up after " ++ pluralize n "test" )         QC.NoExpectedFailure {}     -> Fail ("No expected failure")     where       progressCallback = QCP.PostTest QCP.NotCounterexample $         \st _ -> paramsReportProgress c (QC.numSuccessTests st, QC.maxSuccessTests st) -      sanitizeFailureMessage :: String -> String-      sanitizeFailureMessage = strip . addFalsifiable . stripFailed+      sanitizeFailureMessage :: QC.Result -> String+      sanitizeFailureMessage r = let m = QC.output r in strip $+#if MIN_VERSION_QuickCheck(2,7,0)+        case QC.theException r of+          Just e -> let numbers = formatNumbers r in+            "uncaught exception: " ++ formatException e ++ " " ++ numbers ++ "\n" ++ case lines m of+              x:xs | x == (exceptionPrefix ++ show e ++ "' " ++ numbers ++ ": ") -> unlines xs+              _ -> m+          Nothing ->+#endif+            (addFalsifiable . stripFailed) m        addFalsifiable :: String -> String       addFalsifiable m@@ -159,11 +168,12 @@        parsePending :: String -> Maybe Result       parsePending m-        | prefix `isPrefixOf` m = (readMaybe . takeWhile (/= '\'') . drop n) m+        | exceptionPrefix `isPrefixOf` m = (readMaybe . takeWhile (/= '\'') . drop n) m         | otherwise = Nothing         where-          n = length prefix-          prefix = "*** Failed! Exception: '"+          n = length exceptionPrefix++      exceptionPrefix = "*** Failed! Exception: '"  -- | Specifies a pending example. --
src/Test/Hspec/Formatters.hs view
@@ -61,11 +61,9 @@  import           Data.Maybe import           Test.Hspec.Util-import           Test.Hspec.Compat import           Text.Printf import           Control.Monad (unless, forM_) import           Control.Applicative-import qualified Control.Exception as E import           System.IO (hPutStr, hFlush)  -- We use an explicit import list for "Test.Hspec.Formatters.Internal", to make@@ -200,17 +198,6 @@           writeLine err       where         err = either (("uncaught exception: " ++) . formatException) id reason---- | Convert an exception to a string.------ The type of the exception is included.  Here is an example:------ >>> import Control.Applicative--- >>> import Control.Exception--- >>> either formatException show <$> (try . evaluate) (1 `div` 0)--- "ArithException (divide by zero)"-formatException :: E.SomeException -> String-formatException (E.SomeException e) = showType e ++ " (" ++ show e ++ ")"  defaultFooter :: FormatM () defaultFooter = do
src/Test/Hspec/Util.hs view
@@ -1,5 +1,6 @@ module Test.Hspec.Util (   pluralize+, formatException , lineBreaksAt , safeTry , Path@@ -13,6 +14,8 @@ import           Control.Applicative import qualified Control.Exception as E +import           Test.Hspec.Compat (showType)+ -- | Create a more readable display of a quantity of something. -- -- Examples:@@ -28,6 +31,17 @@ pluralize :: Int -> String -> String pluralize 1 s = "1 " ++ s pluralize n s = show n ++ " " ++ s ++ "s"++-- | Convert an exception to a string.+--+-- The type of the exception is included.  Here is an example:+--+-- >>> import Control.Applicative+-- >>> import Control.Exception+-- >>> either formatException show <$> (try . evaluate) (1 `div` 0)+-- "ArithException (divide by zero)"+formatException :: E.SomeException -> String+formatException (E.SomeException e) = showType e ++ " (" ++ show e ++ ")"  safeTry :: IO a -> IO (Either E.SomeException a) safeTry action = (Right <$> (action >>= E.evaluate)) `E.catches` [