diff options
author | Johan Tibell <johan.tibell@gmail.com> | 2013-01-07 21:35:07 -0800 |
---|---|---|
committer | Johan Tibell <johan.tibell@gmail.com> | 2013-01-07 21:35:07 -0800 |
commit | 744035fdd4b882c17ef7c6e4439b9e7099e7ec3d (patch) | |
tree | 6e36d3ecd2d630ade8112f9589a20f0df0f8d14f /testsuite/tests/codeGen | |
parent | 83bfdc2f31af32477a6c486b952eb646981fe2e0 (diff) | |
download | haskell-744035fdd4b882c17ef7c6e4439b9e7099e7ec3d.tar.gz |
Fix Word2Float# test on 32-bit
Diffstat (limited to 'testsuite/tests/codeGen')
-rw-r--r-- | testsuite/tests/codeGen/should_run/Word2Float32.hs | 17 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/Word2Float32.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/Word2Float64.hs (renamed from testsuite/tests/codeGen/should_run/Word2Float.hs) | 0 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/Word2Float64.stdout (renamed from testsuite/tests/codeGen/should_run/Word2Float.stdout) | 0 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/all.T | 3 |
5 files changed, 23 insertions, 1 deletions
diff --git a/testsuite/tests/codeGen/should_run/Word2Float32.hs b/testsuite/tests/codeGen/should_run/Word2Float32.hs new file mode 100644 index 0000000000..62a738aa5a --- /dev/null +++ b/testsuite/tests/codeGen/should_run/Word2Float32.hs @@ -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 index 0000000000..f558bbe42f --- /dev/null +++ b/testsuite/tests/codeGen/should_run/Word2Float32.stdout @@ -0,0 +1,4 @@ +0.0 +4.294967295e9 +0.0 +1.6777216e7 diff --git a/testsuite/tests/codeGen/should_run/Word2Float.hs b/testsuite/tests/codeGen/should_run/Word2Float64.hs index 9fd98d6653..9fd98d6653 100644 --- a/testsuite/tests/codeGen/should_run/Word2Float.hs +++ b/testsuite/tests/codeGen/should_run/Word2Float64.hs diff --git a/testsuite/tests/codeGen/should_run/Word2Float.stdout b/testsuite/tests/codeGen/should_run/Word2Float64.stdout index d15538e3d5..d15538e3d5 100644 --- a/testsuite/tests/codeGen/should_run/Word2Float.stdout +++ b/testsuite/tests/codeGen/should_run/Word2Float64.stdout diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T index ef9326e66a..1a5733d26c 100644 --- a/testsuite/tests/codeGen/should_run/all.T +++ b/testsuite/tests/codeGen/should_run/all.T @@ -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, ['']) |