Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This modules provides a tripwire abstraction. You can use tripwire as a detection mechanism if the code
path was executed. Trip a tripwire with trip
in the place where you'd like to detect if it was
reached. The tripwire can then be checked in the other place in the code using for example isTripped
or
assertNotTripped
.
Synopsis
- data Tripwire
- makeTripwire :: MonadIO m => m Tripwire
- makeTripwireWithLabel :: MonadIO m => String -> m Tripwire
- trip :: HasCallStack => MonadIO m => MonadTest m => Tripwire -> m ()
- trip_ :: HasCallStack => MonadIO m => Tripwire -> m ()
- isTripped :: MonadIO m => Tripwire -> m Bool
- getTripSite :: MonadIO m => Tripwire -> m (Maybe CallStack)
- resetTripwire :: MonadIO m => Tripwire -> m ()
- assertNotTripped :: HasCallStack => MonadTest m => MonadIO m => Tripwire -> m ()
- assertTripped :: HasCallStack => MonadTest m => MonadIO m => Tripwire -> m ()
Create a tripwire
Represents a tripwire which can be tripped only once. It can be used to detect if a particular code path was reached.
makeTripwire :: MonadIO m => m Tripwire Source #
Creates a new tripwire
makeTripwireWithLabel :: MonadIO m => String -> m Tripwire Source #
Creates a new tripwire with a label, which is visible when show
ed: Tripwire mylabel
Tripwire operations
trip :: HasCallStack => MonadIO m => MonadTest m => Tripwire -> m () Source #
Triggers the tripwire and registers the place of the first trigger. Idempotent. Prints the information in the test log about tripping the tripwire.
getTripSite :: MonadIO m => Tripwire -> m (Maybe CallStack) Source #
Return the call stack, where the tripwire was tripped - if it was tripped.
resetTripwire :: MonadIO m => Tripwire -> m () Source #
Restore tripwire to initial non triggered state
Assertions
assertNotTripped :: HasCallStack => MonadTest m => MonadIO m => Tripwire -> m () Source #
Fails the test if the tripwire was triggered. Prints the call stack where the tripwire was triggered.
assertTripped :: HasCallStack => MonadTest m => MonadIO m => Tripwire -> m () Source #
Fails the test if the tripwire was not triggered yet.