File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ module Hedgehog.Extras.Test.Base
60
60
61
61
, failWithCustom
62
62
, failMessage
63
+ , expectFailure
63
64
64
65
, assertByDeadlineM
65
66
, assertByDeadlineIO
@@ -156,6 +157,14 @@ failWithCustom cs mdiff msg = liftTest $ mkTest (Left $ H.Failure (getCaller cs)
156
157
failMessage :: MonadTest m => CallStack -> String -> m a
157
158
failMessage cs = failWithCustom cs Nothing
158
159
160
+ -- | Invert the behavior of a property: success becomes failure and vice versa.
161
+ expectFailure :: HasCallStack => H. TestT IO m -> H. PropertyT IO ()
162
+ expectFailure prop = GHC. withFrozenCallStack $ do
163
+ (res, _) <- H. evalIO $ H. runTestT prop
164
+ case res of
165
+ Left _ -> pure () -- Property failed so we succeed
166
+ _ -> H. failWith Nothing " Expected the test to fail but it passed" -- Property passed but we expected a failure
167
+
159
168
-- | Create a workspace directory which will exist for at least the duration of
160
169
-- the supplied block.
161
170
--
You can’t perform that action at this time.
0 commit comments