Fix Word2Float# test on 32-bit
authorJohan Tibell <johan.tibell@gmail.com>
Tue, 8 Jan 2013 05:35:07 +0000 (21:35 -0800)
committerJohan Tibell <johan.tibell@gmail.com>
Tue, 8 Jan 2013 05:35:07 +0000 (21:35 -0800)
testsuite/driver/testlib.py
testsuite/tests/codeGen/should_run/Word2Float32.hs [new file with mode: 0644]
testsuite/tests/codeGen/should_run/Word2Float32.stdout [new file with mode: 0644]
testsuite/tests/codeGen/should_run/Word2Float64.hs [moved from testsuite/tests/codeGen/should_run/Word2Float.hs with 100% similarity]
testsuite/tests/codeGen/should_run/Word2Float64.stdout [moved from testsuite/tests/codeGen/should_run/Word2Float.stdout with 100% similarity]
testsuite/tests/codeGen/should_run/all.T

index 4bdcd2d..43a2073 100644 (file)
@@ -342,6 +342,12 @@ def if_wordsize( ws, f ):
     else:
         return normal
 
+def unless_wordsize( ws, f ):
+    if config.wordsize == str(ws):
+        return normal
+    else:
+        return f
+
 def if_msys( f ):
     if config.msys:
         return f
diff --git a/testsuite/tests/codeGen/should_run/Word2Float32.hs b/testsuite/tests/codeGen/should_run/Word2Float32.hs
new file mode 100644 (file)
index 0000000..62a738a
--- /dev/null
@@ -0,0 +1,17 @@
+{-# LANGUAGE MagicHash #-}
+module Main (main) where
+
+import GHC.Exts (Double(D#), Float(F#), word2Double#, word2Float#)
+
+main :: IO ()
+main = do
+    print (D# (word2Double# 0##))
+    -- 4294967295 is 2^32 - 1, the largest 32-bit integer, and can be
+    -- stored in a 64-bit IEEE floating-point value without loss of
+    -- precision.
+    print (D# (word2Double# 4294967295##))
+    print (F# (word2Float# 0##))
+    -- 16777216 is 2^24, which is the largest integer which can be
+    -- stored in a 32-bit IEEE floating-point value without loss of
+    -- precision
+    print (F# (word2Float# 16777216##))
diff --git a/testsuite/tests/codeGen/should_run/Word2Float32.stdout b/testsuite/tests/codeGen/should_run/Word2Float32.stdout
new file mode 100644 (file)
index 0000000..f558bbe
--- /dev/null
@@ -0,0 +1,4 @@
+0.0
+4.294967295e9
+0.0
+1.6777216e7
index ef9326e..1a5733d 100644 (file)
@@ -100,4 +100,5 @@ test('T7319', [ extra_ways(['prof']), only_ways(['prof']), exit_code(1),
                 req_profiling,
                 extra_hc_opts('-fprof-auto'),
                 extra_run_opts('+RTS -xc') ], compile_and_run, [''])
-test('Word2Float', normal, compile_and_run, [''])
+test('Word2Float32', unless_wordsize(32, skip), compile_and_run, [''])
+test('Word2Float64', unless_wordsize(64, skip), compile_and_run, [''])