Commit 0420e501 authored by simonmar's avatar simonmar
Browse files

[project @ 2001-01-12 12:36:28 by simonmar]

Add conversion tests to arith011.
parent 4efb6ede
......@@ -32,6 +32,7 @@ testIntlikeNoBits name zero = do
testNum zero
testReal zero
testIntegral zero
testConversions zero
testInteger = do
let zero = 0 :: Integer
......@@ -68,6 +69,20 @@ testEnum zero = do
print [zero .. toEnum 20] -- enumFromTo
print [zero, toEnum 2 .. toEnum 20] -- enumFromThenTo
testConversions zero = do
putStrLn "testConversions"
putStr "Integer : " >> print (map fromIntegral numbers :: [Integer])
putStr "Int : " >> print (map fromIntegral numbers :: [Int])
putStr "Int8 : " >> print (map fromIntegral numbers :: [Int8])
putStr "Int16 : " >> print (map fromIntegral numbers :: [Int16])
putStr "Int32 : " >> print (map fromIntegral numbers :: [Int32])
putStr "Int64 : " >> print (map fromIntegral numbers :: [Int64])
putStr "Word8 : " >> print (map fromIntegral numbers :: [Word8])
putStr "Word16 : " >> print (map fromIntegral numbers :: [Word16])
putStr "Word32 : " >> print (map fromIntegral numbers :: [Word32])
putStr "Word64 : " >> print (map fromIntegral numbers :: [Word64])
where numbers = [minBound, 0, maxBound] `asTypeOf` [zero]
samples :: (Num a, Enum a) => a -> ([a], [a])
samples zero = ([-3 .. -1]++[0 .. 3], [-3 .. -1]++[1 .. 3])
......
......@@ -903,6 +903,17 @@ testIntegral
3 `rem` 3 = 0
#
testConversions
Integer : [-2147483648,0,2147483647]
Int : [-2147483648,0,2147483647]
Int8 : [0,0,-1]
Int16 : [0,0,-1]
Int32 : [-2147483648,0,2147483647]
Int64 : [-2147483648,0,2147483647]
Word8 : [0,0,255]
Word16 : [0,0,65535]
Word32 : [2147483648,0,2147483647]
Word64 : [2147483648,0,2147483647]
--------------------------------
--Testing Int8
--------------------------------
......@@ -1808,6 +1819,17 @@ testIntegral
3 `rem` 3 = 0
#
testConversions
Integer : [-128,0,127]
Int : [-128,0,127]
Int8 : [-128,0,127]
Int16 : [-128,0,127]
Int32 : [-128,0,127]
Int64 : [-128,0,127]
Word8 : [128,0,127]
Word16 : [65408,0,127]
Word32 : [4294967168,0,127]
Word64 : [4294967168,0,127]
testBits
-3 .&. -3 = -3
-3 .&. -2 = -4
......@@ -3208,6 +3230,17 @@ testIntegral
3 `rem` 3 = 0
#
testConversions
Integer : [-32768,0,32767]
Int : [-32768,0,32767]
Int8 : [0,0,-1]
Int16 : [-32768,0,32767]
Int32 : [-32768,0,32767]
Int64 : [-32768,0,32767]
Word8 : [0,0,255]
Word16 : [32768,0,32767]
Word32 : [4294934528,0,32767]
Word64 : [4294934528,0,32767]
testBits
-3 .&. -3 = -3
-3 .&. -2 = -4
......@@ -4608,6 +4641,17 @@ testIntegral
3 `rem` 3 = 0
#
testConversions
Integer : [-2147483648,0,2147483647]
Int : [-2147483648,0,2147483647]
Int8 : [0,0,-1]
Int16 : [0,0,-1]
Int32 : [-2147483648,0,2147483647]
Int64 : [-2147483648,0,2147483647]
Word8 : [0,0,255]
Word16 : [0,0,65535]
Word32 : [2147483648,0,2147483647]
Word64 : [2147483648,0,2147483647]
testBits
-3 .&. -3 = -3
-3 .&. -2 = -4
......@@ -6008,6 +6052,17 @@ testIntegral
3 `rem` 3 = 0
#
testConversions
Integer : [0,0,255]
Int : [0,0,255]
Int8 : [0,0,-1]
Int16 : [0,0,255]
Int32 : [0,0,255]
Int64 : [0,0,255]
Word8 : [0,0,255]
Word16 : [0,0,255]
Word32 : [0,0,255]
Word64 : [0,0,255]
testBits
253 .&. 253 = 253
253 .&. 254 = 252
......@@ -7408,6 +7463,17 @@ testIntegral
3 `rem` 3 = 0
#
testConversions
Integer : [0,0,65535]
Int : [0,0,65535]
Int8 : [0,0,-1]
Int16 : [0,0,-1]
Int32 : [0,0,65535]
Int64 : [0,0,65535]
Word8 : [0,0,255]
Word16 : [0,0,65535]
Word32 : [0,0,65535]
Word64 : [0,0,65535]
testBits
65533 .&. 65533 = 65533
65533 .&. 65534 = 65532
......@@ -8808,6 +8874,17 @@ testIntegral
3 `rem` 3 = 0
#
testConversions
Integer : [0,0,4294967295]
Int : [0,0,-1]
Int8 : [0,0,-1]
Int16 : [0,0,-1]
Int32 : [0,0,-1]
Int64 : [0,0,4294967295]
Word8 : [0,0,255]
Word16 : [0,0,65535]
Word32 : [0,0,4294967295]
Word64 : [0,0,4294967295]
testBits
4294967293 .&. 4294967293 = 4294967293
4294967293 .&. 4294967294 = 4294967292
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment