summaryrefslogtreecommitdiff
path: root/testsuite/tests/concurrent/should_run/conc012.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/concurrent/should_run/conc012.hs')
-rw-r--r--testsuite/tests/concurrent/should_run/conc012.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/testsuite/tests/concurrent/should_run/conc012.hs b/testsuite/tests/concurrent/should_run/conc012.hs
new file mode 100644
index 0000000000..a2f139e401
--- /dev/null
+++ b/testsuite/tests/concurrent/should_run/conc012.hs
@@ -0,0 +1,23 @@
+module Main where
+
+import Control.Concurrent
+import Control.Exception
+--import GlaExts
+
+data Result = Died SomeException | Finished
+
+-- Test stack overflow catching. Should print "Died: stack overflow".
+
+stackoverflow :: Int -> Int
+stackoverflow 0 = 1
+stackoverflow n = n + stackoverflow n
+
+main = do
+ let x = stackoverflow 1
+ result <- newEmptyMVar
+ forkIO $ Control.Exception.catch (x `seq` putMVar result Finished) $
+ \e -> putMVar result (Died e)
+ res <- takeMVar result
+ case res of
+ Died e -> putStr ("Died: " ++ show e ++ "\n")
+ Finished -> putStr "Ok.\n"