Skip to content

Commit

Permalink
Generalize resulting monad in expectFailure
Browse files Browse the repository at this point in the history
Co-authored-by: Mateusz Galazyn <[email protected]>
  • Loading branch information
palas and carbolymer committed Oct 22, 2024
1 parent 59ada9a commit d9f5c66
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Hedgehog/Extras/Test/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ module Hedgehog.Extras.Test.Base

import Control.Applicative (Applicative (..))
import Control.Monad (Functor (fmap), Monad (return, (>>=)), mapM_, unless, void, when)
import Control.Monad.Catch (MonadCatch)
import Control.Monad.Catch (Handler (..), MonadCatch)
import Control.Monad.Morph (hoist)
import Control.Monad.Reader (MonadIO (..), MonadReader (ask))
import Control.Monad.Trans.Resource (MonadResource, ReleaseKey, register, runResourceT)
Expand Down Expand Up @@ -125,7 +125,6 @@ import Text.Show (Show (show))
import qualified Control.Concurrent as IO
import qualified Control.Concurrent.STM as STM
import Control.Exception (IOException)
import Control.Monad.Catch (Handler (..))
import qualified Control.Monad.Trans.Resource as IO
import qualified Control.Retry as R
import qualified Data.List as L
Expand Down Expand Up @@ -158,7 +157,7 @@ failMessage :: MonadTest m => CallStack -> String -> m a
failMessage cs = failWithCustom cs Nothing

-- | Invert the behavior of a property: success becomes failure and vice versa.
expectFailure :: HasCallStack => H.TestT IO m -> H.PropertyT IO ()
expectFailure :: (MonadTest m, MonadIO m, HasCallStack) => H.TestT IO a -> m ()
expectFailure prop = GHC.withFrozenCallStack $ do
(res, _) <- H.evalIO $ H.runTestT prop
case res of
Expand Down

0 comments on commit d9f5c66

Please sign in to comment.