hspec-meta 1.12.1 → 1.12.2
raw patch · 3 files changed
+52/−6 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- hspec-meta.cabal +1/−1
- src/Test/Hspec/Runner/Tree.hs +23/−4
- src/Test/Hspec/Util.hs +28/−1
hspec-meta.cabal view
@@ -1,5 +1,5 @@ name: hspec-meta-version: 1.12.1+version: 1.12.2 license: MIT license-file: LICENSE copyright: (c) 2011-2014 Simon Hengel,
src/Test/Hspec/Runner/Tree.hs view
@@ -1,16 +1,35 @@-{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable #-}+{-# LANGUAGE CPP, DeriveFunctor #-} module Test.Hspec.Runner.Tree where import Control.Applicative-import Data.Foldable (Foldable)-import Data.Traversable (Traversable)+import Data.Foldable+import Data.Traversable import Test.Hspec.Core.Type+import Data.Monoid data Tree a = Node !String [Tree a] | NodeWithCleanup (IO ()) [Tree a] | Leaf a- deriving (Functor, Foldable, Traversable)+ deriving Functor++instance Foldable Tree where -- Note: GHC 7.0.1 fails to derive this instance+ foldMap = go+ where+ go :: Monoid m => (a -> m) -> Tree a -> m+ go f t = case t of+ Node _ xs -> foldMap (foldMap f) xs+ NodeWithCleanup _ xs -> foldMap (foldMap f) xs+ Leaf x -> f x++instance Traversable Tree where -- Note: GHC 7.0.1 fails to derive this instance+ sequenceA = go+ where+ go :: Applicative f => Tree (f a) -> f (Tree a)+ go t = case t of+ Node label xs -> Node label <$> sequenceA (map go xs)+ NodeWithCleanup action xs -> NodeWithCleanup action <$> sequenceA (map go xs)+ Leaf a -> Leaf <$> a toTree :: Spec -> IO [Tree Item] toTree spec = map f <$> runSpecM spec
src/Test/Hspec/Util.hs view
@@ -11,6 +11,7 @@ import Data.List import Data.Char (isSpace)+import GHC.IO.Exception import qualified Control.Exception as E import Control.Concurrent.Async @@ -28,8 +29,34 @@ -- @ -- "ArithException (divide by zero)" -- @+--+-- For `IOException`s the `IOErrorType` is included. formatException :: E.SomeException -> String-formatException (E.SomeException e) = showType e ++ " (" ++ show e ++ ")"+formatException err@(E.SomeException e) = case E.fromException err of+ Just ioe -> showType ioe ++ " of type " ++ showIOErrorType ioe ++ " (" ++ show ioe ++ ")"+ Nothing -> showType e ++ " (" ++ show e ++ ")"+ where+ showIOErrorType :: IOException -> String+ showIOErrorType ioe = case ioe_type ioe of+ AlreadyExists -> "AlreadyExists"+ NoSuchThing -> "NoSuchThing"+ ResourceBusy -> "ResourceBusy"+ ResourceExhausted -> "ResourceExhausted"+ EOF -> "EOF"+ IllegalOperation -> "IllegalOperation"+ PermissionDenied -> "PermissionDenied"+ UserError -> "UserError"+ UnsatisfiedConstraints -> "UnsatisfiedConstraints"+ SystemError -> "SystemError"+ ProtocolError -> "ProtocolError"+ OtherError -> "OtherError"+ InvalidArgument -> "InvalidArgument"+ InappropriateType -> "InappropriateType"+ HardwareFault -> "HardwareFault"+ UnsupportedOperation -> "UnsupportedOperation"+ TimeExpired -> "TimeExpired"+ ResourceVanished -> "ResourceVanished"+ Interrupted -> "Interrupted" safeTry :: IO a -> IO (Either E.SomeException a) safeTry action = withAsync (action >>= E.evaluate) waitCatch