hspec-core 2.7.4 → 2.7.5
raw patch · 7 files changed
+49/−6 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- LICENSE +1/−1
- hspec-core.cabal +5/−3
- src/Test/Hspec/Core/Example/Location.hs +16/−0
- src/Test/Hspec/Core/Formatters.hs +1/−1
- test/Spec.hs +1/−1
- test/Test/Hspec/Core/Example/LocationSpec.hs +24/−0
- version.yaml +1/−0
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2011-2019 Simon Hengel <sol@typeful.net>+Copyright (c) 2011-2021 Simon Hengel <sol@typeful.net> Copyright (c) 2011-2012 Trystan Spangler <trystan.s@comcast.net> Copyright (c) 2011-2011 Greg Weber <greg@gregweber.info>
hspec-core.cabal view
@@ -1,18 +1,20 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.2.+-- This file has been generated from package.yaml by hpack version 0.34.3. -- -- see: https://github.com/sol/hpack name: hspec-core-version: 2.7.4+version: 2.7.5 license: MIT license-file: LICENSE-copyright: (c) 2011-2019 Simon Hengel,+copyright: (c) 2011-2021 Simon Hengel, (c) 2011-2012 Trystan Spangler, (c) 2011 Greg Weber maintainer: Simon Hengel <sol@typeful.net> build-type: Simple+extra-source-files:+ version.yaml category: Testing stability: experimental bug-reports: https://github.com/hspec/hspec/issues
src/Test/Hspec/Core/Example/Location.hs view
@@ -4,6 +4,7 @@ , extractLocation -- for testing+, parseAssertionFailed , parseCallStack , parseLocation , parseSourceSpan@@ -31,6 +32,21 @@ <|> locationFromPatternMatchFail e <|> locationFromRecConError e <|> locationFromIOException e+ <|> locationFromNoMethodError e+ <|> locationFromAssertionFailed e++locationFromNoMethodError :: SomeException -> Maybe Location+locationFromNoMethodError e = case fromException e of+ Just (NoMethodError s) -> listToMaybe (words s) >>= parseSourceSpan+ Nothing -> Nothing++locationFromAssertionFailed :: SomeException -> Maybe Location+locationFromAssertionFailed e = case fromException e of+ Just (AssertionFailed loc) -> parseAssertionFailed loc+ Nothing -> Nothing++parseAssertionFailed :: String -> Maybe Location+parseAssertionFailed loc = parseCallStack loc <|> parseSourceSpan loc locationFromErrorCall :: SomeException -> Maybe Location locationFromErrorCall e = case fromException e of
src/Test/Hspec/Core/Formatters.hs view
@@ -3,7 +3,7 @@ -- Stability: experimental -- -- This module contains formatters that can be used with--- `Test.Hspec.Runner.hspecWith`.+-- `Test.Hspec.Core.Runner.hspecWith`. module Test.Hspec.Core.Formatters ( -- * Formatters
test/Spec.hs view
@@ -5,7 +5,7 @@ import qualified All spec :: Spec-spec = beforeAll_ (setEnv "IGNORE_DOT_HSPEC" "yes") $ afterAll_ (unsetEnv "IGNORE_DOT_HSPEC") All.spec+spec = beforeAll_ (setEnv "IGNORE_DOT_HSPEC" "yes" >> unsetEnv "HSPEC_OPTIONS") $ afterAll_ (unsetEnv "IGNORE_DOT_HSPEC") All.spec main :: IO () main = hspec spec
test/Test/Hspec/Core/Example/LocationSpec.hs view
@@ -2,6 +2,8 @@ {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} {-# OPTIONS_GHC -fno-warn-missing-fields #-} {-# OPTIONS_GHC -fno-warn-overlapping-patterns #-}+{-# OPTIONS_GHC -fno-warn-missing-methods #-}+{-# OPTIONS_GHC -O0 #-} module Test.Hspec.Core.Example.LocationSpec (spec) where import Helper@@ -10,6 +12,11 @@ import Test.Hspec.Core.Example import Test.Hspec.Core.Example.Location +class SomeClass a where+ someMethod :: a -> IO ()++instance SomeClass () where+ data Person = Person { name :: String , age :: Int@@ -17,6 +24,11 @@ spec :: Spec spec = do+ describe "parseAssertionFailed" $ do+ context "with pre-GHC-8.* error message" $ do+ it "extracts source location" $ do+ parseAssertionFailed "Foo.hs:4:7-12: Assertion failed\n" `shouldBe` Just (Location "Foo.hs" 4 7)+ describe "extractLocation" $ do context "with pattern match failure in do expression" $ do context "in IO" $ do@@ -73,6 +85,18 @@ let location = Just $ Location __FILE__ (__LINE__ + 1) 39 Left e <- try $ evaluate (age Person {name = "foo"})+ extractLocation e `shouldBe` location++ context "with NoMethodError" $ do+ it "extracts Location" $ do+ Left e <- try $ someMethod ()+ extractLocation e `shouldBe` Just (Location __FILE__ 18 10)++ context "with AssertionFailed" $ do+ it "extracts Location" $ do+ let+ location = Just $ Location __FILE__ (__LINE__ + 1) 36+ Left e <- try . evaluate $ assert False () extractLocation e `shouldBe` location describe "parseCallStack" $ do
+ version.yaml view
@@ -0,0 +1,1 @@+&version 2.7.5