packages feed

sydtest-hedgehog 0.2.0.0 → 0.3.0.0

raw patch · 4 files changed

+47/−16 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Test.Syd.Hedgehog: instance Test.Syd.Run.IsTest (arg -> Hedgehog.Internal.Property.Property)
+ Test.Syd.Hedgehog: instance Test.Syd.Run.IsTest (outerArgs -> innerArg -> Hedgehog.Internal.Property.Property)

Files

CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## [0.3.0.0] - 2022-05-10++### Added++* `IsTest` instances for properties with args+ ## [0.2.0.0] - 2022-04-28  ### Added
src/Test/Syd/Hedgehog.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE DataKinds #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-}@@ -32,26 +33,31 @@ instance IsTest Hedgehog.Property where   type Arg1 Hedgehog.Property = ()   type Arg2 Hedgehog.Property = ()-  runTest = runHedgehogProperty+  runTest func = runHedgehogPropertyWithArg (\() () -> func) -runHedgehogProperty ::-  Hedgehog.Property ->-  Syd.TestRunSettings ->-  Syd.ProgressReporter ->-  ((() -> () -> IO ()) -> IO ()) ->+instance IsTest (arg -> Hedgehog.Property) where+  type Arg1 (arg -> Hedgehog.Property) = ()+  type Arg2 (arg -> Hedgehog.Property) = arg+  runTest func = runHedgehogPropertyWithArg (\() a -> func a)++instance IsTest (outerArgs -> innerArg -> Hedgehog.Property) where+  type Arg1 (outerArgs -> innerArg -> Hedgehog.Property) = outerArgs+  type Arg2 (outerArgs -> innerArg -> Hedgehog.Property) = innerArg+  runTest = runHedgehogPropertyWithArg++runHedgehogPropertyWithArg ::+  forall outerArgs innerArg.+  (outerArgs -> innerArg -> Hedgehog.Property) ->+  TestRunSettings ->+  ProgressReporter ->+  ((outerArgs -> innerArg -> IO ()) -> IO ()) ->   IO TestRunResult-runHedgehogProperty+runHedgehogPropertyWithArg   hedgehogProp   TestRunSettings {..}   progressReporter   wrapper = do     let report = reportProgress progressReporter-    let config =-          (Hedgehog.propertyConfig hedgehogProp)-            { Hedgehog.propertyDiscardLimit = Hedgehog.DiscardLimit testRunSettingMaxDiscardRatio,-              Hedgehog.propertyShrinkLimit = Hedgehog.ShrinkLimit testRunSettingMaxShrinks,-              Hedgehog.propertyTerminationCriteria = Hedgehog.NoConfidenceTermination $ Hedgehog.TestLimit testRunSettingMaxSuccess-            }     let size = Hedgehog.Size testRunSettingMaxSize     seed <- case testRunSettingSeed of       RandomSeed -> Seed.random@@ -65,7 +71,14 @@     -- we can attach timing information.     -- In the case of hedgehog, non-property tests should be rarer so that     -- should matter even less.-    errOrReport <- applyWrapper2 wrapper $ \() () ->+    errOrReport <- applyWrapper2 wrapper $ \outer inner -> do+      let config =+            (Hedgehog.propertyConfig (hedgehogProp outer inner))+              { Hedgehog.propertyDiscardLimit = Hedgehog.DiscardLimit testRunSettingMaxDiscardRatio,+                Hedgehog.propertyShrinkLimit = Hedgehog.ShrinkLimit testRunSettingMaxShrinks,+                Hedgehog.propertyTerminationCriteria = Hedgehog.NoConfidenceTermination $ Hedgehog.TestLimit testRunSettingMaxSuccess+              }+       Hedgehog.checkReport         config         size@@ -73,7 +86,7 @@         ( do             exampleNr <- liftIO $ readTVarIO exampleCounter             liftIO $ report $ ProgressExampleStarting totalExamples exampleNr-            timedResult <- timeItT $ Hedgehog.propertyTest hedgehogProp+            timedResult <- timeItT $ Hedgehog.propertyTest (hedgehogProp outer inner)             liftIO $ report $ ProgressExampleDone totalExamples exampleNr $ timedTime timedResult             liftIO $ atomically $ modifyTVar' exampleCounter succ             pure $ timedValue timedResult
sydtest-hedgehog.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           sydtest-hedgehog-version:        0.2.0.0+version:        0.3.0.0 synopsis:       A Hedgehog companion library for sydtest category:       Testing homepage:       https://github.com/NorfairKing/sydtest#readme
test/Test/Syd/HedgehogSpec.hs view
@@ -16,6 +16,18 @@       property $ do         xs <- forAll $ Gen.list (Range.linear 0 100) Gen.alpha         reverse (reverse xs) === xs+  setupAroundWith (const (pure 0)) $+    describe "reverse with setup" $ do+      specify "reversing twice is the same as not reversing" $ \i ->+        property $ do+          xs <- forAll $ Gen.list (Range.linear i 100) Gen.alpha+          reverse (reverse xs) === xs+  beforeAll (pure (1 :: Int)) $ do+    describe "reverse with beforeAll" $ do+      specifyWithBoth "reversing twice is the same as not reversing" $ \i () ->+        property $ do+          xs <- forAll $ Gen.list (Range.linear i 100) Gen.alpha+          reverse (reverse xs) === xs  exampleHedgehogGroup :: Hedgehog.Group exampleHedgehogGroup =