QuickCheck 2.12.5 → 2.12.6
raw patch · 5 files changed
+50/−6 lines, 5 filesdep ~basedep ~deepseqdep ~random
Dependency ranges changed: base, deepseq, random
Files
- QuickCheck.cabal +2/−2
- Test/QuickCheck/Arbitrary.hs +9/−2
- Test/QuickCheck/Gen.hs +8/−0
- Test/QuickCheck/Modifiers.hs +21/−2
- changelog +10/−0
QuickCheck.cabal view
@@ -1,5 +1,5 @@ Name: QuickCheck-Version: 2.12.5+Version: 2.12.6 Cabal-Version: >= 1.8 Build-type: Simple License: BSD3@@ -55,7 +55,7 @@ source-repository this type: git location: https://github.com/nick8325/quickcheck- tag: 2.12.5+ tag: 2.12.6 flag templateHaskell Description: Build Test.QuickCheck.All, which uses Template Haskell.
Test/QuickCheck/Arbitrary.hs view
@@ -1035,8 +1035,15 @@ sized $ \s -> do let bits n | n == 0 = 0 | otherwise = 1 + bits (n `quot` 2)- k = 2^(s*(bits mn `max` bits mx `max` 40) `div` 80)- n <- choose (toInteger mn `max` (-k), toInteger mx `min` k)+ k = (toInteger s*(bits mn `max` bits mx `max` 40) `div` 80)+ -- computes x `min` (2^k), but avoids computing 2^k+ -- if it is too large+ x `minexp` k+ | bits x < k = x+ | otherwise = x `min` (2^k)+ -- x `max` (-2^k)+ x `maxexpneg` k = -((-x) `minexp` k)+ n <- choose (toInteger mn `maxexpneg` k, toInteger mx `minexp` k) return (fromInteger n) -- ** Generators for various kinds of character
Test/QuickCheck/Gen.hs view
@@ -123,6 +123,14 @@ scale :: (Int -> Int) -> Gen a -> Gen a scale f g = sized (\n -> resize (f n) g) +-- | Increase the size parameter by a factor of 2.+larger :: Gen a -> Gen a+larger = scale (*2)++-- | Decrease the size parameter by a factor of 2.+smaller :: Gen a -> Gen a+smaller = scale (`div` 2)+ -- | 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)
Test/QuickCheck/Modifiers.hs view
@@ -58,6 +58,8 @@ , NonNegative(..) , Large(..) , Small(..)+ , Larger(..)+ , Smaller(..) , Smart(..) , Shrink2(..) #ifndef NO_MULTI_PARAM_TYPE_CLASSES@@ -344,8 +346,8 @@ shrink (Large x) = fmap Large (shrinkIntegral x) ----------------------------------------------------------------------------- | @Small x@: generates values of @x@ drawn from a small range.--- The opposite of 'Large'.+-- | @Small x@: generates values of the integral type @x@ drawn from a+-- small range. The opposite of 'Large'. newtype Small a = Small {getSmall :: a} deriving ( Eq, Ord, Show, Read #ifndef NO_NEWTYPE_DERIVING@@ -362,6 +364,23 @@ instance Integral a => Arbitrary (Small a) where arbitrary = fmap Small arbitrarySizedIntegral shrink (Small x) = map Small (shrinkIntegral x)++--------------------------------------------------------------------------+-- | @Larger x@: doubles the QuickCheck size parameter used when+-- generating @x@.+newtype Larger a = Larger {getLarger :: a}+ deriving ( Eq, Ord, Show, Read+#ifndef NO_TYPEABLE+ , Typeable+#endif+ )++instance Functor Larger where+ fmap f (Larger x) = Larger (f x)++instance Arbitrary a => Arbitrary (Larger a) where+ arbitrary = larger arbitrary+ shrink (Larger x) = map Larger (shrink x) -------------------------------------------------------------------------- -- | @Shrink2 x@: allows 2 shrinking steps at the same time when shrinking x
changelog view
@@ -1,3 +1,13 @@+QuickCheck 2.12.6 (released 2018-10-02)+ * Make arbitrarySizedBoundedIntegral handle huge sizes correctly.+ * Add changelog for QuickCheck 2.12.5 :)++QuickCheck 2.12.5 (released 2018-09-30)+ * Export isSuccess from Test.QuickCheck.+ * Export CoArbitrary even when generics are disabled (bugfix).+ * Fix bug in shrinkDecimal.+ * Include Test.QuickCheck.Gen in exposed modules for Haddock.+ QuickCheck 2.12.3, 2.12.4 (released 2018-09-12) * Shrinking for Float and Decimal now works by reducing the number of digits in the number. The new function shrinkDecimal