Commit 377672ae authored by Joachim Breitner's avatar Joachim Breitner
Browse files

Test case for RULE map coerce = coerce

(This tests #2110.)
parent 8f16233c
{-# 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
...@@ -51,6 +51,7 @@ test('T5453', normal, compile_and_run, ['']) ...@@ -51,6 +51,7 @@ test('T5453', normal, compile_and_run, [''])
test('T5441', extra_clean(['T5441a.o','T5441a.hi']), test('T5441', extra_clean(['T5441a.o','T5441a.hi']),
multimod_compile_and_run, ['T5441','']) multimod_compile_and_run, ['T5441',''])
test('T5603', normal, compile_and_run, ['']) test('T5603', normal, compile_and_run, [''])
test('T2110', expect_broken(2110), compile_and_run, [''])
# Run these tests *without* optimisation too # Run these tests *without* optimisation too
test('T5625', [ only_ways(['normal','optasm']), exit_code(1) ], compile_and_run, ['']) test('T5625', [ only_ways(['normal','optasm']), exit_code(1) ], compile_and_run, [''])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment