hedgehog-extras-0.6.3.0: Supplemental library for hedgehog
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hedgehog.Extras.Test.Tripwire

Description

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

Create a tripwire

data Tripwire Source #

Represents a tripwire which can be tripped only once. It can be used to detect if a particular code path was reached.

Instances

Instances details
Show Tripwire Source # 
Instance details

Defined in Hedgehog.Extras.Test.Tripwire

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 showed: 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.

trip_ :: HasCallStack => MonadIO m => Tripwire -> m () Source #

Triggers the tripwire and registers the place of the first trigger. Idempotent. A silent variant of trip which does not require MonadTest, but also does not log the information about tripping.

isTripped :: MonadIO m => Tripwire -> m Bool Source #

Check if the tripwire was tripped.

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.