summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNickSmallbone <>2018-10-02 16:05:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-10-02 16:05:00 (GMT)
commit2f66a5d038d3301d797ba79a53ce55ebaf9f54a9 (patch)
treebd8f5f4b3a376cef38c506020b1970ec4514ba00
parent7c088a02568b7d1193826a673944782069616e67 (diff)
version 2.12.62.12.6
-rw-r--r--QuickCheck.cabal4
-rwxr-xr-x[-rw-r--r--]README0
-rw-r--r--Test/QuickCheck/Arbitrary.hs11
-rw-r--r--Test/QuickCheck/Gen.hs8
-rw-r--r--Test/QuickCheck/Modifiers.hs23
-rwxr-xr-x[-rw-r--r--]changelog10
-rwxr-xr-x[-rw-r--r--]examples/Heap.hs0
-rwxr-xr-x[-rw-r--r--]examples/Heap_Program.hs0
-rwxr-xr-x[-rw-r--r--]examples/Heap_ProgramAlgebraic.hs0
-rwxr-xr-x[-rw-r--r--]examples/Lambda.hs0
-rwxr-xr-x[-rw-r--r--]examples/Merge.hs0
-rwxr-xr-x[-rw-r--r--]examples/Set.hs0
-rwxr-xr-x[-rw-r--r--]examples/Simple.hs0
13 files changed, 50 insertions, 6 deletions
diff --git a/QuickCheck.cabal b/QuickCheck.cabal
index 95dc24f..e9c2308 100644
--- a/QuickCheck.cabal
+++ b/QuickCheck.cabal
@@ -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 head
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.
diff --git a/README b/README
index 832eebc..832eebc 100644..100755
--- a/README
+++ b/README
diff --git a/Test/QuickCheck/Arbitrary.hs b/Test/QuickCheck/Arbitrary.hs
index e34437d..2a6a8e3 100644
--- a/Test/QuickCheck/Arbitrary.hs
+++ b/Test/QuickCheck/Arbitrary.hs
@@ -1035,8 +1035,15 @@ arbitrarySizedBoundedIntegral =
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
diff --git a/Test/QuickCheck/Gen.hs b/Test/QuickCheck/Gen.hs
index d97dda1..73d1ddc 100644
--- a/Test/QuickCheck/Gen.hs
+++ b/Test/QuickCheck/Gen.hs
@@ -123,6 +123,14 @@ resize n (MkGen g) = MkGen (\r _ -> g r n)
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)
diff --git a/Test/QuickCheck/Modifiers.hs b/Test/QuickCheck/Modifiers.hs
index ec08748..70da652 100644
--- a/Test/QuickCheck/Modifiers.hs
+++ b/Test/QuickCheck/Modifiers.hs
@@ -58,6 +58,8 @@ module Test.QuickCheck.Modifiers
, NonNegative(..)
, Large(..)
, Small(..)
+ , Larger(..)
+ , Smaller(..)
, Smart(..)
, Shrink2(..)
#ifndef NO_MULTI_PARAM_TYPE_CLASSES
@@ -344,8 +346,8 @@ instance (Integral a, Bounded a) => Arbitrary (Large a) where
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
@@ -364,6 +366,23 @@ instance Integral a => Arbitrary (Small a) where
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
newtype Shrink2 a = Shrink2 {getShrink2 :: a}
deriving ( Eq, Ord, Show, Read
diff --git a/changelog b/changelog
index 8925ecd..fe315cb 100644..100755
--- a/changelog
+++ b/changelog
@@ -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
diff --git a/examples/Heap.hs b/examples/Heap.hs
index c3900a9..c3900a9 100644..100755
--- a/examples/Heap.hs
+++ b/examples/Heap.hs
diff --git a/examples/Heap_Program.hs b/examples/Heap_Program.hs
index d9db2de..d9db2de 100644..100755
--- a/examples/Heap_Program.hs
+++ b/examples/Heap_Program.hs
diff --git a/examples/Heap_ProgramAlgebraic.hs b/examples/Heap_ProgramAlgebraic.hs
index bfa9626..bfa9626 100644..100755
--- a/examples/Heap_ProgramAlgebraic.hs
+++ b/examples/Heap_ProgramAlgebraic.hs
diff --git a/examples/Lambda.hs b/examples/Lambda.hs
index 42aac86..42aac86 100644..100755
--- a/examples/Lambda.hs
+++ b/examples/Lambda.hs
diff --git a/examples/Merge.hs b/examples/Merge.hs
index 8b1d2dd..8b1d2dd 100644..100755
--- a/examples/Merge.hs
+++ b/examples/Merge.hs
diff --git a/examples/Set.hs b/examples/Set.hs
index 6e0a966..6e0a966 100644..100755
--- a/examples/Set.hs
+++ b/examples/Set.hs
diff --git a/examples/Simple.hs b/examples/Simple.hs
index b173df6..b173df6 100644..100755
--- a/examples/Simple.hs
+++ b/examples/Simple.hs