on master help sign in
Switch from QuickCheck 1 to QuickCheck 2

--HG-- extra : convert_revision : 4b289cc3e6e9bbb503f50627f919a1a9ddff4180

commitce01136cd0e628c7c0de829390698dc193c38085 authorBryan O'Sullivan <bos@serpentine.com> dateFri 23 Jul 2010, 19:47 (16 years ago) parent92d93c3
3 files changed+3−19
tests/Makefile+1−1 tests/Properties.hs+2−2 tests/QuickCheckUtils.hs−16
tests/Makefile+1−1
@@ -5,7 +5,7 @@ ghc-base-flags := -funbox-strict-fields -package criterion \
55 -package bytestring -ignore-package text \
66 -fno-ignore-asserts
77ghc-test-flags := -package QuickCheck -package test-framework \
8− -package test-framework-quickcheck -package test-framework-hunit \
8+ -package test-framework-quickcheck2 -package test-framework-hunit \
99 -package HUnit
1010ghc-base-flags += -Wall -fno-warn-orphans -fno-warn-missing-signatures
1111ghc-flags := $(ghc-base-flags) -i../dist/build -package-name text-$(version)
tests/Properties.hs+2−2
@@ -2,7 +2,7 @@
22 ScopedTypeVariables, TypeSynonymInstances #-}
33{-# OPTIONS_GHC -fno-enable-rewrite-rules #-}
44
5−import Test.QuickCheck hiding (evaluate)
5+import Test.QuickCheck
66import Text.Show.Functions ()
77
88import qualified Data.Bits as Bits (shiftL, shiftR)
@@ -27,7 +27,7 @@ import qualified Data.List as L
2727import Prelude hiding (replicate)
2828import System.IO.Unsafe (unsafePerformIO)
2929import Test.Framework (defaultMain, testGroup)
30−import Test.Framework.Providers.QuickCheck (testProperty)
30+import Test.Framework.Providers.QuickCheck2 (testProperty)
3131import Data.Text.Search (indices)
3232import qualified Data.Text.Lazy.Search as S (indices)
3333import qualified SlowFunctions as Slow
tests/QuickCheckUtils.hs−16
@@ -17,7 +17,6 @@ instance Random Int64 where
1717
1818instance Arbitrary Int64 where
1919 arbitrary = choose (minBound,maxBound)
20− coarbitrary c = variant (fromEnum c `rem` 4)
2120
2221instance Random Word8 where
2322 randomR = integralRandomR
@@ -25,11 +24,9 @@ instance Random Word8 where
2524
2625instance Arbitrary Word8 where
2726 arbitrary = choose (minBound,maxBound)
28− coarbitrary c = variant (fromEnum c `rem` 4)
2927
3028instance Arbitrary B.ByteString where
3129 arbitrary = B.pack `fmap` arbitrary
32− coarbitrary s = coarbitrary (B.unpack s)
3330
3431instance Random Word16 where
3532 randomR = integralRandomR
@@ -37,7 +34,6 @@ instance Random Word16 where
3734
3835instance Arbitrary Word16 where
3936 arbitrary = choose (minBound,maxBound)
40− coarbitrary c = variant (fromEnum c `rem` 4)
4137
4238instance Random Word32 where
4339 randomR = integralRandomR
@@ -45,19 +41,12 @@ instance Random Word32 where
4541
4642instance Arbitrary Word32 where
4743 arbitrary = choose (minBound,maxBound)
48− coarbitrary c = variant (fromEnum c `rem` 4)
49−
50−instance Arbitrary Char where
51− arbitrary = oneof [choose ('\0','\55295'), choose ('\57344','\1114111')]
52− coarbitrary c = variant (fromEnum c `rem` 4)
5344
5445instance Arbitrary T.Text where
5546 arbitrary = T.pack `fmap` arbitrary
56− coarbitrary s = coarbitrary (T.unpack s)
5747
5848instance Arbitrary TL.Text where
5949 arbitrary = TL.pack `fmap` arbitrary
60− coarbitrary s = coarbitrary (TL.unpack s)
6150
6251newtype NotEmpty a = NotEmpty { notEmpty :: a }
6352 deriving (Eq, Ord, Show)
@@ -67,19 +56,15 @@ instance Functor NotEmpty where
6756
6857instance Arbitrary a => Arbitrary (NotEmpty [a]) where
6958 arbitrary = sized (\n -> NotEmpty `fmap` (choose (1,n+1) >>= vector))
70− coarbitrary = coarbitrary . notEmpty
7159
7260instance Arbitrary (NotEmpty T.Text) where
7361 arbitrary = (fmap T.pack) `fmap` arbitrary
74− coarbitrary = coarbitrary . notEmpty
7562
7663instance Arbitrary (NotEmpty TL.Text) where
7764 arbitrary = (fmap TL.pack) `fmap` arbitrary
78− coarbitrary = coarbitrary . notEmpty
7965
8066instance Arbitrary (NotEmpty B.ByteString) where
8167 arbitrary = (fmap B.pack) `fmap` arbitrary
82− coarbitrary = coarbitrary . notEmpty
8368
8469data Small = S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7
8570 | S8 | S9 | S10 | S11 | S12 | S13 | S14 | S15
@@ -120,7 +105,6 @@ instance Random Small where
120105
121106instance Arbitrary Small where
122107 arbitrary = choose (minBound,maxBound)
123− coarbitrary c = variant (fromEnum c `rem` 4)
124108
125109integralRandomR :: (Integral a, RandomGen g) => (a,a) -> g -> (a,g)
126110integralRandomR (a,b) g = case randomR (fromIntegral a :: Integer,