@@ -96,13 +96,6 @@ tests =
100− -- these tests use the R structure
102− -- quickCheck prop_Word32_from_2_Word16
103− -- quickCheck prop_Word32_from_Word8_and_Word16
106prop_putget_with_bitreq :: (BinaryBit a, Num a, Bits a, Ord a) => W a -> Property
99prop_putget_with_bitreq :: (BinaryBit a, Num a, Bits a, Ord a) => W a -> Property
107prop_putget_with_bitreq (W w) = property $
100prop_putget_with_bitreq (W w) = property $
108 -- write all words with as many bits as it's required
101 -- write all words with as many bits as it's required
@@ -167,7 +160,7 @@ prop_bitget_bytestring_interspersed (W ws) bss = property $
167 r = runGet (runBitGet g) lbs
160 r = runGet (runBitGet g) lbs
168 in map (ws,) bss == r
161 in map (ws,) bss == r
170−-- number of bits required to write @v@
163+-- | number of bits required to write @v@
171bitreq :: (Num b, Bits a, Ord a) => a -> b
164bitreq :: (Num b, Bits a, Ord a) => a -> b
172bitreq v = fromIntegral . head $ [ req | (req, top) <- bittable, v <= top ]
165bitreq v = fromIntegral . head $ [ req | (req, top) <- bittable, v <= top ]
@@ -194,7 +187,6 @@ prop_composite_case b (W w) = w < 0x8000 ==>
194 w' = runGet (runBitGet g) lbs
187 w' = runGet (runBitGet g) lbs
195 in w == w'
188 in w == w'
198prop_compare_put_with_naive :: (Bits a, BinaryBit a, Ord a) => W [a] -> Property
190prop_compare_put_with_naive :: (Bits a, BinaryBit a, Ord a) => W [a] -> Property
199prop_compare_put_with_naive (W ws) = property $
191prop_compare_put_with_naive (W ws) = property $
200 let pn = mapM_ (\v -> naive_put (bitreq v) v) ws
192 let pn = mapM_ (\v -> naive_put (bitreq v) v) ws
@@ -230,27 +222,6 @@ naive_get n0 =
230 True -> loop (n-1) ((acc `shiftL` 1) + 1)
222 True -> loop (n-1) ((acc `shiftL` 1) + 1)
231 in loop n0 0
223 in loop n0 0
234−prop_Word32_from_Word8_and_Word16 :: Word8 -> Word16 -> Property
235−prop_Word32_from_Word8_and_Word16 w8 w16 = property $
236− let p = RWord32be 24
237− w' = runGet (get p) lbs
240− lbs = runPut (putWord8 w8 >> putWord16be w16)
241− w0 = ((fromIntegral w8) `shiftL` 16) .|. fromIntegral w16
243−prop_Word32_from_2_Word16 :: Word16 -> Word16 -> Property
244−prop_Word32_from_2_Word16 w1 w2 = property $
245− let p = RWord32be 32
246− w' = runGet (get p) lbs
250− w0 = ((fromIntegral w1) `shiftL` 16) .|. fromIntegral w2
254shrinker :: (Num a, Ord a, Bits a) => a -> [a]
225shrinker :: (Num a, Ord a, Bits a) => a -> [a]
255shrinker 0 = []
226shrinker 0 = []
256shrinker w = [ w `shiftR` 1 -- try to make everything roughly half size
227shrinker w = [ w `shiftR` 1 -- try to make everything roughly half size