registry-hedgehog-0.2.0.3: utilities to work with Hedgehog generators and `registry`

Safe HaskellNone
LanguageHaskell2010

Test.Tasty.Hedgehogx

Contents

Synopsis

Documentation

showsPrec1 :: (Show1 f, Show a) => Int -> f a -> ShowS #

Lift the standard showsPrec and showList functions through the type constructor.

Since: base-4.9.0.0

compare1 :: (Ord1 f, Ord a) => f a -> f a -> Ordering #

Lift the standard compare function through the type constructor.

Since: base-4.9.0.0

eq1 :: (Eq1 f, Eq a) => f a -> f a -> Bool #

Lift the standard (==) function through the type constructor.

Since: base-4.9.0.0

class Eq1 (f :: Type -> Type) #

Lifting of the Eq class to unary type constructors.

Since: base-4.9.0.0

Minimal complete definition

liftEq

Instances
Eq1 []

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a -> b -> Bool) -> [a] -> [b] -> Bool #

Eq1 Maybe

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a -> b -> Bool) -> Maybe a -> Maybe b -> Bool #

Eq1 Identity

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a -> b -> Bool) -> Identity a -> Identity b -> Bool #

Eq1 Down

Since: base-4.12.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a -> b -> Bool) -> Down a -> Down b -> Bool #

Eq1 NonEmpty

Since: base-4.10.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a -> b -> Bool) -> NonEmpty a -> NonEmpty b -> Bool #

Eq1 IntMap

Since: containers-0.5.9

Instance details

Defined in Data.IntMap.Internal

Methods

liftEq :: (a -> b -> Bool) -> IntMap a -> IntMap b -> Bool #

Eq1 SCC

Since: containers-0.5.9

Instance details

Defined in Data.Graph

Methods

liftEq :: (a -> b -> Bool) -> SCC a -> SCC b -> Bool #

Eq1 Seq

Since: containers-0.5.9

Instance details

Defined in Data.Sequence.Internal

Methods

liftEq :: (a -> b -> Bool) -> Seq a -> Seq b -> Bool #

Eq1 Set

Since: containers-0.5.9

Instance details

Defined in Data.Set.Internal

Methods

liftEq :: (a -> b -> Bool) -> Set a -> Set b -> Bool #

Eq1 Hashed 
Instance details

Defined in Data.Hashable.Class

Methods

liftEq :: (a -> b -> Bool) -> Hashed a -> Hashed b -> Bool #

Eq1 Symbolic 
Instance details

Defined in Hedgehog.Internal.State

Methods

liftEq :: (a -> b -> Bool) -> Symbolic a -> Symbolic b -> Bool #

Eq1 Concrete 
Instance details

Defined in Hedgehog.Internal.State

Methods

liftEq :: (a -> b -> Bool) -> Concrete a -> Concrete b -> Bool #

Eq1 HashSet 
Instance details

Defined in Data.HashSet.Base

Methods

liftEq :: (a -> b -> Bool) -> HashSet a -> HashSet b -> Bool #

Eq a => Eq1 (Either a)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a0 -> b -> Bool) -> Either a a0 -> Either a b -> Bool #

Eq a => Eq1 ((,) a)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a0 -> b -> Bool) -> (a, a0) -> (a, b) -> Bool #

Eq1 (Proxy :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a -> b -> Bool) -> Proxy a -> Proxy b -> Bool #

Eq k => Eq1 (Map k)

Since: containers-0.5.9

Instance details

Defined in Data.Map.Internal

Methods

liftEq :: (a -> b -> Bool) -> Map k a -> Map k b -> Bool #

Eq1 m => Eq1 (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

liftEq :: (a -> b -> Bool) -> MaybeT m a -> MaybeT m b -> Bool #

Eq1 m => Eq1 (ListT m) 
Instance details

Defined in Control.Monad.Trans.List

Methods

liftEq :: (a -> b -> Bool) -> ListT m a -> ListT m b -> Bool #

Eq k => Eq1 (HashMap k) 
Instance details

Defined in Data.HashMap.Base

Methods

liftEq :: (a -> b -> Bool) -> HashMap k a -> HashMap k b -> Bool #

Eq a => Eq1 (Const a :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftEq :: (a0 -> b -> Bool) -> Const a a0 -> Const a b -> Bool #

Eq1 f => Eq1 (IdentityT f) 
Instance details

Defined in Control.Monad.Trans.Identity

Methods

liftEq :: (a -> b -> Bool) -> IdentityT f a -> IdentityT f b -> Bool #

(Eq e, Eq1 m) => Eq1 (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftEq :: (a -> b -> Bool) -> ExceptT e m a -> ExceptT e m b -> Bool #

(Eq w, Eq1 m) => Eq1 (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Writer.Lazy

Methods

liftEq :: (a -> b -> Bool) -> WriterT w m a -> WriterT w m b -> Bool #

(Eq e, Eq1 m) => Eq1 (ErrorT e m) 
Instance details

Defined in Control.Monad.Trans.Error

Methods

liftEq :: (a -> b -> Bool) -> ErrorT e m a -> ErrorT e m b -> Bool #

(Eq w, Eq1 m) => Eq1 (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Writer.Strict

Methods

liftEq :: (a -> b -> Bool) -> WriterT w m a -> WriterT w m b -> Bool #

Eq1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftEq :: (a -> b -> Bool) -> Tagged s a -> Tagged s b -> Bool #

class Eq1 f => Ord1 (f :: Type -> Type) #

Lifting of the Ord class to unary type constructors.

Since: base-4.9.0.0

Minimal complete definition

liftCompare

Instances
Ord1 []

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a -> b -> Ordering) -> [a] -> [b] -> Ordering #

Ord1 Maybe

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a -> b -> Ordering) -> Maybe a -> Maybe b -> Ordering #

Ord1 Identity

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a -> b -> Ordering) -> Identity a -> Identity b -> Ordering #

Ord1 Down

Since: base-4.12.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a -> b -> Ordering) -> Down a -> Down b -> Ordering #

Ord1 NonEmpty

Since: base-4.10.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a -> b -> Ordering) -> NonEmpty a -> NonEmpty b -> Ordering #

Ord1 IntMap

Since: containers-0.5.9

Instance details

Defined in Data.IntMap.Internal

Methods

liftCompare :: (a -> b -> Ordering) -> IntMap a -> IntMap b -> Ordering #

Ord1 Seq

Since: containers-0.5.9

Instance details

Defined in Data.Sequence.Internal

Methods

liftCompare :: (a -> b -> Ordering) -> Seq a -> Seq b -> Ordering #

Ord1 Set

Since: containers-0.5.9

Instance details

Defined in Data.Set.Internal

Methods

liftCompare :: (a -> b -> Ordering) -> Set a -> Set b -> Ordering #

Ord1 Hashed 
Instance details

Defined in Data.Hashable.Class

Methods

liftCompare :: (a -> b -> Ordering) -> Hashed a -> Hashed b -> Ordering #

Ord1 Symbolic 
Instance details

Defined in Hedgehog.Internal.State

Methods

liftCompare :: (a -> b -> Ordering) -> Symbolic a -> Symbolic b -> Ordering #

Ord1 Concrete 
Instance details

Defined in Hedgehog.Internal.State

Methods

liftCompare :: (a -> b -> Ordering) -> Concrete a -> Concrete b -> Ordering #

Ord1 HashSet 
Instance details

Defined in Data.HashSet.Base

Methods

liftCompare :: (a -> b -> Ordering) -> HashSet a -> HashSet b -> Ordering #

Ord a => Ord1 (Either a)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a0 -> b -> Ordering) -> Either a a0 -> Either a b -> Ordering #

Ord a => Ord1 ((,) a)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a0 -> b -> Ordering) -> (a, a0) -> (a, b) -> Ordering #

Ord1 (Proxy :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a -> b -> Ordering) -> Proxy a -> Proxy b -> Ordering #

Ord k => Ord1 (Map k)

Since: containers-0.5.9

Instance details

Defined in Data.Map.Internal

Methods

liftCompare :: (a -> b -> Ordering) -> Map k a -> Map k b -> Ordering #

Ord1 m => Ord1 (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

liftCompare :: (a -> b -> Ordering) -> MaybeT m a -> MaybeT m b -> Ordering #

Ord1 m => Ord1 (ListT m) 
Instance details

Defined in Control.Monad.Trans.List

Methods

liftCompare :: (a -> b -> Ordering) -> ListT m a -> ListT m b -> Ordering #

Ord k => Ord1 (HashMap k) 
Instance details

Defined in Data.HashMap.Base

Methods

liftCompare :: (a -> b -> Ordering) -> HashMap k a -> HashMap k b -> Ordering #

Ord a => Ord1 (Const a :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftCompare :: (a0 -> b -> Ordering) -> Const a a0 -> Const a b -> Ordering #

Ord1 f => Ord1 (IdentityT f) 
Instance details

Defined in Control.Monad.Trans.Identity

Methods

liftCompare :: (a -> b -> Ordering) -> IdentityT f a -> IdentityT f b -> Ordering #

(Ord e, Ord1 m) => Ord1 (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftCompare :: (a -> b -> Ordering) -> ExceptT e m a -> ExceptT e m b -> Ordering #

(Ord w, Ord1 m) => Ord1 (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Writer.Lazy

Methods

liftCompare :: (a -> b -> Ordering) -> WriterT w m a -> WriterT w m b -> Ordering #

(Ord e, Ord1 m) => Ord1 (ErrorT e m) 
Instance details

Defined in Control.Monad.Trans.Error

Methods

liftCompare :: (a -> b -> Ordering) -> ErrorT e m a -> ErrorT e m b -> Ordering #

(Ord w, Ord1 m) => Ord1 (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Writer.Strict

Methods

liftCompare :: (a -> b -> Ordering) -> WriterT w m a -> WriterT w m b -> Ordering #

Ord1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftCompare :: (a -> b -> Ordering) -> Tagged s a -> Tagged s b -> Ordering #

class Show1 (f :: Type -> Type) #

Lifting of the Show class to unary type constructors.

Since: base-4.9.0.0

Minimal complete definition

liftShowsPrec

Instances
Show1 []

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> [a] -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [[a]] -> ShowS #

Show1 Maybe

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Maybe a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Maybe a] -> ShowS #

Show1 Identity

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Identity a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Identity a] -> ShowS #

Show1 Down

Since: base-4.12.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Down a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Down a] -> ShowS #

Show1 NonEmpty

Since: base-4.10.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> NonEmpty a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [NonEmpty a] -> ShowS #

Show1 IntMap

Since: containers-0.5.9

Instance details

Defined in Data.IntMap.Internal

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> IntMap a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [IntMap a] -> ShowS #

Show1 SCC

Since: containers-0.5.9

Instance details

Defined in Data.Graph

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> SCC a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [SCC a] -> ShowS #

Show1 Seq

Since: containers-0.5.9

Instance details

Defined in Data.Sequence.Internal

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Seq a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Seq a] -> ShowS #

Show1 Set

Since: containers-0.5.9

Instance details

Defined in Data.Set.Internal

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Set a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Set a] -> ShowS #

