Skip to content

Commit

Permalink
Define expectFailure in terms of expectFailureWith
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Feb 5, 2025
1 parent 5a1fd95 commit 6b40d2d
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/Hedgehog/Extras/Test/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,7 @@ failMessage cs = failWithCustom cs Nothing

-- | Invert the behavior of a property: success becomes failure and vice versa.
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
Left _ -> pure () -- Property failed so we succeed
_ -> H.failWith Nothing "Expected the test to fail but it passed" -- Property passed but we expected a failure
expectFailure = GHC.withFrozenCallStack $ expectFailureWith (pure . const ())

-- | Invert the behavior of a property: success becomes failure and vice versa.
-- This function behaves like 'expectFailure' but it allows to check the failure
Expand Down

0 comments on commit 6b40d2d

Please sign in to comment.