Commits

Bryan O'Sullivan committed 5b411d0

Support the I16 type with QuickCheck

Comments (0)

Files changed (1)

tests/QuickCheckUtils.hs

 import Data.Word (Word8, Word16, Word32)
 import Data.String (IsString, fromString)
 import qualified Data.Text as T
+import Data.Text.Foreign (I16)
 import qualified Data.Text.Lazy as TL
 import System.Random (Random(..), RandomGen)
 import Test.QuickCheck hiding ((.&.))
 instance Arbitrary Int64 where
     arbitrary     = choose (minBound,maxBound)
 
+instance Random I16 where
+    randomR = integralRandomR
+    random  = randomR (minBound,maxBound)
+
+instance Arbitrary I16 where
+    arbitrary     = choose (minBound,maxBound)
+
 instance Random Word8 where
     randomR = integralRandomR
     random  = randomR (minBound,maxBound)
            | S24 | S25 | S26 | S27 | S28 | S29 | S30 | S31
     deriving (Eq, Ord, Enum, Bounded)
 
-small :: Small -> Int
-small = fromEnum
+small :: Integral a => Small -> a
+small = fromIntegral . fromEnum
 
 intf f a b = toEnum ((fromEnum a `f` fromEnum b) `mod` 32)