From 0420e5017e9f491335e982f86d48a66b5f02276f Mon Sep 17 00:00:00 2001 From: simonmar Date: Fri, 12 Jan 2001 12:36:28 +0000 Subject: [PATCH] [project @ 2001-01-12 12:36:28 by simonmar] Add conversion tests to arith011. --- ghc/tests/numeric/should_run/arith011.hs | 15 +++++ ghc/tests/numeric/should_run/arith011.stdout | 77 ++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) diff --git a/ghc/tests/numeric/should_run/arith011.hs b/ghc/tests/numeric/should_run/arith011.hs index 1e53f8f..8c1a580 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 7a7c6b1..453ae5c 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 -- 1.7.10.4