Show1 Hashed 
Instance details

Defined in Data.Hashable.Class

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Hashed a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Hashed a] -> ShowS #

Show1 Symbolic 
Instance details

Defined in Hedgehog.Internal.State

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Symbolic a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Symbolic a] -> ShowS #

Show1 Concrete 
Instance details

Defined in Hedgehog.Internal.State

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Concrete a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Concrete a] -> ShowS #

Show1 HashSet 
Instance details

Defined in Data.HashSet.Base

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> HashSet a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [HashSet a] -> ShowS #

Show a => Show1 (Either a)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> Either a a0 -> ShowS #

liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [Either a a0] -> ShowS #

Show a => Show1 ((,) a)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> (a, a0) -> ShowS #

liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [(a, a0)] -> ShowS #

Show1 (Proxy :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Proxy a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Proxy a] -> ShowS #

Show k => Show1 (Map k)

Since: containers-0.5.9

Instance details

Defined in Data.Map.Internal

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Map k a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Map k a] -> ShowS #

Show1 m => Show1 (MaybeT m) 
Instance details

Defined in Control.Monad.Trans.Maybe

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> MaybeT m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [MaybeT m a] -> ShowS #

Show1 m => Show1 (TreeT m) 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> TreeT m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [TreeT m a] -> ShowS #

Show1 m => Show1 (NodeT m) 
Instance details

Defined in Hedgehog.Internal.Tree

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> NodeT m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [NodeT m a] -> ShowS #

Show1 m => Show1 (ListT m) 
Instance details

Defined in Control.Monad.Trans.List

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ListT m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ListT m a] -> ShowS #

Show k => Show1 (HashMap k) 
Instance details

Defined in Data.HashMap.Base

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> HashMap k a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [HashMap k a] -> ShowS #

Show a => Show1 (Const a :: Type -> Type)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Classes

Methods

liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> Const a a0 -> ShowS #

liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [Const a a0] -> ShowS #

Show1 f => Show1 (IdentityT f) 
Instance details

Defined in Control.Monad.Trans.Identity

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> IdentityT f a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [IdentityT f a] -> ShowS #

(Show e, Show1 m) => Show1 (ExceptT e m) 
Instance details

Defined in Control.Monad.Trans.Except

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ExceptT e m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ExceptT e m a] -> ShowS #

(Show w, Show1 m) => Show1 (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Writer.Lazy

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> WriterT w m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [WriterT w m a] -> ShowS #

(Show e, Show1 m) => Show1 (ErrorT e m) 
Instance details

Defined in Control.Monad.Trans.Error

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ErrorT e m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ErrorT e m a] -> ShowS #

(Show w, Show1 m) => Show1 (WriterT w m) 
Instance details

Defined in Control.Monad.Trans.Writer.Strict

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> WriterT w m a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [WriterT w m a] -> ShowS #

Show1 (Tagged s) 
Instance details

Defined in Data.Tagged

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Tagged s a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Tagged s a] -> ShowS #

checkParallel :: MonadIO m => Group -> m Bool #

Check a group of properties in parallel.

Warning: although this check function runs tests faster than checkSequential, it should be noted that it may cause problems with properties that are not self-contained. For example, if you have a group of tests which all use the same database table, you may find that they interfere with each other when being run in parallel.

Using Template Haskell for property discovery:

tests :: IO Bool
tests =
  checkParallel $$(discover)

With manually specified properties:

tests :: IO Bool
tests =
  checkParallel $ Group "Test.Example" [
      ("prop_reverse", prop_reverse)
    ]

checkSequential :: MonadIO m => Group -> m Bool #

Check a group of properties sequentially.

Using Template Haskell for property discovery:

tests :: IO Bool
tests =
  checkSequential $$(discover)

With manually specified properties:

tests :: IO Bool
tests =
  checkSequential $ Group "Test.Example" [
      ("prop_reverse", prop_reverse)
    ]

recheck :: MonadIO m => Size -> Seed -> Property -> m () #

Check a property using a specific size and seed.

check :: MonadIO m => Property -> m Bool #

Check a property.

discover :: TExpQ Group #

Discover all the properties in a module.

Functions starting with prop_ are assumed to be properties.

executeParallel :: (MonadTest m, MonadCatch m, MonadBaseControl IO m, HasCallStack) => (forall (v :: Type -> Type). state v) -> Parallel m state -> m () #

Executes the prefix actions sequentially, then executes the two branches in parallel, verifying that no exceptions are thrown and that there is at least one sequential interleaving where all the post-conditions are met.

To generate parallel actions to execute, see the parallel combinator in the Hedgehog.Gen module.

executeSequential :: (MonadTest m, MonadCatch m, HasCallStack) => (forall (v :: Type -> Type). state v) -> Sequential m state -> m () #

Executes a list of actions sequentially, verifying that all post-conditions are met and no exceptions are thrown.

To generate a sequence of actions to execute, see the sequential combinator in the Hedgehog.Gen module.

parallel :: (MonadGen gen, MonadTest m) => Range Int -> Range Int -> (forall (v :: Type -> Type). state v) -> [Command gen m state] -> gen (Parallel m state) #

Given the initial model state and set of commands, generates prefix actions to be run sequentially, followed by two branches to be run in parallel.

sequential :: (MonadGen gen, MonadTest m) => Range Int -> (forall (v :: Type -> Type). state v) -> [Command gen m state] -> gen (Sequential m state) #

Generates a sequence of actions from an initial model state and set of commands.

opaque :: Var (Opaque a) Concrete -> a #

Take the value from an opaque concrete variable.

concrete :: Var a Concrete -> a #

Take the value from a concrete variable.

data Symbolic a #

Symbolic values: Because hedgehog generates actions in a separate phase before execution, you will sometimes need to refer to the result of a previous action in a generator without knowing the value of the result (e.g., to get the ID of a previously-created user).

Symmbolic variables provide a token to stand in for the actual variables at generation time (and in 'Require'/'Update' callbacks). At execution time, real values are available, so your execute actions work on Concrete variables.

See also: Command, Var

Instances
Eq1 Symbolic 
Instance details

Defined in Hedgehog.Internal.State

Methods

liftEq :: (a -> b -> Bool) -> Symbolic a -> Symbolic b -> Bool #

Ord1 Symbolic 
Instance details

Defined in Hedgehog.Internal.State

Methods

liftCompare :: (a -> b -> Ordering) -> Symbolic a -> Symbolic b -> Ordering #

Show1 Symbolic 
Instance details

Defined in Hedgehog.Internal.State

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Symbolic a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Symbolic a] -> ShowS #

Eq (Symbolic a) 
Instance details

Defined in Hedgehog.Internal.State

Methods

(==) :: Symbolic a -> Symbolic a -> Bool #

(/=) :: Symbolic a -> Symbolic a -> Bool #

Ord (Symbolic a) 
Instance details

Defined in Hedgehog.Internal.State

Methods

compare :: Symbolic a -> Symbolic a -> Ordering #

(<) :: Symbolic a -> Symbolic a -> Bool #

(<=) :: Symbolic a -> Symbolic a -> Bool #

(>) :: Symbolic a -> Symbolic a -> Bool #

(>=) :: Symbolic a -> Symbolic a -> Bool #

max :: Symbolic a -> Symbolic a -> Symbolic a #

min :: Symbolic a -> Symbolic a -> Symbolic a #

Show (Symbolic a) 
Instance details

Defined in Hedgehog.Internal.State

Methods

showsPrec :: Int -> Symbolic a -> ShowS #

show :: Symbolic a -> String #

showList :: [Symbolic a] -> ShowS #

newtype Concrete a #

Concrete values: At test-execution time, Symbolic values from generation are replaced with Concrete values from performing actions. This type gives us something of the same kind as Symbolic to pass as a type argument to Var.

Constructors

Concrete a 
Instances
Functor Concrete 
Instance details

Defined in Hedgehog.Internal.State

Methods

fmap :: (a -> b) -> Concrete a -> Concrete b #

(<$) :: a -> Concrete b -> Concrete a #

Foldable Concrete 
Instance details

Defined in Hedgehog.Internal.State

Methods

fold :: Monoid m => Concrete m -> m #

foldMap :: Monoid m => (a -> m) -> Concrete a -> m #

foldr :: (a -> b -> b) -> b -> Concrete a -> b #

foldr' :: (a -> b -> b) -> b -> Concrete a -> b #

foldl :: (b -> a -> b) -> b -> Concrete a -> b #

foldl' :: (b -> a -> b) -> b -> Concrete a -> b #

foldr1 :: (a -> a -> a) -> Concrete a -> a #

foldl1 :: (a -> a -> a) -> Concrete a -> a #

toList :: Concrete a -> [a] #

null :: Concrete a -> Bool #

length :: Concrete a -> Int #

elem :: Eq a => a -> Concrete a -> Bool #

maximum :: Ord a => Concrete a -> a #

minimum :: Ord a => Concrete a -> a #

sum :: Num a => Concrete a -> a #

product :: Num a => Concrete a -> a #

Traversable Concrete 
Instance details

Defined in Hedgehog.Internal.State

Methods

traverse :: Applicative f => (a -> f b) -> Concrete a -> f (Concrete b) #

sequenceA :: Applicative f => Concrete (f a) -> f (Concrete a) #

mapM :: Monad m => (a -> m b) -> Concrete a -> m (Concrete b) #

