packages feed

hspec-core 2.7.8 → 2.7.9

raw patch · 6 files changed

+54/−14 lines, 6 filesdep ~hspec-metaPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hspec-meta

API changes (from Hackage documentation)

Files

hspec-core.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:             hspec-core-version:          2.7.8+version:          2.7.9 license:          MIT license-file:     LICENSE copyright:        (c) 2011-2021 Simon Hengel,@@ -103,7 +103,7 @@     , directory     , filepath     , hspec-expectations ==0.8.2.*-    , hspec-meta >=2.3.2+    , hspec-meta ==2.7.8     , process     , quickcheck-io >=0.2.0     , random@@ -155,6 +155,7 @@       Test.Hspec.Core.ExampleSpec       Test.Hspec.Core.FailureReportSpec       Test.Hspec.Core.Formatters.DiffSpec+      Test.Hspec.Core.Formatters.InternalSpec       Test.Hspec.Core.FormattersSpec       Test.Hspec.Core.HooksSpec       Test.Hspec.Core.QuickCheckUtilSpec
src/Test/Hspec/Core/Formatters/Internal.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE CPP, GeneralizedNewtypeDeriving #-} module Test.Hspec.Core.Formatters.Internal (   FormatM , FormatConfig(..)@@ -9,6 +9,9 @@ , addFailMessage , finally_ , formatterToFormat+#ifdef TEST+, overwriteWith+#endif ) where  import           Prelude ()@@ -94,8 +97,8 @@ } deriving (Eq, Show)  data FormatterState = FormatterState {-  stateSuccessCount    :: Int-, statePendingCount    :: Int+  stateSuccessCount    :: !Int+, statePendingCount    :: !Int , stateFailMessages    :: [FailureRecord] , stateCpuStartTime    :: Maybe Integer , stateStartTime       :: Seconds@@ -149,10 +152,18 @@ getFailMessages :: FormatM [FailureRecord] getFailMessages = reverse `fmap` gets stateFailMessages +overwriteWith :: String -> String -> String+overwriteWith old new+  | n == 0 = new+  | otherwise = '\r' : new ++ replicate (n - length new) ' '+  where+    n = length old+ writeTransient :: String -> FormatM ()-writeTransient s = do-  write ("\r" ++ s)-  modify $ \ state -> state {stateTransientOutput = s}+writeTransient new = do+  old <- gets stateTransientOutput+  write $ old `overwriteWith` new+  modify $ \ state -> state {stateTransientOutput = new}   h <- getHandle   liftIO $ IO.hFlush h 
test/Test/Hspec/Core/ExampleSpec.hs view
@@ -13,6 +13,7 @@   , Location(..) #endif   , FailureReason(..))+import qualified Test.Hspec.Expectations as H import qualified Test.Hspec.Core.Example as H import qualified Test.Hspec.Core.Spec as H import qualified Test.Hspec.Core.Runner as H@@ -34,7 +35,7 @@   describe "safeEvaluateExample" $ do     context "for Expectation" $ do       it "returns Failure if an expectation does not hold" $ do-        Result "" (Failure _ msg) <- safeEvaluateExample (23 `shouldBe` (42 :: Int))+        Result "" (Failure _ msg) <- safeEvaluateExample (23 `H.shouldBe` (42 :: Int))         msg `shouldBe` ExpectedButGot Nothing "42" "23"        context "when used with `pending`" $ do@@ -174,7 +175,7 @@         let prop p = property $ \ (x :: Int) (y :: Int) -> (x == 0 && y == 1) ==> p         context "when used with shouldBe" $ do           it "shows what falsified it" $ do-            Result "" (Failure _ err) <- evaluateExample $ prop $ 23 `shouldBe` (42 :: Int)+            Result "" (Failure _ err) <- evaluateExample $ prop $ 23 `H.shouldBe` (42 :: Int)             err `shouldBe` ExpectedButGot (Just "Falsifiable (after 1 test):\n  0\n  1") "42" "23"          context "when used with assertEqual" $ do@@ -189,7 +190,7 @@          context "when used with verbose" $ do           it "includes verbose output" $ do-            Result info (Failure _ err) <- evaluateExample $ verbose $ (`shouldBe` (23 :: Int))+            Result info (Failure _ err) <- evaluateExample $ verbose $ (`H.shouldBe` (23 :: Int))             info `shouldBe` "Failed:\n0"             err `shouldBe` ExpectedButGot (Just "Falsifiable (after 1 test):\n  0") "23" "0" 
+ test/Test/Hspec/Core/Formatters/InternalSpec.hs view
@@ -0,0 +1,26 @@+module Test.Hspec.Core.Formatters.InternalSpec (spec) where++import           Prelude ()+import           Helper+++import           Test.Hspec.Core.Formatters.Internal++spec :: Spec+spec = do+  describe "overwriteWith" $ do+    context "when old is null" $ do+      it "returns new" $ do+        ("" `overwriteWith` "foo") `shouldBe` "foo"++    context "when old and new have the same length" $ do+      it "overwrites old" $ do+        ("foo" `overwriteWith` "bar") `shouldBe` "\rbar"++    context "when old is shorter than new" $ do+      it "overwrites old" $ do+        ("ba" `overwriteWith` "foo") `shouldBe` "\rfoo"++    context "when old is longer than new" $ do+      it "overwrites old" $ do+        ("foobar" `overwriteWith` "foo") `shouldBe` "\rfoo   "
test/Test/Hspec/Core/RunnerSpec.hs view
@@ -23,6 +23,7 @@ import           System.Console.ANSI  import           Test.Hspec.Core.FailureReport (FailureReport(..))+import qualified Test.Hspec.Expectations as H import qualified Test.Hspec.Core.Spec as H import qualified Test.Hspec.Core.Runner as H import qualified Test.Hspec.Core.Formatters as H (silent)@@ -425,7 +426,7 @@       it "shows colorized diffs" $ do         r <- capture_ . ignoreExitCode . withArgs ["--diff", "--color"] . H.hspec $ do           H.it "foo" $ do-            23 `shouldBe` (42 :: Int)+            23 `H.shouldBe` (42 :: Int)         r `shouldContain` unlines [             red ++ "       expected: " ++ reset ++ red ++ "42" ++ reset           , red ++ "        but got: " ++ reset ++ green ++ "23" ++ reset@@ -435,7 +436,7 @@       it "it does not show colorized diffs" $ do         r <- capture_ . ignoreExitCode . withArgs ["--no-diff", "--color"] . H.hspec $ do           H.it "foo" $ do-            23 `shouldBe` (42 :: Int)+            23 `H.shouldBe` (42 :: Int)         r `shouldContain` unlines [             red ++ "       expected: " ++ reset ++ "42"           , red ++ "        but got: " ++ reset ++ "23"
version.yaml view
@@ -1,1 +1,1 @@-&version 2.7.8+&version 2.7.9