summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2018-04-23 10:42:17 -0400
committerBen Gamari <ben@smart-cactus.org>2018-04-24 09:55:01 -0400
commitec9638b222433b33943b3c4319d1d5cf91313b0c (patch)
treef6c2a229069991b5bb5c88386df06140dcfc8753
parent1126e6942624f4e6578e59b2a28b9848ad9fcea2 (diff)
downloadhaskell-ec9638b222433b33943b3c4319d1d5cf91313b0c.tar.gz
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
-rw-r--r--testsuite/tests/primops/should_run/T4442.hs29
1 files changed, 28 insertions, 1 deletions
diff --git a/testsuite/tests/primops/should_run/T4442.hs b/testsuite/tests/primops/should_run/T4442.hs
index 76320e4ef5..0d09f621e0 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#"