diff options
author | Ben Gamari <ben@smart-cactus.org> | 2015-12-26 23:23:03 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-12-27 01:42:07 +0100 |
commit | 0b0652f1e9183e92be10de5aa2b44d9c12c5a68e (patch) | |
tree | 679619d7493bd520cff4bea44a50cacfe619cf59 /testsuite | |
parent | fb5d26d9658908ae3e8416077246c2fb405875e1 (diff) | |
download | haskell-0b0652f1e9183e92be10de5aa2b44d9c12c5a68e.tar.gz |
testsuite/T9430: Fix word-size dependence
Summary: This test was wrong.
Test Plan: Validate
Reviewers: erikd, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1702
GHC Trac Issues: #11294
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/primops/should_run/T9430.hs | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/testsuite/tests/primops/should_run/T9430.hs b/testsuite/tests/primops/should_run/T9430.hs index eedc0a754b..4fa6769e1d 100644 --- a/testsuite/tests/primops/should_run/T9430.hs +++ b/testsuite/tests/primops/should_run/T9430.hs @@ -3,8 +3,12 @@ module Main where +import Data.Bits import GHC.Exts +wordWidth :: Int +wordWidth = finiteBitSize (0 :: Word) + checkI :: (Int, Int) -- ^ expected results -> (Int# -> Int# -> (# Int#, Int# #)) -- ^ primop @@ -96,10 +100,10 @@ main = do check "timesWord2# maxBound 1" $ checkW (0, maxBound) timesWord2# maxBound 1 check "timesWord2# 1 maxBound" $ checkW (0, maxBound) timesWord2# 1 maxBound -- Overflows - check "timesWord2# " $ checkW (1, 0) timesWord2# (2 ^ 63) 2 - check "timesWord2# " $ checkW (2, 0) timesWord2# (2 ^ 63) (2 ^ 2) - check "timesWord2# " $ checkW (4, 0) timesWord2# (2 ^ 63) (2 ^ 3) - check "timesWord2# " $ checkW (8, 0) timesWord2# (2 ^ 63) (2 ^ 4) + check "timesWord2# (2^(N-1)) 2" $ checkW (1, 0) timesWord2# (2 ^ (wordWidth-1)) 2 + check "timesWord2# (2^(N-1)) 2^2" $ checkW (2, 0) timesWord2# (2 ^ (wordWidth-1)) (2 ^ 2) + check "timesWord2# (2^(N-1)) 2^3" $ checkW (4, 0) timesWord2# (2 ^ (wordWidth-1)) (2 ^ 3) + check "timesWord2# (2^(N-1)) 2^4" $ checkW (8, 0) timesWord2# (2 ^ (wordWidth-1)) (2 ^ 4) check "timesWord2# maxBound 2" $ checkW (1, maxBound - 1) timesWord2# maxBound 2 check "timesWord2# 2 maxBound" $ @@ -112,17 +116,17 @@ main = do check "quotRemWord2# 0 0 1" $ checkW2 (0, 0) quotRemWord2# 0 0 1 check "quotRemWord2# 0 4 2" $ checkW2 (2, 0) quotRemWord2# 0 4 2 check "quotRemWord2# 0 7 3" $ checkW2 (2, 1) quotRemWord2# 0 7 3 - check "quotRemWord2# 1 0 (2 ^ 63)" $ - checkW2 (2, 0) quotRemWord2# 1 0 (2 ^ 63) - check "quotRemWord2# 1 1 (2 ^ 63)" $ - checkW2 (2, 1) quotRemWord2# 1 1 (2 ^ 63) + check "quotRemWord2# 1 0 (2^(N-1))" $ + checkW2 (2, 0) quotRemWord2# 1 0 (2 ^ (wordWidth-1)) + check "quotRemWord2# 1 1 (2^(N-1))" $ + checkW2 (2, 1) quotRemWord2# 1 1 (2 ^ (wordWidth-1)) check "quotRemWord2# 1 0 maxBound" $ checkW2 (1, 1) quotRemWord2# 1 0 maxBound check "quotRemWord2# 2 0 maxBound" $ checkW2 (2, 2) quotRemWord2# 2 0 maxBound check "quotRemWord2# 1 maxBound maxBound" $ checkW2 (2, 1) quotRemWord2# 1 maxBound maxBound - check "quotRemWord2# (2 ^ 63) 0 maxBound" $ - checkW2 (2 ^ 63, 2 ^ 63) quotRemWord2# (2 ^ 63) 0 maxBound - check "quotRemWord2# (2 ^ 63) maxBound maxBound" $ - checkW2 (2 ^ 63 + 1, 2 ^ 63) quotRemWord2# (2 ^ 63) maxBound maxBound + check "quotRemWord2# (2^(N-1)) 0 maxBound" $ + checkW2 (2 ^ (wordWidth-1), 2 ^ (wordWidth-1)) quotRemWord2# (2 ^ (wordWidth-1)) 0 maxBound + check "quotRemWord2# (2^(N-1)) maxBound maxBound" $ + checkW2 (2 ^ (wordWidth-1) + 1, 2 ^ (wordWidth-1)) quotRemWord2# (2 ^ (wordWidth-1)) maxBound maxBound |