packages feed

QuickCheck 2.13 → 2.13.1

raw patch · 5 files changed

+67/−15 lines, 5 filesdep ~basePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base

API changes (from Hackage documentation)

- Test.QuickCheck: propertyForAllShrinkShow :: (Testable prop, Show a) => Gen a -> (a -> [a]) -> (a -> String) -> (a -> prop) -> Property
+ Test.QuickCheck: propertyForAllShrinkShow :: Testable prop => Gen a -> (a -> [a]) -> (a -> [String]) -> (a -> prop) -> Property

Files

QuickCheck.cabal view
@@ -1,5 +1,5 @@ Name: QuickCheck-Version: 2.13+Version: 2.13.1 Cabal-Version: >= 1.8 Build-type: Simple License: BSD3@@ -56,7 +56,7 @@ source-repository this   type:     git   location: https://github.com/nick8325/quickcheck-  tag:      2.13+  tag:      2.13.1  flag templateHaskell   Description: Build Test.QuickCheck.All, which uses Template Haskell.@@ -199,3 +199,11 @@     hs-source-dirs: tests     main-is: Split.hs     build-depends: base, QuickCheck++Test-Suite test-quickcheck-misc+    type: exitcode-stdio-1.0+    hs-source-dirs: tests+    main-is: Misc.hs+    build-depends: base, QuickCheck+    if !flag(templateHaskell) || !impl(ghc >= 7.10)+        buildable: False
README view
@@ -7,7 +7,7 @@ The quickcheck-instances [1] companion package provides instances for types in Haskell Platform packages at the cost of additional dependencies. -[1]: http://hackage.haskell.org/package/quickcheck-instances--The make-hugs scripts makes a Hugs-compatible version of QuickCheck.+The make-hugs script makes a Hugs-compatible version of QuickCheck. It may also be useful for other non-GHC implementations.++[1]: http://hackage.haskell.org/package/quickcheck-instances
Test/QuickCheck/Property.hs view
@@ -95,13 +95,14 @@   property :: prop -> Property    -- | Optional; used internally in order to improve shrinking.-  -- @propertyForAll gen shr shw f@ is normally equivalent to-  -- @'forAllShrinkShow' gen shr shw f@.+  -- Tests a property but also quantifies over an extra value+  -- (with a custom shrink and show function).   -- The 'Testable' instance for functions defines-  -- @propertyForAll@ in a way that improves shrinking.-  propertyForAllShrinkShow :: Show a => Gen a -> (a -> [a]) -> (a -> String) -> (a -> prop) -> Property-  propertyForAllShrinkShow gen shr f =-    forAllShrinkShow gen shr f+  -- @propertyForAllShrinkShow@ in a way that improves shrinking.+  propertyForAllShrinkShow :: Gen a -> (a -> [a]) -> (a -> [String]) -> (a -> prop) -> Property+  propertyForAllShrinkShow gen shr shw f =+    forAllShrinkBlind gen shr $+      \x -> foldr counterexample (property (f x)) (shw x)  -- | If a property returns 'Discard', the current test case is discarded, -- the same as if a precondition was false.@@ -138,13 +139,13 @@   property = MkProperty . return . MkProp . protectResults . return  instance Testable Prop where-  property (MkProp r) = MkProperty . return . MkProp . ioRose . return $ r+  property p = MkProperty . return . protectProp $ p  instance Testable prop => Testable (Gen prop) where   property mp = MkProperty $ do p <- mp; unProperty (again p)  instance Testable Property where-  property (MkProperty mp) = MkProperty $ do p <- mp; unProperty (property p)+  property (MkProperty mp) = MkProperty (fmap protectProp mp)  -- | Do I/O inside a property. {-# DEPRECATED morallyDubiousIOProperty "Use 'ioProperty' instead" #-}@@ -174,14 +175,14 @@  instance (Arbitrary a, Show a, Testable prop) => Testable (a -> prop) where   property f =-    propertyForAllShrinkShow arbitrary shrink show f+    propertyForAllShrinkShow arbitrary shrink (return . show) f   propertyForAllShrinkShow gen shr shw f =     -- gen :: Gen b, shr :: b -> [b], f :: b -> a -> prop     -- Idea: Generate and shrink (b, a) as a pair     propertyForAllShrinkShow       (liftM2 (,) gen arbitrary)       (liftShrink2 shr shrink)-      (\(x, y) -> shw x ++ "\n" ++ show y)+      (\(x, y) -> shw x ++ [show y])       (uncurry f)  -- ** Exception handling@@ -241,6 +242,10 @@ protectRose :: IO (Rose Result) -> IO (Rose Result) protectRose = protect (return . exception "Exception") +-- | Wrap the top level of a 'Prop' in an exception handler.+protectProp :: Prop -> Prop+protectProp (MkProp r) = MkProp (IORose . protectRose . return $ r)+ -- | Wrap all the Results in a rose tree in exception handlers. protectResults :: Rose Result -> Rose Result protectResults = onRose $ \x rs ->@@ -754,6 +759,16 @@  -- | Considers a property failed if it does not complete within -- the given number of microseconds.+--+-- Note: if the property times out, variables quantified inside the+-- `within` will not be printed. Therefore, you should use `within`+-- only in the body of your property.+--+-- Good: @prop_foo a b c = within 1000000 ...@+--+-- Bad: @prop_foo = within 1000000 $ \\a b c -> ...@+--+-- Bad: @prop_foo a b c = ...; main = quickCheck (within 1000000 prop_foo)@ within :: Testable prop => Int -> prop -> Property within n = mapRoseResult f   where
changelog view
@@ -1,3 +1,6 @@+QuickCheck 2.13.1 (release 2019-03-29)+	* A couple of bug fixes+ QuickCheck 2.13 (released 2019-03-26) 	* Properties with multiple arguments now shrink better. 	  Previously, the first argument was shrunk, then the second, and
+ tests/Misc.hs view
@@ -0,0 +1,26 @@+-- Miscellaneous tests.++{-# LANGUAGE TemplateHaskell #-}+import Test.QuickCheck+import Test.QuickCheck.Random++prop_verbose :: Blind (Int -> Int -> Bool) -> Property+prop_verbose (Blind p) =+  forAll (mkQCGen <$> arbitrary) $ \g ->+  ioProperty $ do+    res1 <- quickCheckWithResult stdArgs{replay = Just (g, 100), chatty = False} p+    res2 <- quickCheckWithResult stdArgs{replay = Just (g, 100), chatty = False} (verbose p)+    return $+      numTests res1 === numTests res2 .&&.+      failingTestCase res1 === failingTestCase res2++prop_failingTestCase :: Blind (Int -> Int -> Int -> Bool) -> Property+prop_failingTestCase (Blind p) = ioProperty $ do+  res <- quickCheckWithResult stdArgs{chatty = False} p+  let [x, y, z] = failingTestCase res+  return (not (p (read x) (read y) (read z)))++return []+main = do+  True <- $quickCheckAll+  return ()