lawful-classes-hedgehog 0.1.0.0 → 0.1.1.0
raw patch · 3 files changed
+26/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Test.Lawful.Hedgehog: testLawsWith :: (Property -> Property) -> TestName -> (forall a. m a -> PropertyT IO a) -> Laws m -> TestTree
Files
- CHANGELOG.md +4/−0
- lawful-classes-hedgehog.cabal +1/−1
- src/Test/Lawful/Hedgehog.hs +21/−3
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for lawful-classes-hedgehog +## 0.1.1.0 -- 2023-02-01++* Add `Test.Lawful.Hedgehog.testLawsWith`.+ ## 0.1.0.0 -- 2023-02-01 * First version. Released on an unsuspecting world.
lawful-classes-hedgehog.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: lawful-classes-hedgehog-version: 0.1.0.0+version: 0.1.1.0 synopsis: Hedgehog support for lawful-classes description: Support code to check @lawful-classes@ laws using Hedgehog and,
src/Test/Lawful/Hedgehog.hs view
@@ -11,7 +11,11 @@ -- Support code to check @lawful-classes@ laws using Hedgehog and, optionally, -- Tasty. module Test.Lawful.Hedgehog- ( testLaws,+ ( -- * Tasty integration+ testLaws,+ testLawsWith,++ -- * Plumbing toProperty, ) where@@ -25,6 +29,20 @@ toProperty :: (forall a. m a -> PropertyT IO a) -> Law m -> Property toProperty run law = property $ maybe discard assert =<< evalM (run law) --- | Given 'Laws', create a @tasty@ 'TestTree'.+-- | Given 'Laws' for @m@ and a way to evaluate an @m a@ in @'PropertyT' IO@,+-- create a @tasty@ 'TestTree'. testLaws :: TestName -> (forall a. m a -> PropertyT IO a) -> Laws m -> TestTree-testLaws name run laws = testGroup name [testProperty n (toProperty run l) | (n, l) <- laws]+testLaws = testLawsWith id++-- | Given 'Laws' for @m@ and a way to evaluate an @m a@ in @'PropertyT' IO@,+-- create a @tasty@ 'TestTree', modifying all created 'Property's with the+-- given function.+--+-- As an example, 'Hedgehog.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+testLawsWith :: (Property -> Property) -> TestName -> (forall a. m a -> PropertyT IO a) -> Laws m -> TestTree+testLawsWith fn name run laws = testGroup name [testProperty n (fn $ toProperty run l) | (n, l) <- laws]