From 929a82aede0062df3b3ca6da29b6c627b4f6cd1b Mon Sep 17 00:00:00 2001 From: simonm <unknown> Date: Mon, 27 Jul 1998 12:38:33 +0000 Subject: [PATCH] [project @ 1998-07-27 12:38:33 by simonm] Add a test for black hole behaviour, where a computation is shared between threads. --- ghc/tests/concurrent/should_run/conc006.hs | 23 +++++++++++++++++++ .../concurrent/should_run/conc006.stdout | 1 + 2 files changed, 24 insertions(+) create mode 100644 ghc/tests/concurrent/should_run/conc006.hs create mode 100644 ghc/tests/concurrent/should_run/conc006.stdout diff --git a/ghc/tests/concurrent/should_run/conc006.hs b/ghc/tests/concurrent/should_run/conc006.hs new file mode 100644 index 000000000000..63008e135c7e --- /dev/null +++ b/ghc/tests/concurrent/should_run/conc006.hs @@ -0,0 +1,23 @@ +module Main where + +import Concurrent + +-- This test hopefully exercises the black hole code. The main thread +-- forks off another thread and starts on a large computation. +-- The child thread attempts to get the result of the same large +-- computation (and should get blocked doing so, because the parent +-- won't have evaluated it yet). When the result is available, the +-- child passes it back to the parent who prints it out. + +test = sum [1..10000] + +main = do + x <- newEmptyMVar + forkIO (if test > 0 + then putMVar x test + else error "proc" + ) + if test > 0 -- evaluate test + then do result <- takeMVar x + print result + else error "main" diff --git a/ghc/tests/concurrent/should_run/conc006.stdout b/ghc/tests/concurrent/should_run/conc006.stdout new file mode 100644 index 000000000000..b9d569380ca1 --- /dev/null +++ b/ghc/tests/concurrent/should_run/conc006.stdout @@ -0,0 +1 @@ +50005000 -- GitLab