test :: IO ()
test = do
+ testIntlikeNoBits "Int" (0::Int)
testIntlike "Int8" (0::Int8)
testIntlike "Int16" (0::Int16)
testIntlike "Int32" (0::Int32)
testIntlike "Word16" (0::Word16)
testIntlike "Word32" (0::Word32)
-testIntlike :: (Bounded a, Integral a, Ix a, Read a, Bits a) => String -> a -> IO ()
-testIntlike name zero = do
+testIntlikeNoBits :: (Bounded a, Integral a, Ix a, Read a) => String -> a -> IO ()
+testIntlikeNoBits name zero = do
putStrLn $ "--------------------------------"
putStrLn $ "--Testing " ++ name
putStrLn $ "--------------------------------"
testNum zero
testReal zero
testIntegral zero
+
+
+testIntlike :: (Bounded a, Integral a, Ix a, Read a, Bits a) => String -> a -> IO ()
+testIntlike name zero = do
+ testIntlikeNoBits name zero
testBits zero
- putStrLn $ "--------------------------------"
+
-- In all these tests, zero is a dummy element used to get
-- the overloading to work
table2 ".|. " (.|.) xs ys
table2 "`xor`" xor xs ys
table1 "complement" complement xs
- table2 "`shiftL`" shiftL xs [0..3]
- table2 "`shiftR`" shiftR xs [0..3]
+ table2 "`shiftL`" shiftL xs ([0..3] ++ [32])
+ table2 "`shiftR`" shiftR xs ([0..3] ++ [32])
table2 "`rotate`" rotate xs ([-3..3])
table1 "bit" (\ x -> (bit x) `asTypeOf` zero) [(0::Int)..3]
- table2 "`setBit`" setBit xs [0..3]
- table2 "`clearBit`" clearBit xs [0..3]
- table2 "`complementBit`" complementBit xs [0..3]
- table2 "`testBit`" testBit xs [0..3]
+ table2 "`setBit`" setBit xs ([0..3] ++ [32])
+ table2 "`clearBit`" clearBit xs ([0..3] ++ [32])
+ table2 "`complementBit`" complementBit xs ([0..3] ++ [32])
+ table2 "`testBit`" testBit xs ([0..3] ++ [32])
table1 "bitSize" bitSize xs
table1 "isSigned" isSigned xs
where