Run a property with only one test. This is intended for allowing hedgehog to run unit tests.
Modulehedgehog-extras-0.10.1.0Haskell2010
Hedgehog.Extras.Test.Base
Synopsis
- value propertyOnce
- value workspace
- value workspaceWithConfig
- data WorkspacePolicy
- value moduleWorkspace
- value note
- value note_
- value noteM
- value noteM_
- value noteIO
- value noteIO_
- value noteShow
- value noteShowPretty
- value noteShowIO
- value noteShowPrettyIO
- value noteShowIO_
- value noteShowPrettyIO_
- value noteShowM
- value noteShowPrettyM
- value noteShowM_
- value noteShowPrettyM_
- value noteShow_
- value noteShowPretty_
- value noteEach
- value noteEachPretty
- value noteEachIO
- value noteEachPrettyIO
- value noteEachIO_
- value noteEachPrettyIO_
- value noteEachM
- value noteEachPrettyM
- value noteEachM_
- value noteEachPrettyM_
- value noteEach_
- value noteEachPretty_
- value noteTempFile
- value headM
- value indexM
- value fromJustM
- value nothingFail
- value nothingFailM
- value leftFail
- value leftFailM
- value onLeft
- value onNothing
- value jsonErrorFail
- value jsonErrorFailM
- value failWithCustom
- value failMessage
- value expectFailure
- value expectFailureWith
- value tryAssertion
- value assertFailure
- value assertFailure_
- value assertByDeadlineM
- value assertByDeadlineIO
- value assertByDeadlineMFinally
- value assertByDeadlineIOFinally
- value assertWith
- value assertWithM
- value assertM
- value assertIO
- value assertWithinTolerance
- value byDeadlineM
- value byDeadlineIO
- value byDurationM
- value byDurationIO
- value onFailure
- type Integration
- value release
- value runFinallies
- value retry
- value retry'
- class MonadBaseControl
- value bracket
- value bracket_
- Packagehedgehog-extras-0.10.1.0
- Exports76
- LanguageHaskell2010
- LicenceApache-2.0
- SourceBase.hs
Create a workspace directory which will exist for at least the duration of the supplied block.
The directory will have the supplied prefix but contain a generated random suffix to prevent interference between tests
The directory will be deleted if the block succeeds, but left behind if the block fails.
workspaceWithConfig :: (HasCallStack, MonadCatch m, MonadBaseControl IO m, MonadResource m, MonadTest m, MonadAssertion m)=> WorkspacePolicyCleanup policy: PreserveWorkspace always preserves, CleanupOnSuccess deletes on success only
-> FilePath-> (FilePath -> m ())-> m ()
Create a workspace directory with explicit configuration for cleanup behavior.
The directory will have the supplied prefix but contain a generated random suffix to prevent interference between tests
The directory will be deleted if the block succeeds, but left behind if the block fails (unless policy is PreserveWorkspace, in which case it's always preserved).
Policy for workspace directory cleanup behavior
Constructors
PreserveWorkspaceAlways preserve workspace directories, even on success
CleanupOnSuccessClean up workspace directories only when tests succeed
Instances2Eq, Show
Eq WorkspacePolicyDefined in hedgehog-extras-0.10.1.0 · Hedgehog.Extras.Test.BaseShow WorkspacePolicyDefined in hedgehog-extras-0.10.1.0 · Hedgehog.Extras.Test.Base
Create a workspace directory which will exist for at least the duration of the supplied block.
The directory will have the prefix as "$prefixPath/$moduleName" but contain a generated random suffix to prevent interference between tests
The directory will be deleted if the block succeeds, but left behind if the block fails.
The prefix argument should not contain directory delimeters.
Annotate with the given string.
Annotate the given string returning unit.
Annotate the given string in a monadic context.
Annotate the given string in a monadic context returning unit.
Annotate the given string in IO.
Annotate the given string in IO returning unit.
Annotate the given value.
Annotate the given value, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.
Annotate the given value in IO.
Annotate the given value in IO, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.
Annotate the given value in IO returning unit.
Annotate the given value in IO returning unit, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.
Annotate the given value in a monadic context.
Annotate the given value in a monadic context, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.
Annotate the given value in a monadic context returning unit.
Annotate the given value in a monadic context returning unit, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.
Annotate the given value returning unit.
Annotate the given value returning unit, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.
Annotate the each value in the given traversable.
Annotate the each value in the given traversable, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.
Annotate the each value in the given traversable in IO.
Annotate the each value in the given traversable in IO, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.
Annotate the each value in the given traversable in IO returning unit.
Annotate the each value in the given traversable in IO returning unit, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.
Annotate the each value in the given traversable in a monadic context.
Annotate the each value in the given traversable in a monadic context, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.
Annotate the each value in the given traversable in a monadic context returning unit.
Annotate the each value in the given traversable in a monadic context returning unit, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.
Annotate the each value in the given traversable returning unit.
Annotate the each value in the given traversable returning unit, pretty printing it with indentation. Note that large data structures will take a significant amount of vertical screen space.
Return the test file path after annotating it relative to the project root directory
Index into a list. On failure, a friendly message is included in the test report.
Fail when the result is Nothing.
Fail when the computed result is Nothing.
Fail when the result is Left.
Fail when the computed result is Left.
Fail when the result is Error.
Fail when the computed result is Error.
Takes a CallStack so the error can be rendered at the appropriate call site.
Takes a CallStack so the error can be rendered at the appropriate call site.
Invert the behavior of a property: success becomes failure and vice versa.
Invert the behavior of a property: success becomes failure and vice versa. This function behaves like expectFailure but it allows to check the failure is as expected. The function takes a Failure and should itself be a test that fails if the failure is not as expected.
Attempt to run a function that may assert, returning either a failure or the result of the assertion.
Run the given action and succeed if the action fails, but fail if it succeeds.
Run the given action and succeed if the action fails, but fail if it succeeds.
Run the operation f once a second until it returns True or the deadline expires.
Expiration of the deadline results in an assertion failure
Run the operation f once a second until it returns True or the deadline expires.
Expiration of the deadline results in an assertion failure
Run the operation f once a second until it returns True or the deadline expires.
The action g is run after expiration of the deadline, but before failure allowing for
additional annotations to be presented.
Expiration of the deadline results in an assertion failure
Run the operation f once a second until it returns True or the deadline expires.
The action g is run after expiration of the deadline, but before failure allowing for
additional annotations to be presented.
Expiration of the deadline results in an assertion failure
Run the test function against the value. Report the value on the failure.
Run the test function against the value. Report the value on the failure.
Run the monadic action f and assert the return value is True.
Run the IO action f and assert the return value is True.
assertWithinTolerance :: (Show a, Ord a, Num a, HasCallStack, MonadTest m)=> atested value
v-> aexpected value
c-> atolerance range
r-> m ()
Tests if |c - v| <= r
Run the operation f once per period until it returns True or the deadline expires.
Expiration of the deadline results in an assertion failure
Run the operation f once per period until it returns True or the deadline expires.
Expiration of the deadline results in an assertion failure
Run the operation f once per period until it returns True or the duration expires.
Expiration of the duration results in an assertion failure
Run the operation f once per period until it returns True or the duration expires.
Expiration of the duration results in an assertion failure
Release the given release key.
Writing instances
The usual way to write a MonadBaseControl instance for a transformer
stack over a base monad B is to write an instance MonadBaseControl B B
for the base monad, and MonadTransControl T instances for every transformer
T. Instances for MonadBaseControl are then simply implemented using
ComposeSt, defaultLiftBaseWith, defaultRestoreM.
Instances25MonadBaseControl, …
MonadBaseControl STM STMDefined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl Identity IdentityDefined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl Maybe MaybeDefined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl IO IODefined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl IO UnitIODefined in hedgehog-extras-0.10.1.0 · Hedgehog.Extras.Test.UnitMonadBaseControl [] []Defined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl IO (ResourceT IO)Defined in hedgehog-extras-0.10.1.0 · Hedgehog.Extras.Internal.Orphans · orphanMonadBaseControl b m => MonadBaseControl b (GenT m)Defined in hedgehog-1.7 · Hedgehog.Internal.GenMonadBaseControl b m => MonadBaseControl b (PropertyT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadBaseControl b m => MonadBaseControl b (TestT m)Defined in hedgehog-1.7 · Hedgehog.Internal.PropertyMonadBaseControl b m => MonadBaseControl b (TreeT m)Defined in hedgehog-1.7 · Hedgehog.Internal.TreeMonadBaseControl b m => MonadBaseControl b (MaybeT m)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl b m => MonadBaseControl b (ExceptT e m)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl b m => MonadBaseControl b (IdentityT m)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl b m => MonadBaseControl b (ReaderT r m)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl b m => MonadBaseControl b (StateT s m)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl b m => MonadBaseControl b (StateT s m)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.Control(Monoid w, MonadBaseControl b m) => MonadBaseControl b (WriterT w m)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.Control(Monoid w, MonadBaseControl b m) => MonadBaseControl b (WriterT w m)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.Control(Monoid w, MonadBaseControl b m) => MonadBaseControl b (RWST r w s m)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.Control(Monoid w, MonadBaseControl b m) => MonadBaseControl b (RWST r w s m)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl (ST s) (ST s)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl (Either e) (Either e)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl (ST s) (ST s)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.ControlMonadBaseControl ((->) r) ((->) r)Defined in monad-control-1.0.3.1 · Control.Monad.Trans.Control
bracket :: MonadBaseControl IO m=> m acomputation to run first ("acquire resource")
-> (a -> m b)computation to run last ("release resource")
-> (a -> m c)computation to run in-between
-> m c
Generalized version of bracket.
Note:
When the "acquire" or "release" computations throw exceptions any monadic side effects in
mwill be discarded.When the "in-between" computation throws an exception any monadic side effects in
mproduced by that computation will be discarded but the side effects of the "acquire" or "release" computations will be retained.Also, any monadic side effects in
mof the "release" computation will be discarded; it is run only for its side effects inIO.
Note that when your acquire and release computations are of type IO
it will be more efficient to write:
liftBaseOp (bracket acquire release)bracket_ :: MonadBaseControl IO m=> m acomputation to run first ("acquire resource")
-> m bcomputation to run last ("release resource")
-> m ccomputation to run in-between
-> m c
Generalized version of bracket_.
Note any monadic side effects in m of both the "acquire" and
"release" computations will be discarded. To keep the monadic
side effects of the "acquire" computation, use bracket with
constant functions instead.
Note that when your acquire and release computations are of type IO
it will be more efficient to write:
liftBaseOp_ (bracket_ acquire release)