QuickCheck 1.0 → 1.1.0.0
raw patch · 3 files changed
+38/−12 lines, 3 filesdep +randomdep ~basesetup-changed
Dependencies added: random
Dependency ranges changed: base
Files
- QuickCheck.cabal +21/−12
- Setup.hs +4/−0
- Test/QuickCheck.hs +13/−0
QuickCheck.cabal view
@@ -1,5 +1,5 @@ name: QuickCheck-version: 1.0+version: 1.1.0.0 license: BSD3 license-file: LICENSE author: Koen Classen and John Hughes@@ -17,14 +17,23 @@ QuickCheck provides combinators to define properties, observe the distribution of test data, and define test data generators.-exposed-modules:- Debug.QuickCheck.Batch,- Debug.QuickCheck.Poly,- Debug.QuickCheck.Utils,- Debug.QuickCheck,- Test.QuickCheck.Batch,- Test.QuickCheck.Poly,- Test.QuickCheck.Utils,- Test.QuickCheck-build-depends: base-extensions: CPP+build-type: Simple+cabal-version: >=1.2++flag split-base++library+ exposed-modules:+ Debug.QuickCheck.Batch,+ Debug.QuickCheck.Poly,+ Debug.QuickCheck.Utils,+ Debug.QuickCheck,+ Test.QuickCheck.Batch,+ Test.QuickCheck.Poly,+ Test.QuickCheck.Utils,+ Test.QuickCheck+ if flag(split-base)+ build-depends: base >= 3, random+ else+ build-depends: base < 3+ extensions: CPP
Setup.hs view
@@ -1,2 +1,6 @@+module Main (main) where+ import Distribution.Simple++main :: IO () main = defaultMain
Test/QuickCheck.hs view
@@ -197,6 +197,19 @@ coarbitrary (a, b, c, d) = coarbitrary a . coarbitrary b . coarbitrary c . coarbitrary d +instance (Arbitrary a) => Arbitrary (Maybe a) where+ arbitrary = sized arbMaybe+ where+ arbMaybe 0 = return Nothing+ arbMaybe n = fmap Just (resize (n-1) arbitrary)+ coarbitrary Nothing = variant 0+ coarbitrary (Just x) = variant 1 . coarbitrary x++instance (Arbitrary a, Arbitrary b) => Arbitrary (Either a b) where+ arbitrary = oneof [fmap Left arbitrary, fmap Right arbitrary]+ coarbitrary (Left x) = variant 0 . coarbitrary x+ coarbitrary (Right x) = variant 1 . coarbitrary x+ instance Arbitrary a => Arbitrary [a] where arbitrary = sized (\n -> choose (0,n) >>= vector) coarbitrary [] = variant 0