Commit 40e10bd0 authored by Simon Marlow's avatar Simon Marlow

Add test for #7970

parent 991a6fdd
Mix "conc067.hs" 2011-07-21 13:37:37 UTC 3869899995 8 [(9:10-9:21,ExpBox False),(10:39-10:39,ExpBox False),(10:29-10:40,ExpBox False),(10:10-10:40,ExpBox False),(11:24-11:24,ExpBox False),(11:17-11:25,ExpBox False),(11:10-11:25,ExpBox False),(12:18-12:20,ExpBox False),(12:22-12:25,ExpBox False),(12:17-12:26,ExpBox False),(12:5-12:26,ExpBox False),(13:16-13:16,ExpBox False),(13:5-13:16,ExpBox False),(14:5-14:10,ExpBox False),(14:20-14:20,ExpBox False),(14:14-14:20,ExpBox False),(14:5-14:20,ExpBox False),(15:13-15:13,ExpBox False),(15:15-15:16,ExpBox False),(15:5-15:16,ExpBox False),(8:8-15:16,ExpBox False),(8:1-15:16,TopLevelBox ["main"])]
\ No newline at end of file
import Control.Exception as E
import Data.IORef
import System.Mem.Weak
import Control.Concurrent
main :: IO ()
main = do
ref <- newIORef 'x'
weak <- mkWeakIORef ref $ putStrLn "IORef finalized"
let check = deRefWeak weak >>= \m -> case m of
Nothing -> putStrLn "IORef was GCed"
Just ref' -> do
x <- readIORef ref'
putStrLn $ "IORef still alive, and contains " ++ show x
m <- newEmptyMVar
check
takeMVar m `catch` \ex -> do
putStrLn $ "caught exception: " ++ show (ex :: SomeException)
check
readIORef ref >>= print
......@@ -233,3 +233,5 @@ test('setnumcapabilities001',
reqlib('parallel'),
skip_if_not_smp ],
compile_and_run, [''])
test('T7970', normal, 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