sequence :: Monad m => Concrete (m a) -> m (Concrete a) #

Eq1 Concrete 
Instance details

Defined in Hedgehog.Internal.State

Methods

liftEq :: (a -> b -> Bool) -> Concrete a -> Concrete b -> Bool #

Ord1 Concrete 
Instance details

Defined in Hedgehog.Internal.State

Methods

liftCompare :: (a -> b -> Ordering) -> Concrete a -> Concrete b -> Ordering #

Show1 Concrete 
Instance details

Defined in Hedgehog.Internal.State

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Concrete a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Concrete a] -> ShowS #

Eq a => Eq (Concrete a) 
Instance details

Defined in Hedgehog.Internal.State

Methods

(==) :: Concrete a -> Concrete a -> Bool #

(/=) :: Concrete a -> Concrete a -> Bool #

Ord a => Ord (Concrete a) 
Instance details

Defined in Hedgehog.Internal.State

Methods

compare :: Concrete a -> Concrete a -> Ordering #

(<) :: Concrete a -> Concrete a -> Bool #

(<=) :: Concrete a -> Concrete a -> Bool #

(>) :: Concrete a -> Concrete a -> Bool #

(>=) :: Concrete a -> Concrete a -> Bool #

max :: Concrete a -> Concrete a -> Concrete a #

min :: Concrete a -> Concrete a -> Concrete a #

Show a => Show (Concrete a) 
Instance details

Defined in Hedgehog.Internal.State

Methods

showsPrec :: Int -> Concrete a -> ShowS #

show :: Concrete a -> String #

showList :: [Concrete a] -> ShowS #

newtype Var a (v :: Type -> Type) #

Variables are the potential or actual result of executing an action. They are parameterised by either Symbolic or Concrete depending on the phase of the test.

Symbolic variables are the potential results of actions. These are used when generating the sequence of actions to execute. They allow actions which occur later in the sequence to make use of the result of an action which came earlier in the sequence.

Concrete variables are the actual results of actions. These are used during test execution. They provide access to the actual runtime value of a variable.

The state update Callback for a command needs to be polymorphic in the type of variable because it is used in both the generation and the execution phase.

The order of arguments makes Var HTraverable, which is how Symbolic values are turned into Concrete ones.

Constructors

Var (v a) 
Instances
HTraversable (Var a) 
Instance details

Defined in Hedgehog.Internal.State

Methods

htraverse :: Applicative f => (forall a0. g a0 -> f (h a0)) -> Var a g -> f (Var a h) #

(Eq a, Eq1 v) => Eq (Var a v) 
Instance details

Defined in Hedgehog.Internal.State

Methods

(==) :: Var a v -> Var a v -> Bool #

(/=) :: Var a v -> Var a v -> Bool #

(Ord a, Ord1 v) => Ord (Var a v) 
Instance details

Defined in Hedgehog.Internal.State

Methods

compare :: Var a v -> Var a v -> Ordering #

(<) :: Var a v -> Var a v -> Bool #

(<=) :: Var a v -> Var a v -> Bool #

(>) :: Var a v -> Var a v -> Bool #

(>=) :: Var a v -> Var a v -> Bool #

max :: Var a v -> Var a v -> Var a v #

min :: Var a v -> Var a v -> Var a v #

(Show a, Show1 v) => Show (Var a v) 
Instance details

Defined in Hedgehog.Internal.State

Methods

showsPrec :: Int -> Var a v -> ShowS #

show :: Var a v -> String #

showList :: [Var a v] -> ShowS #

data Callback (input :: (Type -> Type) -> Type) output (state :: (Type -> Type) -> Type) #

Optional command configuration.

Constructors

Require (state Symbolic -> input Symbolic -> Bool)

A pre-condition for a command that must be verified before the command can be executed. This is mainly used during shrinking to ensure that it is still OK to run a command despite the fact that some previously executed commands may have been removed from the sequence.

Update (forall (v :: Type -> Type). Ord1 v => state v -> input v -> Var output v -> state v)

Updates the model state, given the input and output of the command. Note that this function is polymorphic in the type of values. This is because it must work over Symbolic values when we are generating actions, and Concrete values when we are executing them.

Ensure (state Concrete -> state Concrete -> input Concrete -> output -> Test ())

A post-condition for a command that must be verified for the command to be considered a success.

This callback receives the state prior to execution as the first argument, and the state after execution as the second argument.

data Command (gen :: Type -> Type) (m :: Type -> Type) (state :: (Type -> Type) -> Type) where #

The specification for the expected behaviour of an Action. These are used to generate sequences of actions to test.

This is the main type you will use when writing state machine tests. gen is usually an instance of MonadGen, and m is usually an instance of MonadTest. These constraints appear when you pass your Command list to sequential or parallel.

Constructors

Command 

Fields

data Action (m :: Type -> Type) (state :: (Type -> Type) -> Type) #

An instantiation of a Command which can be executed, and its effect evaluated.

Instances
Show (Action m state) 
Instance details

Defined in Hedgehog.Internal.State

Methods

showsPrec :: Int -> Action m state -> ShowS #

show :: Action m state -> String #

showList :: [Action m state] -> ShowS #

data Sequential (m :: Type -> Type) (state :: (Type -> Type) -> Type) #

A sequence of actions to execute.

Constructors

Sequential 

Fields

Instances
Show (Sequential m state) 
Instance details

Defined in Hedgehog.Internal.State

Methods

showsPrec :: Int -> Sequential m state -> ShowS #

show :: Sequential m state -> String #

showList :: [Sequential m state] -> ShowS #

data Parallel (m :: Type -> Type) (state :: (Type -> Type) -> Type) #

A sequential prefix of actions to execute, with two branches to execute in parallel.

Constructors

Parallel 

Fields

Instances
Show (Parallel m state) 
Instance details

Defined in Hedgehog.Internal.State

Methods

showsPrec :: Int -> Parallel m state -> ShowS #

show :: Parallel m state -> String #

showList :: [Parallel m state] -> ShowS #

tripping :: (MonadTest m, Applicative f, Show b, Show (f a), Eq (f a), HasCallStack) => a -> (a -> b) -> (b -> f a) -> m () #

Test that a pair of encode / decode functions are compatible.

Given a printer from some type 'a -> b', and a parser with a potential failure case 'b -> f a'. Ensure that a valid a round trips through the "print" and "parse" to yield the same a.

For example, types should have tripping Read and Show instances.

trippingShowRead :: (Show a, Read a, Eq a, MonadTest m) => a -> m ()
trippingShowRead a = tripping a show readEither

collect :: (MonadTest m, Show a, HasCallStack) => a -> m () #

Like label, but uses Show to render its argument for display.

label :: (MonadTest m, HasCallStack) => LabelName -> m () #

Add a label for each test run. It produces a table showing the percentage of test runs that produced each label.

classify :: (MonadTest m, HasCallStack) => LabelName -> Bool -> m () #

Records the proportion of tests which satisfy a given condition.

   prop_with_classifier :: Property
   prop_with_classifier =
     property $ do
       xs <- forAll $ Gen.list (Range.linear 0 100) Gen.alpha
       for_ xs $ x -> do
         classify "newborns" $ x == 0
         classify "children" $ x > 0 && x < 13
         classify "teens" $ x > 12 && x < 20

cover :: (MonadTest m, HasCallStack) => CoverPercentage -> LabelName -> Bool -> m () #

Require a certain percentage of the tests to be covered by the classifier.

   prop_with_coverage :: Property
   prop_with_coverage =
     property $ do
       match <- forAll Gen.bool
       cover 30 True $ match
       cover 30 False $ not match

The example above requires a minimum of 30% coverage for both classifiers. If these requirements are not met, it will fail the test.

property :: HasCallStack -> PropertyT IO () -> Property #

Creates a property with the default configuration.

withRetries :: ShrinkRetries -> Property -> Property #

Set the number of times a property will be executed for each shrink before the test runner gives up and tries a different shrink. See ShrinkRetries for more information.

withShrinks :: ShrinkLimit -> Property -> Property #

Set the number of times a property is allowed to shrink before the test runner gives up and prints the counterexample.

withDiscards :: DiscardLimit -> Property -> Property #

Set the number of times a property is allowed to discard before the test runner gives up.

withTests :: TestLimit -> Property -> Property #

Set the number of times a property should be executed before it is considered successful.

If you have a test that does not involve any generators and thus does not need to run repeatedly, you can use withTests 1 to define a property that will only be checked once.

discard :: Monad m => PropertyT m a #

Discards the current test entirely.

forAll :: (Monad m, Show a, HasCallStack) => Gen a -> PropertyT m a #

Generates a random input for the test by running the provided generator.

forAllWith :: (Monad m, HasCallStack) => (a -> String) -> Gen a -> PropertyT m a #

Generates a random input for the test by running the provided generator.

This is a the same as forAll but allows the user to provide a custom rendering function. This is useful for values which don't have a Show instance.

evalExceptT :: (MonadTest m, Show x, HasCallStack) => ExceptT x m a -> m a #

Fails the test if the ExceptT is Left, otherwise returns the value in the Right.

evalEither :: (MonadTest m, Show x, HasCallStack) => Either x a -> m a #

Fails the test if the Either is Left, otherwise returns the value in the Right.

evalIO :: (MonadTest m, MonadIO m, HasCallStack) => IO a -> m a #

Fails the test if the IO action throws an exception.

The benefit of using this over liftIO is that the location of the exception will be shown in the output.

evalM :: (MonadTest m, MonadCatch m, HasCallStack) => m a -> m a #

Fails the test if the action throws an exception.

The benefit of using this over simply letting the exception bubble up is that the location of the closest evalM will be shown in the output.

eval :: (MonadTest m, HasCallStack) => a -> m a #

Fails the test if the value throws an exception when evaluated to weak head normal form (WHNF).

(/==) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m () infix 4 #

Fails the test if the two arguments provided are equal.

diff :: (MonadTest m, Show a, Show b, HasCallStack) => a -> (a -> b -> Bool) -> b -> m () #

Fails the test and shows a git-like diff if the comparison operation evaluates to False when applied to its arguments.

The comparison function is the second argument, which may be counter-intuitive to Haskell programmers. However, it allows operators to be written infix for easy reading:

  diff y (<) 87
  diff x (<=) r

