summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonmar <unknown>2001-01-12 12:36:28 +0000
committersimonmar <unknown>2001-01-12 12:36:28 +0000
commit0420e5017e9f491335e982f86d48a66b5f02276f (patch)
treec91f85828a75116ea71e6198b9dbf74dabaecad3
parent4efb6ede36e9a15336b5390864838464547f289b (diff)
downloadhaskell-0420e5017e9f491335e982f86d48a66b5f02276f.tar.gz
[project @ 2001-01-12 12:36:28 by simonmar]
Add conversion tests to arith011.
-rw-r--r--ghc/tests/numeric/should_run/arith011.hs15
-rw-r--r--ghc/tests/numeric/should_run/arith011.stdout77
2 files changed, 92 insertions, 0 deletions
diff --git a/ghc/tests/numeric/should_run/arith011.hs b/ghc/tests/numeric/should_run/arith011.hs
index 1e53f8f514..8c1a580a78 100644
--- a/ghc/tests/numeric/should_run/arith011.hs
+++ b/ghc/tests/numeric/should_run/arith011.hs
@@ -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])
diff --git a/ghc/tests/numeric/should_run/arith011.stdout b/ghc/tests/numeric/should_run/arith011.stdout
index 7a7c6b1a99..453ae5c25a 100644
--- a/ghc/tests/numeric/should_run/arith011.stdout
+++ b/ghc/tests/numeric/should_run/arith011.stdout
@@ -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