packages feed

lawful-classes-quickcheck 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.QuickCheck: testLawsWith :: (Property -> Property) -> TestName -> (forall a. m a -> PropertyM IO a) -> Laws m -> TestTree

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for lawful-classes-quickcheck +## 0.1.1.0 -- 2023-02-01++* Add `Test.Lawful.QuickCheck.testLawsWith`.+ ## 0.1.0.0 -- 2023-02-01  * First version. Released on an unsuspecting world.
lawful-classes-quickcheck.cabal view
@@ -1,6 +1,6 @@ cabal-version:   3.0 name:            lawful-classes-quickcheck-version:         0.1.0.0+version:         0.1.1.0 synopsis:        QuickCheck support for lawful-classes description:   Support code to check @lawful-classes@ laws using QuickCheck and,
src/Test/Lawful/QuickCheck.hs view
@@ -11,7 +11,11 @@ -- Support code to check @lawful-classes@ laws using QuickCheck and, -- optionally, Tasty. module Test.Lawful.QuickCheck-  ( testLaws,+  ( -- * Tasty integration+    testLaws,+    testLawsWith,++    -- * Plumbing     toProperty,   ) where@@ -26,6 +30,20 @@ toProperty :: (forall a. m a -> PropertyM IO a) -> Law m -> Property toProperty run law = monadicIO $ maybe discard assert =<< run law --- | Given 'Laws', create a @tasty@ 'TestTree'.+-- | Given 'Laws' for @m@ and a way to evaluate an @m a@ in @'PropertyM' IO@,+-- create a @tasty@ 'TestTree'. testLaws :: TestName -> (forall a. m a -> PropertyM 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, 'Test.QuickCheck.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+testLawsWith :: (Property -> Property) -> TestName -> (forall a. m a -> PropertyM IO a) -> Laws m -> TestTree+testLawsWith fn name run laws = testGroup name [testProperty n (fn $ toProperty run l) | (n, l) <- laws]