Copyright | (c) 2023 Nicolas Trangez |
---|---|
License | Apache-2.0 |
Maintainer | ikke@nicolast.be |
Stability | alpha |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Support code to check lawful-classes
laws using QuickCheck and,
optionally, Tasty.
Synopsis
- testLaws :: TestName -> (forall a. m a -> PropertyM IO a) -> Laws m -> TestTree
- testLawsWith :: (Property -> Property) -> TestName -> (forall a. m a -> PropertyM IO a) -> Laws m -> TestTree
- forAll :: (MonadTrans t, Monad m, Show a) => Gen a -> t (PropertyM m) a
- forAllShow :: (MonadTrans t, Monad m) => (a -> String) -> Gen a -> t (PropertyM m) a
- toProperty :: (forall a. m a -> PropertyM IO a) -> Law m -> Property
Tasty integration
testLawsWith :: (Property -> Property) -> TestName -> (forall a. m a -> PropertyM IO a) -> Laws m -> TestTree Source #
Given Laws
for m
and a way to evaluate an m a
in
,
create a PropertyT
IOtasty
TestTree
, modifying all created Property
s with the
given function.
As an example, once
could be used to run every test only
once, 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
forAllShow :: (MonadTrans t, Monad m) => (a -> String) -> Gen a -> t (PropertyM m) a Source #
Like forAll
, but for types without a Show
instance (or, for which
another stringification functions but show
should be used).
Like forAllShow
, but in a monadic context.
This can be used to earily create generators for laws which need them.
Note: like forAll
, values generated by forAllShow
do not shrink.