[commit: testsuite] master: Add test for #7970 (5bcf82f)

Simon Marlow marlowsd at gmail.com
Tue Jul 2 13:08:31 CEST 2013


Repository : ssh://darcs.haskell.org//srv/darcs/testsuite

On branch  : master

https://github.com/ghc/testsuite/commit/5bcf82fd981c9bfc0277d35a0d5d2db8d2f7d073

>---------------------------------------------------------------

commit 5bcf82fd981c9bfc0277d35a0d5d2db8d2f7d073
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Tue Jul 2 11:27:20 2013 +0100

    Add test for #7970

>---------------------------------------------------------------

 tests/concurrent/should_run/.hpc.conc067/Main.mix |    1 +
 tests/concurrent/should_run/T7970.hs              |   20 ++++++++++++++++++++
 tests/concurrent/should_run/all.T                 |    2 ++
 3 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/tests/concurrent/should_run/.hpc.conc067/Main.mix b/tests/concurrent/should_run/.hpc.conc067/Main.mix
new file mode 100644
index 0000000..39262a5
--- /dev/null
+++ b/tests/concurrent/should_run/.hpc.conc067/Main.mix
@@ -0,0 +1 @@
+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
diff --git a/tests/concurrent/should_run/T7970.hs b/tests/concurrent/should_run/T7970.hs
new file mode 100644
index 0000000..986cb66
--- /dev/null
+++ b/tests/concurrent/should_run/T7970.hs
@@ -0,0 +1,20 @@
+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
diff --git a/tests/concurrent/should_run/all.T b/tests/concurrent/should_run/all.T
index bb2bcd3..8a32c10 100644
--- a/tests/concurrent/should_run/all.T
+++ b/tests/concurrent/should_run/all.T
@@ -233,3 +233,5 @@ test('setnumcapabilities001',
        reqlib('parallel'),
        skip_if_not_smp ],
      compile_and_run, [''])
+
+test('T7970', normal, compile_and_run, [''])





More information about the ghc-commits mailing list