summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore
diff options
context:
space:
mode:
authorJoachim Breitner <mail@joachim-breitner.de>2014-01-27 10:36:34 +0000
committerJoachim Breitner <mail@joachim-breitner.de>2014-02-11 15:36:24 +0000
commit377672ae068f6dbfa0354dfab95f41bdd26b0df4 (patch)
tree4e62517ca95dcb34699c77e4a21724adec4a80f2 /testsuite/tests/simplCore
parent8f16233c154ab0645c4b90f0e4e98204650811c1 (diff)
downloadhaskell-377672ae068f6dbfa0354dfab95f41bdd26b0df4.tar.gz
Test case for RULE map coerce = coerce
(This tests #2110.)
Diffstat (limited to 'testsuite/tests/simplCore')
-rw-r--r--testsuite/tests/simplCore/should_run/T2110.hs28
-rw-r--r--testsuite/tests/simplCore/should_run/T2110.stdout3
-rw-r--r--testsuite/tests/simplCore/should_run/all.T1
3 files changed, 32 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_run/T2110.hs b/testsuite/tests/simplCore/should_run/T2110.hs
new file mode 100644
index 0000000000..fb657818d4
--- /dev/null
+++ b/testsuite/tests/simplCore/should_run/T2110.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE MagicHash #-}
+
+import GHC.Exts
+import Unsafe.Coerce
+
+{-# RULES
+"map/coerce" map coerce = coerce
+ #-}
+
+newtype Age = Age Int
+
+fooAge :: [Int] -> [Age]
+fooAge = map Age
+fooCoerce :: [Int] -> [Age]
+fooCoerce = map coerce
+fooUnsafeCoerce :: [Int] -> [Age]
+fooUnsafeCoerce = map unsafeCoerce
+
+same :: a -> b -> IO ()
+same x y = case reallyUnsafePtrEquality# (unsafeCoerce x) y of
+ 1# -> putStrLn "yes"
+ _ -> putStrLn "no"
+
+main = do
+ let l = [1,2,3]
+ same (fooAge l) l
+ same (fooCoerce l) l
+ same (fooUnsafeCoerce l) l
diff --git a/testsuite/tests/simplCore/should_run/T2110.stdout b/testsuite/tests/simplCore/should_run/T2110.stdout
new file mode 100644
index 0000000000..55f7ebb441
--- /dev/null
+++ b/testsuite/tests/simplCore/should_run/T2110.stdout
@@ -0,0 +1,3 @@
+yes
+yes
+yes
diff --git a/testsuite/tests/simplCore/should_run/all.T b/testsuite/tests/simplCore/should_run/all.T
index 430d61f1c5..6f5751e84b 100644
--- a/testsuite/tests/simplCore/should_run/all.T
+++ b/testsuite/tests/simplCore/should_run/all.T
@@ -51,6 +51,7 @@ test('T5453', normal, compile_and_run, [''])
test('T5441', extra_clean(['T5441a.o','T5441a.hi']),
multimod_compile_and_run, ['T5441',''])
test('T5603', normal, compile_and_run, [''])
+test('T2110', expect_broken(2110), compile_and_run, [''])
# Run these tests *without* optimisation too
test('T5625', [ only_ways(['normal','optasm']), exit_code(1) ], compile_and_run, [''])