[commit: ghc] master: testsuite/T9430: Fix word-size dependence (0b0652f)

git at git.haskell.org git at git.haskell.org
Sun Dec 27 00:42:36 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/0b0652f1e9183e92be10de5aa2b44d9c12c5a68e/ghc

>---------------------------------------------------------------

commit 0b0652f1e9183e92be10de5aa2b44d9c12c5a68e
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Sat Dec 26 23:23:03 2015 +0100

    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


>---------------------------------------------------------------

0b0652f1e9183e92be10de5aa2b44d9c12c5a68e
 testsuite/tests/primops/should_run/T9430.hs | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/testsuite/tests/primops/should_run/T9430.hs b/testsuite/tests/primops/should_run/T9430.hs
index eedc0a7..4fa6769 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



More information about the ghc-commits mailing list