@@ -111,22 +111,33 @@ prop_Word32_from_2_Word16 w1 w2 = property $
111 w0 = ((fromIntegral w1) `shiftL` 16) .|. fromIntegral w2
111 w0 = ((fromIntegral w1) `shiftL` 16) .|. fromIntegral w2
115+shrinker :: (Num a, Ord a, Bits a) => a -> [a]
117+shrinker w = [ w `shiftR` 1 -- try to make everything roughly half size
118+ ] ++ [ w' -- flip bits to zero, left->right
120+ , let w' = w `clearBit` m
122+ ] ++ [w-1] -- just make it a little smaller
114instance Arbitrary Word8 where
126instance Arbitrary Word8 where
115 arbitrary = choose (minBound, maxBound)
127 arbitrary = choose (minBound, maxBound)
116− shrink 0 = []
128+ shrink = shrinker
117− shrink n = [ n - 1 ]
119instance Arbitrary Word16 where
130instance Arbitrary Word16 where
120 arbitrary = choose (minBound, maxBound)
131 arbitrary = choose (minBound, maxBound)
121− shrink 0 = []
132+ shrink = shrinker
122− shrink n = [ n - 10000, n - 1000, n - 100, n - 1 ]
124instance Arbitrary Word32 where
134instance Arbitrary Word32 where
125 arbitrary = choose (minBound, maxBound)
135 arbitrary = choose (minBound, maxBound)
127instance Arbitrary Word64 where
138instance Arbitrary Word64 where
128 arbitrary = choose (minBound, maxBound)
139 arbitrary = choose (minBound, maxBound)
129−
140+ shrink = shrinker
131integralRandomR :: (Integral a, RandomGen g) => (a,a) -> g -> (a,g)
142integralRandomR :: (Integral a, RandomGen g) => (a,a) -> g -> (a,g)
132integralRandomR (a,b) g = case randomR (fromIntegral a :: Integer,
143integralRandomR (a,b) g = case randomR (fromIntegral a :: Integer,