[commit: ghc] master: testsuite: Fix T4442 on 32-bit architectures (ec9638b)

git at git.haskell.org git at git.haskell.org
Tue Apr 24 16:09:01 UTC 2018


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

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

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

commit ec9638b222433b33943b3c4319d1d5cf91313b0c
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Mon Apr 23 10:42:17 2018 -0400

    testsuite: Fix T4442 on 32-bit architectures
    
    This relied on Int# being 64-bits. This is nothing a bit of CPP can't
    fix, but I think the right solution would be to make out treatment of
    word-size dependent types more consistent, as suggested by #11953.
    
    Test Plan: Validate on i386
    
    Subscribers: thomie, carter
    
    Differential Revision: https://phabricator.haskell.org/D4614


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

ec9638b222433b33943b3c4319d1d5cf91313b0c
 testsuite/tests/primops/should_run/T4442.hs | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/testsuite/tests/primops/should_run/T4442.hs b/testsuite/tests/primops/should_run/T4442.hs
index 76320e4..0d09f62 100644
--- a/testsuite/tests/primops/should_run/T4442.hs
+++ b/testsuite/tests/primops/should_run/T4442.hs
@@ -111,6 +111,33 @@ testIntArray name0 index read write val0 len = do
     (intToBytes val len)
     len
 
+#if WORD_SIZE_IN_BITS == 64
+testInt64Array = testIntArray
+#else
+testInt64Array ::
+     String
+  -> (ByteArray# -> Int# -> Int64#)
+  -> (MutableByteArray# RealWorld -> Int# -> State# RealWorld
+        -> (# State# RealWorld, Int64# #))
+  -> (MutableByteArray# RealWorld -> Int# -> Int64# -> State# RealWorld
+        -> State# RealWorld)
+  -> Int
+  -> Int
+  -> IO ()
+testInt64Array name0 index read write val0 len = do
+  doOne (name0 ++ " positive") val0
+  doOne (name0 ++ " negative") (negate val0)
+ where
+  doOne name val = test
+    name
+    (\arr i -> I64# (index arr i))
+    (\arr i s -> case read arr i s of (# s', a #) -> (# s', I# a #))
+    (\arr i (I64# a) s -> write arr i a s)
+    val
+    (intToBytes val len)
+    len
+#endif
+
 testWordArray ::
      String
   -> (ByteArray# -> Int# -> Word#)
@@ -172,7 +199,7 @@ main = do
   testIntArray "Int32#"
     indexWord8ArrayAsInt32# readWord8ArrayAsInt32# writeWord8ArrayAsInt32#
     12345678 4
-  testIntArray "Int64#"
+  testInt64Array "Int64#"
     indexWord8ArrayAsInt64# readWord8ArrayAsInt64# writeWord8ArrayAsInt64#
     1234567890123 8
   testIntArray "Int#"



More information about the ghc-commits mailing list