packages feed

quickcheck-dynamic 3.4.1 → 3.4.2

raw patch · 7 files changed

+35/−28 lines, 7 filesnew-uploaderPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -9,6 +9,10 @@  ## UNRELEASED +## 3.4.2 - 2025-07-14++* Added support for `Quickcheck-2.16`.+ ## 3.4.1 - 2024-03-22  * [#70](https://github.com/input-output-hk/quickcheck-dynamic/pull/70) Expose `IsPerformResult` typeclass
quickcheck-dynamic.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.2 name:               quickcheck-dynamic-version:            3.4.1+version:            3.4.2 license:            Apache-2.0 license-files:   LICENSE
src/Test/QuickCheck/DynamicLogic/Internal.hs view
@@ -4,7 +4,8 @@ import Control.Arrow (second) import Control.Monad import Data.Typeable-import Test.QuickCheck hiding (generate)+import Test.QuickCheck (Gen, Property, Testable)+import Test.QuickCheck qualified as QC import Test.QuickCheck.DynamicLogic.CanGenerate import Test.QuickCheck.DynamicLogic.Quantify import Test.QuickCheck.DynamicLogic.SmartShrinking@@ -360,8 +361,8 @@     let d = unDynFormula f sz         n = unsafeNextVarIndex $ vars s      in case generate chooseUniqueNextStep d n s 500 of-          Nothing -> counterexample "Generating Non-unique script in forAllUniqueScripts" False-          Just test -> validDLTest d test . applyMonitoring d test . property $ k (scriptFromDL test)+          Nothing -> QC.counterexample "Generating Non-unique script in forAllUniqueScripts" False+          Just test -> validDLTest d test . applyMonitoring d test . QC.property $ k (scriptFromDL test)  -- | Creates a `Property` from `DynFormula` with some specialised isomorphism for shrinking purpose. forAllMappedScripts@@ -374,22 +375,22 @@ forAllMappedScripts to from f k =   QC.withSize $ \n ->     let d = unDynFormula f n-     in forAllShrinkBlind-          (Smart 0 <$> sized ((from <$>) . generateDLTest d))+     in QC.forAllShrinkBlind+          (QC.Smart 0 <$> QC.sized ((from <$>) . generateDLTest d))           (shrinkSmart ((from <$>) . shrinkDLTest d . to))-          $ \(Smart _ script) ->+          $ \(QC.Smart _ script) ->             withDLScript d k (to script)  withDLScript :: (DynLogicModel s, Testable a) => DynLogic s -> (Actions s -> a) -> DynLogicTest s -> Property withDLScript d k test =-  validDLTest d test . applyMonitoring d test . property $ k (scriptFromDL test)+  validDLTest d test . applyMonitoring d test . QC.property $ k (scriptFromDL test)  withDLScriptPrefix :: (DynLogicModel s, Testable a) => DynFormula s -> (Actions s -> a) -> DynLogicTest s -> Property withDLScriptPrefix f k test =   QC.withSize $ \n ->     let d = unDynFormula f n         test' = unfailDLTest d test-     in validDLTest d test' . applyMonitoring d test' . property $ k (scriptFromDL test')+     in validDLTest d test' . applyMonitoring d test' . QC.property $ k (scriptFromDL test')  generateDLTest :: DynLogicModel s => DynLogic s -> Int -> Gen (DynLogicTest s) generateDLTest d size = generate chooseNextStep d 0 (initialStateFor d) size@@ -502,7 +503,7 @@ nextSteps' gen (Monitor _f d) = nextSteps' gen d  chooseOneOf :: [(Double, a)] -> Gen a-chooseOneOf steps = frequency [(round (w / never), return s) | (w, s) <- steps]+chooseOneOf steps = QC.frequency [(round (w / never), return s) | (w, s) <- steps]  never :: Double never = 1.0e-9@@ -572,7 +573,7 @@ keepTryingUntil 0 _ _ = return Nothing keepTryingUntil n g p = do   x <- g-  if p x then return $ Just x else scale (+ 1) $ keepTryingUntil (n - 1) g p+  if p x then return $ Just x else QC.scale (+ 1) $ keepTryingUntil (n - 1) g p  shrinkDLTest :: DynLogicModel s => DynLogic s -> DynLogicTest s -> [DynLogicTest s] shrinkDLTest _ (Looping _) = []@@ -696,7 +697,7 @@  propPruningGeneratedScriptIsNoop :: DynLogicModel s => DynLogic s -> Property propPruningGeneratedScriptIsNoop d =-  forAll (sized $ \n -> choose (1, max 1 n) >>= generateDLTest d) $ \test ->+  QC.forAll (QC.sized $ \n -> QC.choose (1, max 1 n) >>= generateDLTest d) $ \test ->     let script = case test of           BadPrecondition s _ _ -> s           Looping s -> s@@ -764,9 +765,9 @@ stuck (Monitor _ d) s = stuck d s  validDLTest :: StateModel s => DynLogic s -> DynLogicTest s -> Property -> Property-validDLTest _ Stuck{} _ = False ==> False-validDLTest _ test@DLScript{} p = counterexample (show test) p-validDLTest _ test _ = counterexample (show test) False+validDLTest _ Stuck{} _ = False QC.==> False+validDLTest _ test@DLScript{} p = QC.counterexample (show test) p+validDLTest _ test _ = QC.counterexample (show test) False  scriptFromDL :: DynLogicTest s -> Actions s scriptFromDL (DLScript s) = Actions $ sequenceSteps s
src/Test/QuickCheck/StateModel.hs view
@@ -52,7 +52,8 @@ import Data.Set qualified as Set import Data.Void import GHC.Generics-import Test.QuickCheck as QC+import Test.QuickCheck (Arbitrary, Gen, Property, Smart (..), counterexample, frequency, resize, shrinkList, sized, tabulate)+import Test.QuickCheck qualified as QC import Test.QuickCheck.DynamicLogic.SmartShrinking import Test.QuickCheck.Monadic import Test.QuickCheck.StateModel.Variables
src/Test/QuickCheck/StateModel/Variables.hs view
@@ -31,7 +31,7 @@ import GHC.Generics import GHC.TypeLits import GHC.Word-import Test.QuickCheck as QC+import Test.QuickCheck (Gen, Smart (..), elements)  -- | A symbolic variable for a value of type `a` newtype Var a = Var Int
test/Spec/DynamicLogic/Counters.hs view
@@ -6,7 +6,7 @@  import Control.Monad.Reader import Data.IORef-import Test.QuickCheck+import Test.QuickCheck (frequency) import Test.QuickCheck.StateModel  -- A very simple model with a single action that always succeed in
test/Spec/DynamicLogic/RegistryModel.hs view
@@ -10,7 +10,8 @@ import Data.List import Data.Map (Map) import Data.Map qualified as Map-import Test.QuickCheck+import Test.QuickCheck (Gen, Property)+import Test.QuickCheck qualified as QC import Test.QuickCheck.Monadic hiding (assert) import Test.QuickCheck.Monadic qualified as QC import Test.Tasty hiding (after)@@ -57,7 +58,7 @@   validFailingAction _ _ = True    arbitraryAction ctx s =-    frequency $+    QC.frequency $       [         ( max 1 $ 10 - length (ctxAtType @ThreadId ctx)         , return $ Some Spawn@@ -134,15 +135,15 @@    postconditionOnFailure (s, _) act@Register{} _ res = do     monitorPost $-      tabulate+      QC.tabulate         "Reason for -Register"         [why s act]     pure $ isLeft res   postconditionOnFailure _s _ _ _ = pure True    monitoring (_s, s') act@(showDictAction -> ShowDict) _ res =-    counterexample (show res ++ " <- " ++ show act ++ "\n  -- State: " ++ show s')-      . tabulate "Registry size" [show $ Map.size (regs s')]+    QC.counterexample (show res ++ " <- " ++ show act ++ "\n  -- State: " ++ show s')+      . QC.tabulate "Registry size" [show $ Map.size (regs s')]  data ShowDict a where   ShowDict :: Show (Realized RegM a) => ShowDict a@@ -166,13 +167,13 @@ why _ _ = "(impossible)"  arbitraryName :: Gen String-arbitraryName = elements allNames+arbitraryName = QC.elements allNames  probablyRegistered :: RegState -> Gen String-probablyRegistered s = oneof $ map pure (Map.keys $ regs s) ++ [arbitraryName]+probablyRegistered s = QC.oneof $ map pure (Map.keys $ regs s) ++ [arbitraryName]  probablyUnregistered :: RegState -> Gen String-probablyUnregistered s = elements $ allNames ++ (allNames \\ Map.keys (regs s))+probablyUnregistered s = QC.elements $ allNames ++ (allNames \\ Map.keys (regs s))  shrinkName :: String -> [String] shrinkName name = [n | n <- allNames, n < name]@@ -183,7 +184,7 @@ prop_Registry :: Actions RegState -> Property prop_Registry s =   monadicIO $ do-    monitor $ counterexample "\nExecution\n"+    monitor $ QC.counterexample "\nExecution\n"     reg <- lift setupRegistry     runPropertyReaderT (runActions s) reg     QC.assert True@@ -268,5 +269,5 @@     "registry model example"     [ testProperty "prop_Registry" $ prop_Registry     , testProperty "canRegister" $ propDL canRegister-    , testProperty "canRegisterNoUnregister" $ expectFailure $ propDL canRegisterNoUnregister+    , testProperty "canRegisterNoUnregister" $ QC.expectFailure $ propDL canRegisterNoUnregister     ]