/This function behaves like the unix diff tool, which gives a `0` exit code if the compared files are identical, or a `1` exit code code otherwise. Like unix diff, if the arguments fail the comparison, a diff is shown./

assert :: (MonadTest m, HasCallStack) => Bool -> m () #

Fails the test if the condition provided is False.

success :: MonadTest m => m () #

Another name for pure ().

failure :: (MonadTest m, HasCallStack) => m a #

Causes a test to fail.

footnoteShow :: (MonadTest m, Show a) => a -> m () #

Logs a value to be displayed as additional information in the footer of the failure report.

footnote :: MonadTest m => String -> m () #

Logs a message to be displayed as additional information in the footer of the failure report.

annotateShow :: (MonadTest m, Show a, HasCallStack) => a -> m () #

Annotates the source code with a value that might be useful for debugging a test failure.

annotate :: (MonadTest m, HasCallStack) => String -> m () #

Annotates the source code with a message that might be useful for debugging a test failure.

data Property #

A property test, along with some configurable limits like how many times to run the test.

data PropertyT (m :: Type -> Type) a #

The property monad transformer allows both the generation of test inputs and the assertion of expectations.

Instances
MonadTransDistributive PropertyT 
Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type Transformer f PropertyT m :: Constraint #

Methods

distributeT :: Transformer f PropertyT m => PropertyT (f m) a -> f (PropertyT m) a #

MonadTrans PropertyT 
Instance details

Defined in Hedgehog.Internal.Property

Methods

lift :: Monad m => m a -> PropertyT m a #

