on master help sign in
Support the I16 type with QuickCheck

--HG-- extra : convert_revision : 2df60d47f2ff03b01ae0ad0040ddba8e3a39dbcc

commit8c349241f56b4fc04b3b4df533d5bb7165f04c29 authorBryan O'Sullivan <bos@serpentine.com> dateTue 5 Oct 2010, 04:41 (16 years ago) parent9825285
1 file changed+10−2
tests/QuickCheckUtils.hs+10−2
tests/QuickCheckUtils.hs+10−2
@@ -9,6 +9,7 @@ import Data.Int (Int64)
99import Data.Word (Word8, Word16, Word32)
1010import Data.String (IsString, fromString)
1111import qualified Data.Text as T
12+import Data.Text.Foreign (I16)
1213import qualified Data.Text.Lazy as TL
1314import System.Random (Random(..), RandomGen)
1415import Test.QuickCheck hiding ((.&.))
@@ -21,6 +22,13 @@ instance Random Int64 where
2122instance Arbitrary Int64 where
2223 arbitrary = choose (minBound,maxBound)
2324
25+instance Random I16 where
26+ randomR = integralRandomR
27+ random = randomR (minBound,maxBound)
28+
29+instance Arbitrary I16 where
30+ arbitrary = choose (minBound,maxBound)
31+
2432instance Random Word8 where
2533 randomR = integralRandomR
2634 random = randomR (minBound,maxBound)
@@ -137,8 +145,8 @@ data Small = S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7
137145 | S24 | S25 | S26 | S27 | S28 | S29 | S30 | S31
138146 deriving (Eq, Ord, Enum, Bounded)
139147
140−small :: Small -> Int
141−small = fromEnum
148+small :: Integral a => Small -> a
149+small = fromIntegral . fromEnum
142150
143151intf f a b = toEnum ((fromEnum a `f` fromEnum b) `mod` 32)
144152