QuickCheck 2.9.1 → 2.9.2
raw patch · 7 files changed
+35/−36 lines, 7 filesdep ~QuickCheckPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: QuickCheck
API changes (from Hackage documentation)
- Test.QuickCheck: shrinkRealFracToInteger :: RealFrac a => a -> [a]
- Test.QuickCheck.Arbitrary: shrinkRealFracToInteger :: RealFrac a => a -> [a]
+ Test.QuickCheck.Gen: chooseAny :: Random a => Gen a
Files
- QuickCheck.cabal +6/−6
- Test/QuickCheck.hs +0/−1
- Test/QuickCheck/Arbitrary.hs +16/−18
- Test/QuickCheck/Gen.hs +5/−0
- Test/QuickCheck/Property.hs +1/−11
- Test/QuickCheck/Test.hs +2/−0
- changelog +5/−0
QuickCheck.cabal view
@@ -1,5 +1,5 @@ Name: QuickCheck-Version: 2.9.1+Version: 2.9.2 Cabal-Version: >= 1.8 Build-type: Simple License: BSD3@@ -37,7 +37,7 @@ source-repository this type: git location: https://github.com/nick8325/quickcheck- tag: 2.9.1+ tag: 2.9.2 flag templateHaskell Description: Build Test.QuickCheck.All, which uses Template Haskell.@@ -134,7 +134,7 @@ build-depends: base, containers,- QuickCheck == 2.9.1,+ QuickCheck == 2.9.2, template-haskell >= 2.4, test-framework >= 0.4 && < 0.9 if flag(templateHaskell)@@ -146,7 +146,7 @@ type: exitcode-stdio-1.0 hs-source-dirs: tests main-is: GCoArbitraryExample.hs- build-depends: base, QuickCheck == 2.9.1+ build-depends: base, QuickCheck == 2.9.2 if impl(ghc < 7.2) buildable: False if impl(ghc >= 7.2) && impl(ghc < 7.6)@@ -156,7 +156,7 @@ type: exitcode-stdio-1.0 hs-source-dirs: tests main-is: Generators.hs- build-depends: base, QuickCheck == 2.9.1+ build-depends: base, QuickCheck == 2.9.2 if !flag(templateHaskell) Buildable: False @@ -164,7 +164,7 @@ type: exitcode-stdio-1.0 hs-source-dirs: tests main-is: GShrinkExample.hs- build-depends: base, QuickCheck == 2.9.1+ build-depends: base, QuickCheck == 2.9.2 if impl(ghc < 7.2) buildable: False if impl(ghc >= 7.2) && impl(ghc < 7.6)
Test/QuickCheck.hs view
@@ -146,7 +146,6 @@ , shrinkList , shrinkIntegral , shrinkRealFrac- , shrinkRealFracToInteger -- ** Helper functions for implementing coarbitrary , variant , coarbitraryIntegral
Test/QuickCheck/Arbitrary.hs view
@@ -36,7 +36,6 @@ , shrinkList -- :: (a -> [a]) -> [a] -> [[a]] , shrinkIntegral -- :: Integral a => a -> [a] , shrinkRealFrac -- :: RealFrac a => a -> [a]- , shrinkRealFracToInteger -- :: RealFrac a => a -> [a] -- ** Helper functions for implementing coarbitrary , coarbitraryIntegral -- :: Integral a => a -> Gen b -> Gen b , coarbitraryReal -- :: Real a => a -> Gen b -> Gen b@@ -134,8 +133,10 @@ import qualified Data.Monoid as Monoid +#ifndef NO_TRANSFORMERS import Data.Functor.Identity import Data.Functor.Constant+#endif -------------------------------------------------------------------------- -- ** class Arbitrary@@ -391,7 +392,7 @@ instance Integral a => Arbitrary (Ratio a) where arbitrary = arbitrarySizedFractional- shrink = shrinkRealFracToInteger+ shrink = shrinkRealFrac instance (RealFloat a, Arbitrary a) => Arbitrary (Complex a) where arbitrary = liftM2 (:+) arbitrary arbitrary@@ -610,6 +611,7 @@ arbitrary = fmap ZipList arbitrary shrink = map ZipList . shrink . getZipList +#ifndef NO_TRANSFORMERS -- Arbitrary instance for transformers' Functors instance Arbitrary a => Arbitrary (Identity a) where arbitrary = fmap Identity arbitrary@@ -618,6 +620,7 @@ instance Arbitrary a => Arbitrary (Constant a b) where arbitrary = fmap Constant arbitrary shrink = map Constant . shrink . getConstant+#endif -- Arbitrary instance for Const instance Arbitrary a => Arbitrary (Const a b) where@@ -649,6 +652,8 @@ arbitrary = fmap Monoid.Product arbitrary shrink = map Monoid.Product . shrink . Monoid.getProduct +#if defined(MIN_VERSION_base)+#if MIN_VERSION_base(3,0,0) instance Arbitrary a => Arbitrary (Monoid.First a) where arbitrary = fmap Monoid.First arbitrary shrink = map Monoid.First . shrink . Monoid.getFirst@@ -656,8 +661,8 @@ instance Arbitrary a => Arbitrary (Monoid.Last a) where arbitrary = fmap Monoid.Last arbitrary shrink = map Monoid.Last . shrink . Monoid.getLast+#endif -#if defined(MIN_VERSION_base) #if MIN_VERSION_base(4,8,0) instance Arbitrary (f a) => Arbitrary (Monoid.Alt f a) where arbitrary = fmap Monoid.Alt arbitrary@@ -778,26 +783,15 @@ (True, False) -> a + b < 0 (False, True) -> a + b > 0 --- | Shrink a fraction, but only shrink to integral values.-shrinkRealFracToInteger :: RealFrac a => a -> [a]-shrinkRealFracToInteger x =+-- | Shrink a fraction.+shrinkRealFrac :: RealFrac a => a -> [a]+shrinkRealFrac x = nub $ [ -x | x < 0 ] ++ map fromInteger (shrinkIntegral (truncate x)) --- | Shrink a fraction.-shrinkRealFrac :: RealFrac a => a -> [a]-shrinkRealFrac x =- nub $- shrinkRealFracToInteger x ++- [ x - x'- | x' <- take 20 (iterate (/ 2) x)- , (x - x') << x ]- where- a << b = abs a < abs b- -------------------------------------------------------------------------- -- ** CoArbitrary @@ -1009,12 +1003,14 @@ instance CoArbitrary a => CoArbitrary (ZipList a) where coarbitrary = coarbitrary . getZipList +#ifndef NO_TRANSFORMERS -- CoArbitrary instance for transformers' Functors instance CoArbitrary a => CoArbitrary (Identity a) where coarbitrary = coarbitrary . runIdentity instance CoArbitrary a => CoArbitrary (Constant a b) where coarbitrary = coarbitrary . getConstant+#endif -- CoArbitrary instance for Const instance CoArbitrary a => CoArbitrary (Const a b) where@@ -1039,13 +1035,15 @@ instance CoArbitrary a => CoArbitrary (Monoid.Product a) where coarbitrary = coarbitrary . Monoid.getProduct +#if defined(MIN_VERSION_base)+#if MIN_VERSION_base(3,0,0) instance CoArbitrary a => CoArbitrary (Monoid.First a) where coarbitrary = coarbitrary . Monoid.getFirst instance CoArbitrary a => CoArbitrary (Monoid.Last a) where coarbitrary = coarbitrary . Monoid.getLast+#endif -#if defined(MIN_VERSION_base) #if MIN_VERSION_base(4,8,0) instance CoArbitrary (f a) => CoArbitrary (Monoid.Alt f a) where coarbitrary = coarbitrary . Monoid.getAlt
Test/QuickCheck/Gen.hs view
@@ -11,6 +11,7 @@ import System.Random ( Random , StdGen+ , random , randomR , split , newStdGen@@ -89,6 +90,10 @@ -- | Generates a random element in the given inclusive range. choose :: Random a => (a,a) -> Gen a choose rng = MkGen (\r _ -> let (x,_) = randomR rng r in x)++-- | Generates a random element over the natural range of `a`.+chooseAny :: Random a => Gen a+chooseAny = MkGen (\r _ -> let (x,_) = random r in x) -- | Run a generator. The size passed to the generator is always 30; -- if you want another size then you should explicitly use 'resize'.
Test/QuickCheck/Property.hs view
@@ -67,16 +67,6 @@ -- * Property and Testable types -- | The type of properties.------ Backwards combatibility note: in older versions of QuickCheck--- 'Property' was a type synonym for @'Gen' 'Prop'@, so you could mix--- and match property combinators and 'Gen' monad operations. Code--- that does this will no longer typecheck.--- However, it is easy to fix: because of the 'Testable' typeclass, any--- combinator that expects a 'Property' will also accept a @'Gen' 'Property'@.--- If you have a 'Property' where you need a @'Gen' 'a'@, simply wrap--- the property combinator inside a 'return' to get a @'Gen' 'Property'@, and--- all should be well. newtype Property = MkProperty { unProperty :: Gen Prop } -- | The class of things which can be tested, i.e. turned into a property.@@ -101,7 +91,7 @@ property (MkProp r) = MkProperty . return . MkProp . ioRose . return $ r instance Testable prop => Testable (Gen prop) where- property mp = MkProperty $ do p <- mp; unProperty (property p)+ property mp = MkProperty $ do p <- mp; unProperty (again p) instance Testable Property where property = property . unProperty
Test/QuickCheck/Test.hs view
@@ -23,6 +23,8 @@ #else import qualified Data.Map as Map #endif+#else+import qualified Data.Map as Map #endif import qualified Data.Set as Set
changelog view
@@ -1,3 +1,8 @@+QuickCheck 2.9.2 (released 2016-09-15)+ * Fix a bug where some properties were only being tested once+ * Make shrinking of floating-point values less aggressive+ * Add function chooseAny :: Random a => Gen a+ QuickCheck 2.9.1 (released 2016-07-11) * 'again' was only used in forAllShrink, not forAll