MonadReader r m => MonadReader r (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

ask :: PropertyT m r #

local :: (r -> r) -> PropertyT m a -> PropertyT m a #

reader :: (r -> a) -> PropertyT m a #

MonadState s m => MonadState s (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

get :: PropertyT m s #

put :: s -> PropertyT m () #

state :: (s -> (a, s)) -> PropertyT m a #

MonadBase b m => MonadBase b (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftBase :: b α -> PropertyT m α #

MonadError e m => MonadError e (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

throwError :: e -> PropertyT m a #

catchError :: PropertyT m a -> (e -> PropertyT m a) -> PropertyT m a #

Monad m => Monad (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

(>>=) :: PropertyT m a -> (a -> PropertyT m b) -> PropertyT m b #

(>>) :: PropertyT m a -> PropertyT m b -> PropertyT m b #

return :: a -> PropertyT m a #

fail :: String -> PropertyT m a #

Functor m => Functor (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

fmap :: (a -> b) -> PropertyT m a -> PropertyT m b #

(<$) :: a -> PropertyT m b -> PropertyT m a #

Monad m => MonadFail (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

fail :: String -> PropertyT m a #

Monad m => Applicative (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

pure :: a -> PropertyT m a #

(<*>) :: PropertyT m (a -> b) -> PropertyT m a -> PropertyT m b #

liftA2 :: (a -> b -> c) -> PropertyT m a -> PropertyT m b -> PropertyT m c #

(*>) :: PropertyT m a -> PropertyT m b -> PropertyT m b #

(<*) :: PropertyT m a -> PropertyT m b -> PropertyT m a #

MonadIO m => MonadIO (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftIO :: IO a -> PropertyT m a #

MonadPlus m => Alternative (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

empty :: PropertyT m a #

(<|>) :: PropertyT m a -> PropertyT m a -> PropertyT m a #

some :: PropertyT m a -> PropertyT m [a] #

many :: PropertyT m a -> PropertyT m [a] #

MonadPlus m => MonadPlus (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

mzero :: PropertyT m a #

mplus :: PropertyT m a -> PropertyT m a -> PropertyT m a #

MonadCatch m => MonadCatch (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

catch :: Exception e => PropertyT m a -> (e -> PropertyT m a) -> PropertyT m a #

MonadThrow m => MonadThrow (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

throwM :: Exception e => e -> PropertyT m a #

Monad m => MonadTest (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> PropertyT m a #

PrimMonad m => PrimMonad (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type PrimState (PropertyT m) :: Type #

Methods

primitive :: (State# (PrimState (PropertyT m)) -> (#State# (PrimState (PropertyT m)), a#)) -> PropertyT m a #

MonadResource m => MonadResource (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftResourceT :: ResourceT IO a -> PropertyT m a #

MFunctor PropertyT 
Instance details

Defined in Hedgehog.Internal.Property

Methods

hoist :: Monad m => (forall a. m a -> n a) -> PropertyT m b -> PropertyT n b #

type Transformer t PropertyT m 
Instance details

Defined in Hedgehog.Internal.Property

type PrimState (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

type Test = TestT Identity #

A test monad allows the assertion of expectations.

data TestT (m :: Type -> Type) a #

A test monad transformer allows the assertion of expectations.

Instances
MonadTransControl TestT 
Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type StT TestT a :: Type #

Methods

liftWith :: Monad m => (Run TestT -> m a) -> TestT m a #

restoreT :: Monad m => m (StT TestT a) -> TestT m a #

MonadTransDistributive TestT 
Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type Transformer f TestT m :: Constraint #

Methods

distributeT :: Transformer f TestT m => TestT (f m) a -> f (TestT m) a #

MonadTrans TestT 
Instance details

Defined in Hedgehog.Internal.Property

Methods

lift :: Monad m => m a -> TestT m a #

MonadBaseControl b m => MonadBaseControl b (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type StM (TestT m) a :: Type #

Methods

liftBaseWith :: (RunInBase (TestT m) b -> b a) -> TestT m a #

restoreM :: StM (TestT m) a -> TestT m a #

MonadReader r m => MonadReader r (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

ask :: TestT m r #

local :: (r -> r) -> TestT m a -> TestT m a #

reader :: (r -> a) -> TestT m a #

MonadState s m => MonadState s (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

get :: TestT m s #

put :: s -> TestT m () #

state :: (s -> (a, s)) -> TestT m a #

MonadBase b m => MonadBase b (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftBase :: b α -> TestT m α #

MonadError e m => MonadError e (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

throwError :: e -> TestT m a #

catchError :: TestT m a -> (e -> TestT m a) -> TestT m a #

Monad m => Monad (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

(>>=) :: TestT m a -> (a -> TestT m b) -> TestT m b #

(>>) :: TestT m a -> TestT m b -> TestT m b #

return :: a -> TestT m a #

fail :: String -> TestT m a #

Functor m => Functor (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

fmap :: (a -> b) -> TestT m a -> TestT m b #

(<$) :: a -> TestT m b -> TestT m a #

Monad m => MonadFail (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

fail :: String -> TestT m a #

Monad m => Applicative (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

pure :: a -> TestT m a #

(<*>) :: TestT m (a -> b) -> TestT m a -> TestT m b #

liftA2 :: (a -> b -> c) -> TestT m a -> TestT m b -> TestT m c #

(*>) :: TestT m a -> TestT m b -> TestT m b #

(<*) :: TestT m a -> TestT m b -> TestT m a #

MonadIO m => MonadIO (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftIO :: IO a -> TestT m a #

MonadCatch m => MonadCatch (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

catch :: Exception e => TestT m a -> (e -> TestT m a) -> TestT m a #

MonadThrow m => MonadThrow (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

throwM :: Exception e => e -> TestT m a #

Monad m => MonadTest (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> TestT m a #

PrimMonad m => PrimMonad (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Associated Types

type PrimState (TestT m) :: Type #

Methods

primitive :: (State# (PrimState (TestT m)) -> (#State# (PrimState (TestT m)), a#)) -> TestT m a #

MonadResource m => MonadResource (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftResourceT :: ResourceT IO a -> TestT m a #

MFunctor TestT 
Instance details

Defined in Hedgehog.Internal.Property

Methods

hoist :: Monad m => (forall a. m a -> n a) -> TestT m b -> TestT n b #

type StT TestT a 
Instance details

Defined in Hedgehog.Internal.Property

type Transformer t TestT m 
Instance details

Defined in Hedgehog.Internal.Property

type PrimState (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

type StM (TestT m) a 
Instance details

Defined in Hedgehog.Internal.Property

type StM (TestT m) a = ComposeSt TestT m a

data TestLimit #

The number of successful tests that need to be run before a property test is considered successful.

Can be constructed using numeric literals:

  200 :: TestLimit
Instances
Enum TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Eq TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Integral TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Num TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Ord TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Real TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Show TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Lift TestLimit 
Instance details

Defined in Hedgehog.Internal.Property

Methods

lift :: TestLimit -> Q Exp #

data DiscardLimit #

The number of discards to allow before giving up.

Can be constructed using numeric literals:

  10000 :: DiscardLimit
Instances
Enum DiscardLimit 
Instance details

Defined in Hedgehog.Internal.Property

Eq DiscardLimit 
Instance details

Defined in Hedgehog.Internal.Property

Integral DiscardLimit 
Instance details

Defined in Hedgehog.Internal.Property

Num DiscardLimit 
Instance details

Defined in Hedgehog.Internal.Property

Ord DiscardLimit 
Instance details

Defined in Hedgehog.Internal.Property

Real DiscardLimit 
Instance details

Defined in Hedgehog.Internal.Property

Show DiscardLimit 
Instance details

Defined in Hedgehog.Internal.Property

Lift DiscardLimit 
Instance details

Defined in Hedgehog.Internal.Property

Methods

lift :: DiscardLimit -> Q Exp #

data ShrinkLimit #

The number of shrinks to try before giving up on shrinking.

Can be constructed using numeric literals:

  1000 :: ShrinkLimit
Instances
Enum ShrinkLimit 
Instance details

Defined in Hedgehog.Internal.Property

Eq ShrinkLimit 
Instance details

Defined in Hedgehog.Internal.Property

Integral ShrinkLimit 
Instance details

Defined in Hedgehog.Internal.Property

Num ShrinkLimit 
Instance details

Defined in Hedgehog.Internal.Property

Ord ShrinkLimit 
Instance details

Defined in Hedgehog.Internal.Property

Real ShrinkLimit 
Instance details

Defined in Hedgehog.Internal.Property

Show ShrinkLimit 
Instance details

Defined in Hedgehog.Internal.Property

Lift ShrinkLimit 
Instance details

Defined in Hedgehog.Internal.Property

Methods

lift :: ShrinkLimit -> Q Exp #

data ShrinkRetries #

The number of times to re-run a test during shrinking. This is useful if you are testing something which fails non-deterministically and you want to increase the change of getting a good shrink.

If you are doing parallel state machine testing, you should probably set shrink retries to something like 10. This will mean that during shrinking, a parallel test case requires 10 successful runs before it is passes and we try a different shrink.

Can be constructed using numeric literals:

  0 :: ShrinkRetries
Instances
Enum ShrinkRetries 
Instance details

Defined in Hedgehog.Internal.Property

Eq ShrinkRetries 
Instance details

Defined in Hedgehog.Internal.Property

Integral ShrinkRetries 
Instance details

Defined in Hedgehog.Internal.Property

Num ShrinkRetries 
Instance details

Defined in Hedgehog.Internal.Property

Ord ShrinkRetries 
Instance details

Defined in Hedgehog.Internal.Property

Real ShrinkRetries 
Instance details

Defined in Hedgehog.Internal.Property

Show ShrinkRetries 
Instance details

Defined in Hedgehog.Internal.Property

Lift ShrinkRetries 
Instance details

Defined in Hedgehog.Internal.Property

Methods

lift :: ShrinkRetries -> Q Exp #

data Group #

A named collection of property tests.

Constructors

Group 

data GroupName #

The name of a group of properties.

Can be constructed using OverloadedStrings:

  "fruit" :: GroupName

class Monad m => MonadTest (m :: Type -> Type) where #

Methods

liftTest :: Test a -> m a #

Instances
MonadTest m => MonadTest (MaybeT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> MaybeT m a #

Monad m => MonadTest (PropertyT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> PropertyT m a #

Monad m => MonadTest (TestT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> TestT m a #

MonadTest m => MonadTest (ResourceT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> ResourceT m a #

MonadTest m => MonadTest (IdentityT m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> IdentityT m a #

MonadTest m => MonadTest (ExceptT x m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> ExceptT x m a #

MonadTest m => MonadTest (StateT s m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> StateT s m a #

(MonadTest m, Monoid w) => MonadTest (WriterT w m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> WriterT w m a #

MonadTest m => MonadTest (StateT s m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> StateT s m a #

(MonadTest m, Monoid w) => MonadTest (WriterT w m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> WriterT w m a #

MonadTest m => MonadTest (ReaderT r m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> ReaderT r m a #

MonadTest m => MonadTest (ContT r m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> ContT r m a #

(MonadTest m, Monoid w) => MonadTest (RWST r w s m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> RWST r w s m a #

(MonadTest m, Monoid w) => MonadTest (RWST r w s m) 
Instance details

Defined in Hedgehog.Internal.Property

Methods

liftTest :: Test a -> RWST r w s m a #

printTreeWith :: (MonadIO m, Show a) => Size -> Seed -> Gen a -> m () #

Print the shrink tree produced by a generator, for the given size and seed.

Use printTree to generate a value from a random seed.

printTree :: (MonadIO m, Show a) => Gen a -> m () #

Run a generator with a random seed and print the resulting shrink tree.

Gen.printTree (Gen.enum 'a' 'f')
'd'
 ├╼'a'
 ├╼'b'
 │  └╼'a'
 └╼'c'
    ├╼'a'
    └╼'b'
       └╼'a'

This may not terminate when the tree is very large.

printWith :: (MonadIO m, Show a) => Size -> Seed -> Gen a -> m () #

Print the value produced by a generator, and the first level of shrinks, for the given size and seed.

Use print to generate a value from a random seed.

sample :: MonadIO m => Gen a -> m a #

Generate a sample from a generator.

shuffle :: MonadGen m => [a] -> m [a] #

Generates a random permutation of a list.

This shrinks towards the order of the list being identical to the input list.

subsequence :: MonadGen m => [a] -> m [a] #

Generates a random subsequence of a list.

subterm3 :: MonadGen m => m a -> m a -> m a -> (a -> a -> a -> a) -> m a #

Constructs a generator from three sub-term generators.

Shrinks to one of the sub-terms if possible.

subtermM3 :: MonadGen m => m a -> m a -> m a -> (a -> a -> a -> m a) -> m a #

Constructs a generator from three sub-term generators.

Shrinks to one of the sub-terms if possible.

subterm2 :: MonadGen m => m a -> m a -> (a -> a -> a) -> m a #

Constructs a generator from two sub-term generators.

Shrinks to one of the sub-terms if possible.

subtermM2 :: MonadGen m => m a -> m a -> (a -> a -> m a) -> m a #

Constructs a generator from two sub-term generators.

Shrinks to one of the sub-terms if possible.

subterm :: MonadGen m => m a -> (a -> a) -> m a #

Constructs a generator from a sub-term generator.

Shrinks to the sub-term if possible.

subtermM :: MonadGen m => m a -> (a -> m a) -> m a #

Constructs a generator from a sub-term generator.

Shrinks to the sub-term if possible.

freeze :: MonadGen m => m a -> m (a, m a) #

Freeze the size and seed used by a generator, so we can inspect the value which it will produce.

This is used for implementing list and subtermMVec. It allows us to shrink the list itself before trying to shrink the values inside the list.

map :: (MonadGen m, Ord k) => Range Int -> m (k, v) -> m (Map k v) #

Generates a map using a Range to determine the length.

This may fail to generate anything if the keys produced by the generator do not account for a large enough number of unique items to satify the required map size.

set :: (MonadGen m, Ord a) => Range Int -> m a -> m (Set a) #

Generates a set using a Range to determine the length.

This may fail to generate anything if the element generator cannot produce a large enough number of unique items to satify the required set size.

nonEmpty :: MonadGen m => Range Int -> m a -> m (NonEmpty a) #

Generates a non-empty list using a Range to determine the length.

seq :: MonadGen m => Range Int -> m a -> m (Seq a) #

Generates a seq using a Range to determine the length.

list :: MonadGen m => Range Int -> m a -> m [a] #

Generates a list using a Range to determine the length.

maybe :: MonadGen m => m a -> m (Maybe a) #

Generates a Nothing some of the time.

just :: (MonadGen m, GenBase m ~ Identity) => m (Maybe a) -> m a #

Runs a Maybe generator until it produces a Just.

This is implemented using filter and has the same caveats.

filter :: (MonadGen m, GenBase m ~ Identity) => (a -> Bool) -> m a -> m a #

Generates a value that satisfies a predicate.

This is essentially:

  filter p gen = mfilter p gen <|> filter p gen

It differs from the above in that we keep some state to avoid looping forever. If we trigger these limits then the whole generator is discarded.

recursive :: MonadGen m => ([m a] -> m a) -> [m a] -> [m a] -> m a #

Modifies combinators which choose from a list of generators, like choice or frequency, so that they can be used in recursive scenarios.

This combinator modifies its target to select one of the generators in either the non-recursive or the recursive list. When a selection is made from the recursive list, the Size is halved. When the Size gets to one or less, selections are no longer made from the recursive list, this ensures termination.

A good example of where this might be useful is abstract syntax trees:

data Expr =
    Var String
  | Lam String Expr
  | App Expr Expr

-- Assuming we have a name generator
genName :: MonadGen m => m String

-- We can write a generator for expressions
genExpr :: MonadGen m => m Expr
genExpr =
  Gen.recursive Gen.choice [
      -- non-recursive generators
      Var <$> genName
    ] [
      -- recursive generators
      Gen.subtermM genExpr (x -> Lam <$> genName <*> pure x)
    , Gen.subterm2 genExpr genExpr App
    ]

If we wrote the above example using only choice, it is likely that it would fail to terminate. This is because for every call to genExpr, there is a 2 in 3 chance that we will recurse again.

frequency :: MonadGen m => [(Int, m a)] -> m a #

Uses a weighted distribution to randomly select one of the generators in the list.

This generator shrinks towards the first generator in the list.

The input list must be non-empty.

choice :: MonadGen m => [m a] -> m a #

Randomly selects one of the generators in the list.

This generator shrinks towards the first generator in the list.

The input list must be non-empty.

element :: MonadGen m => [a] -> m a #

Randomly selects one of the elements in the list.

This generator shrinks towards the first element in the list.

The input list must be non-empty.

constant :: MonadGen m => a -> m a #

Trivial generator that always produces the same element.

This is another name for pure / return.

bytes :: MonadGen m => Range Int -> m ByteString #

Generates a random ByteString, using Range to determine the length.

utf8 :: MonadGen m => Range Int -> m Char -> m ByteString #

Generates a UTF-8 encoded string, using Range to determine the length.

text :: MonadGen m => Range Int -> m Char -> m Text #

Generates a string using Range to determine the length.

string :: MonadGen m => Range Int -> m Char -> m String #

Generates a string using Range to determine the length.

This is a specialization of list, offered for convenience.

unicodeAll :: MonadGen m => m Char #

Generates a Unicode character, including noncharacters and invalid standalone surrogates: '\0'..'\1114111'

unicode :: (MonadGen m, GenBase m ~ Identity) => m Char #

Generates a Unicode character, excluding noncharacters and invalid standalone surrogates: '\0'..'\1114111' (excluding '\55296'..'\57343')

latin1 :: MonadGen m => m Char #

Generates a Latin-1 character: '\0'..'\255'

ascii :: MonadGen m => m Char #

Generates an ASCII character: '\0'..'\127'

alphaNum :: MonadGen m => m Char #

Generates an ASCII letter or digit: 'a'..'z', 'A'..'Z', '0'..'9'

alpha :: MonadGen m => m Char #

Generates an ASCII letter: 'a'..'z', 'A'..'Z'

upper :: MonadGen m => m Char #

Generates an ASCII uppercase letter: 'A'..'Z'

lower :: MonadGen m => m Char #

Generates an ASCII lowercase letter: 'a'..'z'

hexit :: MonadGen m => m Char #

Generates an ASCII hexit: '0'..'9', 'a'..'f', 'A'..'F'

digit :: MonadGen m => m Char #

Generates an ASCII digit: '0'..'9'

octit :: MonadGen m => m Char #

Generates an ASCII octit: '0'..'7'

binit :: MonadGen m => m Char #

Generates an ASCII binit: '0'..'1'

bool_ :: MonadGen m => m Bool #

Generates a random boolean.

This generator does not shrink.

bool :: MonadGen m => m Bool #

Generates a random boolean.

This generator shrinks to False.

This is a specialization of enumBounded, offered for convenience.

enumBounded :: (MonadGen m, Enum a, Bounded a) => m a #

Generates a random value from a bounded enumeration.

This generator shrinks towards minBound.

For example:

enumBounded :: Gen Bool

/This is implemented in terms of the Enum class, and thus may be partial for integral types larger than Int, e.g. Word64./

enum :: (MonadGen m, Enum a) => a -> a -> m a #

Generates an element from an enumeration.

This generator shrinks towards the first argument.

For example:

enum 'a' 'z' :: Gen Char

double :: MonadGen m => Range Double -> m Double #

Generates a random floating-point number in the [inclusive,exclusive) range.

This is a specialization of realFloat, offered for convenience.

float :: MonadGen m => Range Float -> m Float #

Generates a random floating-point number in the [inclusive,exclusive) range.

This is a specialization of realFloat, offered for convenience.

realFrac_ :: (MonadGen m, RealFrac a) => Range a -> m a #

Generates a random fractional number in the [inclusive,exclusive) range.

This generator does not shrink.

realFloat :: (MonadGen m, RealFloat a) => Range a -> m a #

Generates a random floating-point number in the [inclusive,exclusive) range.

This generator works the same as integral, but for floating point numbers.

word64 :: MonadGen m => Range Word64 -> m Word64 #

Generates a random 64-bit word in the given [inclusive,inclusive] range.

This is a specialization of integral, offered for convenience.

word32 :: MonadGen m => Range Word32 -> m Word32 #

Generates a random 32-bit word in the given [inclusive,inclusive] range.

This is a specialization of integral, offered for convenience.

word16 :: MonadGen m => Range Word16 -> m Word16 #

Generates a random 16-bit word in the given [inclusive,inclusive] range.

This is a specialization of integral, offered for convenience.

word8 :: MonadGen m => Range Word8 -> m Word8 #

Generates a random byte in the given [inclusive,inclusive] range.

This is a specialization of integral, offered for convenience.

word :: MonadGen m => Range Word -> m Word #

Generates a random machine word in the given [inclusive,inclusive] range.

This is a specialization of integral, offered for convenience.

int64 :: MonadGen m => Range Int64 -> m Int64 #

Generates a random 64-bit integer in the given [inclusive,inclusive] range.

This is a specialization of integral, offered for convenience.

int32 :: MonadGen m => Range Int32 -> m Int32 #

Generates a random 32-bit integer in the given [inclusive,inclusive] range.

This is a specialization of integral, offered for convenience.

int16 :: MonadGen m => Range Int16 -> m Int16 #

Generates a random 16-bit integer in the given [inclusive,inclusive] range.

This is a specialization of integral, offered for convenience.

int8 :: MonadGen m => Range Int8 -> m Int8 #

Generates a random 8-bit integer in the given [inclusive,inclusive] range.

This is a specialization of integral, offered for convenience.

int :: MonadGen m => Range Int -> m Int #

Generates a random machine integer in the given [inclusive,inclusive] range.

This is a specialization of integral, offered for convenience.

integral_ :: (MonadGen m, Integral a) => Range a -> m a #

Generates a random integral number in the [inclusive,inclusive] range.

This generator does not shrink.

integral :: (MonadGen m, Integral a) => Range a -> m a #

Generates a random integral number in the given [inclusive,inclusive] range.

When the generator tries to shrink, it will shrink towards the origin of the specified Range.

For example, the following generator will produce a number between 1970 and 2100, but will shrink towards 2000:

integral (Range.constantFrom 2000 1970 2100) :: Gen Int

Some sample outputs from this generator might look like:

=== Outcome ===
1973
=== Shrinks ===
2000
1987
1980
1976
1974
=== Outcome ===
2061
=== Shrinks ===
2000
2031
2046
2054
2058
2060

small :: MonadGen m => m a -> m a #

Make a generator smaller by scaling its size parameter.

scale :: MonadGen m => (Size -> Size) -> m a -> m a #

Adjust the size parameter by transforming it with the given function.

resize :: MonadGen m => Size -> m a -> m a #

Override the size parameter. Returns a generator which uses the given size instead of the runtime-size parameter.

sized :: MonadGen m => (Size -> m a) -> m a #

Construct a generator that depends on the size parameter.

prune :: MonadGen m => m a -> m a #

Throw away a generator's shrink tree.

shrink :: MonadGen m => (a -> [a]) -> m a -> m a #

Apply a shrinking function to a generator.

This will give the generator additional shrinking options, while keeping the existing shrinks intact.

type Gen = GenT Identity #

Generator for random values of a.

data GenT (m :: Type -> Type) a #

Monad transformer which can generate random values of a.

Instances
MonadTransDistributive GenT 
Instance details

Defined in Hedgehog.Internal.Gen

Associated Types

type Transformer f GenT m :: Constraint #

Methods

distributeT :: Transformer f GenT m => GenT (f m) a -> f (GenT m) a #

MMonad GenT 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

embed :: Monad n => (forall a. m a -> GenT n a) -> GenT m b -> GenT n b #

MonadTrans GenT 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

lift :: Monad m => m a -> GenT m a #

MonadReader r m => MonadReader r (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

ask :: GenT m r #

local :: (r -> r) -> GenT m a -> GenT m a #

reader :: (r -> a) -> GenT m a #

MonadState s m => MonadState s (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

get :: GenT m s #

put :: s -> GenT m () #

state :: (s -> (a, s)) -> GenT m a #

MonadBase b m => MonadBase b (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

liftBase :: b α -> GenT m α #

MonadWriter w m => MonadWriter w (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

writer :: (a, w) -> GenT m a #

tell :: w -> GenT m () #

listen :: GenT m a -> GenT m (a, w) #

pass :: GenT m (a, w -> w) -> GenT m a #

MonadError e m => MonadError e (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

throwError :: e -> GenT m a #

catchError :: GenT m a -> (e -> GenT m a) -> GenT m a #

Monad m => Monad (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

(>>=) :: GenT m a -> (a -> GenT m b) -> GenT m b #

(>>) :: GenT m a -> GenT m b -> GenT m b #

return :: a -> GenT m a #

fail :: String -> GenT m a #

Functor m => Functor (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

fmap :: (a -> b) -> GenT m a -> GenT m b #

(<$) :: a -> GenT m b -> GenT m a #

Monad m => MonadFail (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

fail :: String -> GenT m a #

Monad m => Applicative (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

pure :: a -> GenT m a #

(<*>) :: GenT m (a -> b) -> GenT m a -> GenT m b #

liftA2 :: (a -> b -> c) -> GenT m a -> GenT m b -> GenT m c #

(*>) :: GenT m a -> GenT m b -> GenT m b #

(<*) :: GenT m a -> GenT m b -> GenT m a #

MonadIO m => MonadIO (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

liftIO :: IO a -> GenT m a #

Monad m => Alternative (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

empty :: GenT m a #

(<|>) :: GenT m a -> GenT m a -> GenT m a #

some :: GenT m a -> GenT m [a] #

many :: GenT m a -> GenT m [a] #

Monad m => MonadPlus (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

mzero :: GenT m a #

mplus :: GenT m a -> GenT m a -> GenT m a #

MonadCatch m => MonadCatch (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

catch :: Exception e => GenT m a -> (e -> GenT m a) -> GenT m a #

MonadThrow m => MonadThrow (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

throwM :: Exception e => e -> GenT m a #

Monad m => MonadGen (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Associated Types

type GenBase (GenT m) :: Type -> Type #

Methods

toGenT :: GenT m a -> GenT (GenBase (GenT m)) a #

fromGenT :: GenT (GenBase (GenT m)) a -> GenT m a #

PrimMonad m => PrimMonad (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Associated Types

type PrimState (GenT m) :: Type #

Methods

primitive :: (State# (PrimState (GenT m)) -> (#State# (PrimState (GenT m)), a#)) -> GenT m a #

MonadResource m => MonadResource (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

liftResourceT :: ResourceT IO a -> GenT m a #

MFunctor GenT 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

hoist :: Monad m => (forall a. m a -> n a) -> GenT m b -> GenT n b #

(Monad m, Semigroup a) => Semigroup (GenT m a) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

(<>) :: GenT m a -> GenT m a -> GenT m a #

sconcat :: NonEmpty (GenT m a) -> GenT m a #

stimes :: Integral b => b -> GenT m a -> GenT m a #

(Monad m, Monoid a) => Monoid (GenT m a) 
Instance details

Defined in Hedgehog.Internal.Gen

Methods

mempty :: GenT m a #

mappend :: GenT m a -> GenT m a -> GenT m a #

mconcat :: [GenT m a] -> GenT m a #

type Transformer t GenT m 
Instance details

Defined in Hedgehog.Internal.Gen

type GenBase (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

type GenBase (GenT m) = m
type PrimState (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

type PrimState (GenT m) = PrimState m

class (Monad m, Monad (GenBase m)) => MonadGen (m :: Type -> Type) where #

Class of monads which can generate input data for tests.

Associated Types

type GenBase (m :: Type -> Type) :: Type -> Type #

Methods

toGenT :: m a -> GenT (GenBase m) a #

Extract a GenT from a MonadGen.

fromGenT :: GenT (GenBase m) a -> m a #

Lift a GenT in to a MonadGen.

Instances
MonadGen m => MonadGen (MaybeT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Associated Types

type GenBase (MaybeT m) :: Type -> Type #

Methods

toGenT :: MaybeT m a -> GenT (GenBase (MaybeT m)) a #

fromGenT :: GenT (GenBase (MaybeT m)) a -> MaybeT m a #

Monad m => MonadGen (GenT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Associated Types

type GenBase (GenT m) :: Type -> Type #

Methods

toGenT :: GenT m a -> GenT (GenBase (GenT m)) a #

fromGenT :: GenT (GenBase (GenT m)) a -> GenT m a #

MonadGen m => MonadGen (IdentityT m) 
Instance details

Defined in Hedgehog.Internal.Gen

Associated Types

type GenBase (IdentityT m) :: Type -> Type #

Methods

toGenT :: IdentityT m a -> GenT (GenBase (IdentityT m)) a #

fromGenT :: GenT (GenBase (IdentityT m)) a -> IdentityT m a #

MonadGen m => MonadGen (ExceptT x m) 
Instance details

Defined in Hedgehog.Internal.Gen

Associated Types

type GenBase (ExceptT x m) :: Type -> Type #

Methods

toGenT :: ExceptT x m a -> GenT (GenBase (ExceptT x m)) a #

fromGenT :: GenT (GenBase (ExceptT x m)) a -> ExceptT x m a #

(MonadGen m, Monoid w) => MonadGen (WriterT w m) 
Instance details

Defined in Hedgehog.Internal.Gen

Associated Types

type GenBase (WriterT w m) :: Type -> Type #

Methods

toGenT :: WriterT w m a -> GenT (GenBase (WriterT w m)) a #

fromGenT :: GenT (GenBase (WriterT w m)) a -> WriterT w m a #

(MonadGen m, Monoid w) => MonadGen (WriterT w m) 
Instance details

Defined in Hedgehog.Internal.Gen

Associated Types

type GenBase (WriterT w m) :: Type -> Type #

Methods

toGenT :: WriterT w m a -> GenT (GenBase (WriterT w m)) a #

fromGenT :: GenT (GenBase (WriterT w m)) a -> WriterT w m a #

MonadGen m => MonadGen (ReaderT r m) 
Instance details

Defined in Hedgehog.Internal.Gen

Associated Types

type GenBase (ReaderT r m) :: Type -> Type #

Methods

toGenT :: ReaderT r m a -> GenT (GenBase (ReaderT r m)) a #

fromGenT :: GenT (GenBase (ReaderT r m)) a -> ReaderT r m a #

data Seed #

A splittable random number generator.

Constructors

Seed 

Fields

Instances
Eq Seed 
Instance details

Defined in Hedgehog.Internal.Seed

Methods

(==) :: Seed -> Seed -> Bool #

(/=) :: Seed -> Seed -> Bool #

Ord Seed 
Instance details

Defined in Hedgehog.Internal.Seed

Methods

compare :: Seed -> Seed -> Ordering #

(<) :: Seed -> Seed -> Bool #

(<=) :: Seed -> Seed -> Bool #

(>) :: Seed -> Seed -> Bool #

(>=) :: Seed -> Seed -> Bool #

max :: Seed -> Seed -> Seed #

min :: Seed -> Seed -> Seed #

Read Seed 
Instance details

Defined in Hedgehog.Internal.Seed

Show Seed 
Instance details

Defined in Hedgehog.Internal.Seed

Methods

showsPrec :: Int -> Seed -> ShowS #

show :: Seed -> String #

showList :: [Seed] -> ShowS #

RandomGen Seed 
Instance details

Defined in Hedgehog.Internal.Seed

Methods

next :: Seed -> (Int, Seed) #

genRange :: Seed -> (Int, Int) #

split :: Seed -> (Seed, Seed) #

newtype Size #

Tests are parameterized by the size of the randomly-generated data, the meaning of which depends on the particular generator used.

Constructors

Size 

Fields

Instances
Enum Size 
Instance details

Defined in Hedgehog.Internal.Range

Methods

succ :: Size -> Size #

pred :: Size -> Size #

toEnum :: Int -> Size #

fromEnum :: Size -> Int #

enumFrom :: Size -> [Size] #

enumFromThen :: Size -> Size -> [Size] #

enumFromTo :: Size -> Size -> [Size] #

enumFromThenTo :: Size -> Size -> Size -> [Size] #

Eq Size 
Instance details

Defined in Hedgehog.Internal.Range

Methods

(==) :: Size -> Size -> Bool #

(/=) :: Size -> Size -> Bool #

Integral Size 
Instance details

Defined in Hedgehog.Internal.Range

Methods

quot :: Size -> Size -> Size #

rem :: Size -> Size -> Size #

div :: Size -> Size -> Size #

mod :: Size -> Size -> Size #

quotRem :: Size -> Size -> (Size, Size) #

divMod :: Size -> Size -> (Size, Size) #

toInteger :: Size -> Integer #

Num Size 
Instance details

Defined in Hedgehog.Internal.Range

Methods

(+) :: Size -> Size -> Size #

(-) :: Size -> Size -> Size #

(*) :: Size -> Size -> Size #

negate :: Size -> Size #

abs :: Size -> Size #

signum :: Size -> Size #

fromInteger :: Integer -> Size #

Ord Size 
Instance details

Defined in Hedgehog.Internal.Range

Methods

compare :: Size -> Size -> Ordering #

(<) :: Size -> Size -> Bool #

(<=) :: Size -> Size -> Bool #

(>) :: Size -> Size -> Bool #

(>=) :: Size -> Size -> Bool #

max :: Size -> Size -> Size #

min :: Size -> Size -> Size #

Read Size 
Instance details

Defined in Hedgehog.Internal.Range

Real Size 
Instance details

Defined in Hedgehog.Internal.Range

Methods

toRational :: Size -> Rational #

Show Size 
Instance details

Defined in Hedgehog.Internal.Range

Methods

showsPrec :: Int -> Size -> ShowS #

show :: Size -> String #

showList :: [Size] -> ShowS #

data Range a #

A range describes the bounds of a number to generate, which may or may not be dependent on a Size.

The constructor takes an origin between the lower and upper bound, and a function from Size to bounds. As the size goes towards 0, the values go towards the origin.

Instances
Functor Range 
Instance details

Defined in Hedgehog.Internal.Range

Methods

fmap :: (a -> b) -> Range a -> Range b #

(<$) :: a -> Range b -> Range a #

newtype Opaque a #

Opaque values.

Useful if you want to put something without a Show instance inside something which you'd like to be able to display.

For example:

  data State v =
    State {
        stateRefs :: [Var (Opaque (IORef Int)) v]
      } deriving (Eq, Show)

Constructors

Opaque 

Fields

Instances
Eq a => Eq (Opaque a) 
Instance details

Defined in Hedgehog.Internal.Opaque

Methods

(==) :: Opaque a -> Opaque a -> Bool #

(/=) :: Opaque a -> Opaque a -> Bool #

Ord a => Ord (Opaque a) 
Instance details

Defined in Hedgehog.Internal.Opaque

Methods

compare :: Opaque a -> Opaque a -> Ordering #

(<) :: Opaque a -> Opaque a -> Bool #

(<=) :: Opaque a -> Opaque a -> Bool #

(>) :: Opaque a -> Opaque a -> Bool #

(>=) :: Opaque a -> Opaque a -> Bool #

max :: Opaque a -> Opaque a -> Opaque a #

min :: Opaque a -> Opaque a -> Opaque a #

Show (Opaque a) 
Instance details

Defined in Hedgehog.Internal.Opaque

Methods

showsPrec :: Int -> Opaque a -> ShowS #

show :: Opaque a -> String #

showList :: [Opaque a] -> ShowS #

class HTraversable (t :: (Type -> Type) -> Type) where #

Higher-order traversable functors.

This is used internally to make symbolic variables concrete given an Environment.

Methods

htraverse :: Applicative f => (forall a. g a -> f (h a)) -> t g -> f (t h) #

Instances
HTraversable (Var a) 
Instance details

Defined in Hedgehog.Internal.State

Methods

htraverse :: Applicative f => (forall a0. g a0 -> f (h a0)) -> Var a g -> f (Var a h) #

distributeT :: (MonadTransDistributive g, Transformer f g m) => g (f m) a -> f (g m) a #

Distribute one monad transformer over another.

withResource #

Arguments

:: IO a

initialize the resource

-> (a -> IO ())

free the resource

-> (IO a -> TestTree)

IO a is an action which returns the acquired resource. Despite it being an IO action, the resource it returns will be acquired only once and shared across all the tests in the tree.

-> TestTree 

Acquire the resource to run this test (sub)tree and release it afterwards

askOption :: IsOption v => (v -> TestTree) -> TestTree #

Customize the test tree based on the run-time options

localOption :: IsOption v => v -> TestTree -> TestTree #

Locally set the option value for the given test subtree

adjustOption :: IsOption v => (v -> v) -> TestTree -> TestTree #

Locally adjust the option value for the given test subtree

defaultMain :: TestTree -> IO () #

Parse the command line arguments and run the tests.

When the tests finish, this function calls exitWith with the exit code that indicates whether any tests have failed. Most external systems (stack, cabal, travis-ci, jenkins etc.) rely on the exit code to detect whether the tests pass. If you want to do something else after defaultMain returns, you need to catch the exception and then re-throw it. Example:

import Test.Tasty
import Test.Tasty.HUnit
import System.Exit
import Control.Exception

test = testCase "Test 1" (2 @?= 3)

main = defaultMain test
  `catch` (\e -> do
    if e == ExitSuccess
      then putStrLn "Yea"
      else putStrLn "Nay"
    throwIO e)

defaultIngredients :: [Ingredient] #

List of the default ingredients. This is what defaultMain uses.

At the moment it consists of listingTests and consoleTestReporter.

defaultMainWithIngredients :: [Ingredient] -> TestTree -> IO () #

Parse the command line arguments and run the tests using the provided ingredient list.

When the tests finish, this function calls exitWith with the exit code that indicates whether any tests have failed. See defaultMain for details.

includingOptions :: [OptionDescription] -> Ingredient #

This ingredient doesn't do anything apart from registering additional options.

The option values can be accessed using askOption.

singleTest :: IsTest t => TestName -> t -> TestTree #

Convert a test to a leaf of the TestTree

foldTestTree #

Arguments

:: Monoid b 
=> TreeFold b

the algebra (i.e. how to fold a tree)

-> OptionSet

initial options

-> TestTree

the tree to fold

-> b 

Fold a test tree into a single value.

The fold result type should be a monoid. This is used to fold multiple results in a test group. In particular, empty groups get folded into mempty.

Apart from pure convenience, this function also does the following useful things:

  1. Keeping track of the current options (which may change due to PlusTestOptions nodes)
  2. Filtering out the tests which do not match the patterns

Thus, it is preferred to an explicit recursive traversal of the tree.

Note: right now, the patterns are looked up only once, and won't be affected by the subsequent option changes. This shouldn't be a problem in practice; OTOH, this behaviour may be changed later.

trivialFold :: Monoid b => TreeFold b #

trivialFold can serve as the basis for custom folds. Just override the fields you need.

Here's what it does:

  • single tests are mapped to mempty (you probably do want to override that)
  • test groups are returned unmodified
  • for a resource, an IO action that throws an exception is passed (you want to override this for runners/ingredients that execute tests)

after #

Arguments

:: DependencyType

whether to run the tests even if some of the dependencies fail

-> String

the pattern

-> TestTree

the subtree that depends on other tests

-> TestTree

the subtree annotated with dependency information

The after combinator declares dependencies between tests.

If a TestTree is wrapped in after, the tests in this tree will not run until certain other tests («dependencies») have finished. These dependencies are specified using an AWK pattern (see the «Patterns» section in the README).

Moreover, if the DependencyType argument is set to AllSucceed and at least one dependency has failed, this test tree will not run at all.

Tasty does not check that the pattern matches any tests (let alone the correct set of tests), so it is on you to supply the right pattern.

Examples

Expand

The following test will be executed only after all tests that contain Foo anywhere in their path finish.

after AllFinish "Foo" $
   testCase "A test that depends on Foo.Bar" $ ...

Note, however, that our test also happens to contain Foo as part of its name, so it also matches the pattern and becomes a dependency of itself. This will result in a DependencyLoop exception. To avoid this, either change the test name so that it doesn't mention Foo or make the pattern more specific.

You can use AWK patterns, for instance, to specify the full path to the dependency.

after AllFinish "$0 == \"Tests.Foo.Bar\"" $
   testCase "A test that depends on Foo.Bar" $ ...

Or only specify the dependency's own name, ignoring the group names:

after AllFinish "$NF == \"Bar\"" $
   testCase "A test that depends on Foo.Bar" $ ...

Since: tasty-1.2

after_ #

Arguments

:: DependencyType

whether to run the tests even if some of the dependencies fail

-> Expr

the pattern

-> TestTree

the subtree that depends on other tests

-> TestTree

the subtree annotated with dependency information

Like after, but accepts the pattern as a syntax tree instead of a string. Useful for generating a test tree programmatically.

Examples

Expand

Only match on the test's own name, ignoring the group names:

after_ AllFinish (EQ (Field NF) (StringLit "Bar")) $
   testCase "A test that depends on Foo.Bar" $ ...

Since: tasty-1.2

testGroup :: TestName -> [TestTree] -> TestTree #

Create a named group of test cases or other groups

type TestName = String #

The name of a test or a group of tests

data DependencyType #

These are the two ways in which one test may depend on the others.

This is the same distinction as the hard vs soft dependencies in TestNG.

Since: tasty-1.2

Constructors

AllSucceed

The current test tree will be executed after its dependencies finish, and only if all of the dependencies succeed.

AllFinish

The current test tree will be executed after its dependencies finish, regardless of whether they succeed or not.

data TestTree where #

The main data structure defining a test suite.

It consists of individual test cases and properties, organized in named groups which form a tree-like hierarchy.

There is no generic way to create a test case. Instead, every test provider (tasty-hunit, tasty-smallcheck etc.) provides a function to turn a test case into a TestTree.

Groups can be created using testGroup.

Constructors

SingleTest :: forall t. IsTest t => TestName -> t -> TestTree

A single test of some particular type

TestGroup :: forall. TestName -> [TestTree] -> TestTree

Assemble a number of tests into a cohesive group

PlusTestOptions :: forall. (OptionSet -> OptionSet) -> TestTree -> TestTree

Add some options to child tests

WithResource :: forall a. ResourceSpec a -> (IO a -> TestTree) -> TestTree

Acquire the resource before the tests in the inner tree start and release it after they finish. The tree gets an IO action which yields the resource, although the resource is shared across all the tests.

AskOptions :: forall. (OptionSet -> TestTree) -> TestTree

Ask for the options and customize the tests based on them

After :: forall. DependencyType -> Expr -> TestTree -> TestTree

Only run after all tests that match a given pattern finish (and, depending on the DependencyType, succeed)

foldSingle :: TreeFold b -> forall t. IsTest t => OptionSet -> TestName -> t -> b #

mkTimeout #

Arguments

:: Integer

microseconds

-> Timeout 

A shortcut for creating Timeout values

data Timeout #

Timeout to be applied to individual tests

Constructors

Timeout Integer String

String is the original representation of the timeout (such as "0.5m"), so that we can print it back. Integer is the number of microseconds.

NoTimeout 

safeReadBool :: String -> Maybe Bool #

Parse a Bool case-insensitively

safeRead :: Read a => String -> Maybe a #

Safe read function. Defined here for convenience to use for parseValue.

mkOptionCLParser :: IsOption v => Mod OptionFields v -> Parser v #

Command-line option parser that takes additional option modifiers.

mkFlagCLParser #

Arguments

:: IsOption v 
=> Mod FlagFields v

option modifier

-> v

non-default value (when the flag is supplied)

-> Parser v 

Command-line flag parser that takes additional option modifiers.

flagCLParser #

Arguments

:: IsOption v 
=> Maybe Char

optional short flag

-> v

non-default value (when the flag is supplied)

-> Parser v 

Command-line parser to use with flags

singleOption :: IsOption v => v -> OptionSet #

Create a singleton OptionSet

changeOption :: IsOption v => (v -> v) -> OptionSet -> OptionSet #

Change the option value

lookupOption :: IsOption v => OptionSet -> v #

Query the option value

setOption :: IsOption v => v -> OptionSet -> OptionSet #

Set the option value

class Typeable v => IsOption v where #

An option is a data type that inhabits the IsOption type class.

Minimal complete definition

defaultValue, parseValue, optionName, optionHelp

Methods

defaultValue :: v #

The value to use if the option was not supplied explicitly

parseValue :: String -> Maybe v #

Try to parse an option value from a string. Consider using safeReadBool for boolean options and safeRead for numeric options.

optionName :: Tagged v String #

The option name. It is used to form the command line option name, for instance. Therefore, it had better not contain spaces or other fancy characters. It is recommended to use dashes instead of spaces.

optionHelp :: Tagged v String #

The option description or help string. This can be an arbitrary string.

optionCLParser :: Parser v #

A command-line option parser.

It has a default implementation in terms of the other methods. You may want to override it in some cases (e.g. add a short flag) and flagCLParser, mkFlagCLParser and mkOptionCLParser might come in handy.

Even if you override this, you still should implement all the methods above, to allow alternative interfaces.

Do not supply a default value here for this parser! This is because if no value was provided on the command line we may lookup the option e.g. in the environment. But if the parser always succeeds, we have no way to tell whether the user really provided the option on the command line.

Instances
IsOption NumThreads 
Instance details

Defined in Test.Tasty.Options.Core

IsOption Timeout 
Instance details

Defined in Test.Tasty.Options.Core

IsOption HedgehogReplay 
Instance details

Defined in Test.Tasty.Hedgehog

IsOption HedgehogShowReplay 
Instance details

Defined in Test.Tasty.Hedgehog

IsOption HedgehogTestLimit 
Instance details

Defined in Test.Tasty.Hedgehog

IsOption HedgehogDiscardLimit 
Instance details

Defined in Test.Tasty.Hedgehog

IsOption HedgehogShrinkLimit 
Instance details

Defined in Test.Tasty.Hedgehog

IsOption HedgehogShrinkRetries 
Instance details

Defined in Test.Tasty.Hedgehog

data OptionSet #

A set of options. Only one option of each type can be kept.

If some option has not been explicitly set, the default value is used.

Instances
Semigroup OptionSet 
Instance details

Defined in Test.Tasty.Options

Monoid OptionSet

Later options override earlier ones

Instance details

Defined in Test.Tasty.Options

data OptionDescription where #

The purpose of this data type is to capture the dictionary corresponding to a particular option.

Constructors

Option :: forall v. IsOption v => Proxy v -> OptionDescription 

testProperty :: TestName -> Property -> TestTree #

Create a Test from a Hedgehog property

newtype HedgehogReplay #

The replay token to use for replaying a previous test run

Constructors

HedgehogReplay (Maybe (Size, Seed)) 

gotException :: forall a. (HasCallStack, Show a) => a -> PropertyT IO () Source #

Assert that an exception is thrown

groupByModuleName :: TestTree -> TestTree Source #

This allows the discovery of Hedgehog properties and their grouping by module name in the test report. Extract the ModuleName option value for a given test and group all the tests with that option into the same test group

minTestsOk :: Int -> TestTree -> TestTree Source #

Set a mininum number of tests to be successful on a property

mustBe :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m () Source #

An equality assertion which does not try to do a smart diffs for cases where the output is too large.

noShrink :: TestTree -> TestTree Source #

Don't shrink failures

prop :: HasCallStack => TestName -> PropertyT IO () -> TestTree Source #

Create a Tasty test from a Hedgehog property

run :: Runnable t => t -> IO () Source #

Run either a test tree (a test or a property) whether it is in IO or not

runOnly :: Runnable t => Text -> t -> IO () Source #

Run only some tests by passing a tasty pattern

test :: HasCallStack => TestName -> PropertyT IO () -> TestTree Source #

Create a Tasty test from a Hedgehog property called only once

withSeed :: String -> TestTree -> TestTree Source #

Run a property with a specify seed. You can copy and paste the exact string which Hedgehog outputs when there is a failure

(===) :: (MonadTest m, Eq a, Show a, HasCallStack) => a -> a -> m () infix 4 Source #

Redefinition of Hedgehog's === operator to add better source file information

It adds a link to the source file which is conforms to output of GHC.Exception. See makeSourceLink It also displays the actual and expected values in a compact form before the pretty-printed form provided by Hedgehog

Orphan instances

Ord k => Semigroup (MultiMap k v) Source # 
Instance details

Methods

(<>) :: MultiMap k v -> MultiMap k v -> MultiMap k v #

sconcat :: NonEmpty (MultiMap k v) -> MultiMap k v #

stimes :: Integral b => b -> MultiMap k v -> MultiMap k v #

Ord k => Monoid (MultiMap k v) Source # 
Instance details

Methods

mempty :: MultiMap k v #

mappend :: MultiMap k v -> MultiMap k v -> MultiMap k v #

mconcat :: [MultiMap k v] -> MultiMap k v #