lawful-classes-hedgehog-0.1.2.1: Hedgehog support for lawful-classes
Copyright(c) 2023 Nicolas Trangez
LicenseApache-2.0
Maintainerikke@nicolast.be
Stabilityalpha
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Lawful.Hedgehog

Description

Support code to check lawful-classes laws using Hedgehog and, optionally, Tasty.

Synopsis

Tasty integration

testLaws :: TestName -> (forall a. m a -> PropertyT IO a) -> Laws m -> TestTree Source #

Given Laws for m and a way to evaluate an m a in PropertyT IO, create a tasty TestTree.

testLawsWith :: (Property -> Property) -> TestName -> (forall a. m a -> PropertyT IO a) -> Laws m -> TestTree Source #

Given Laws for m and a way to evaluate an m a in PropertyT IO, create a tasty TestTree, modifying all created Propertys with the given function.

As an example, withTests could be used to reduce or increase the number of times tests are executed, e.g., because m is not a transformer so there's no way to generate multiple test exemplars using some generator, except for the trivial constant generator.

Since: 0.1.1.0

Utilities

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

Lifted version of forAll.

This can be used to easily create generators for laws which need them.

Since: 0.1.2.0

forAllShow :: (MonadTrans t, Monad m, HasCallStack) => (a -> String) -> Gen a -> t (PropertyT m) a Source #

Lifted version of forAllWith.

Like forAll, but for types without a Show instance (or, for which another stringification functions but show should be used).

This can be used to earily create generators for laws which need them.

Since: 0.1.2.0

Plumbing

toProperty :: (forall a. m a -> PropertyT IO a) -> Law m -> Property Source #

Given a way to evaluate an m a into a base Monad, turn a Law into a Property.