[project @ 1998-10-08 11:37:15 by simonm]
authorsimonm <unknown>
Thu, 8 Oct 1998 11:37:16 +0000 (11:37 +0000)
committersimonm <unknown>
Thu, 8 Oct 1998 11:37:16 +0000 (11:37 +0000)
fix conc004 for new type of forkIO.
add conc007: killThread test.

ghc/tests/concurrent/should_run/conc004.hs
ghc/tests/concurrent/should_run/conc007.hs [new file with mode: 0644]
ghc/tests/concurrent/should_run/conc007.stdout [new file with mode: 0644]

index 2580636..246f898 100644 (file)
@@ -10,7 +10,7 @@ main = do
    mvar <- newEmptyMVar
 
    let 
-       spawner :: (IO () -> IO ()) -> Int -> IO ()
+       spawner :: (IO () -> IO ThreadId) -> Int -> IO ()
        spawner c 0 = putMVar mvar ()
        spawner c n = do { c (spawner c (n-1)); return ()}
 
diff --git a/ghc/tests/concurrent/should_run/conc007.hs b/ghc/tests/concurrent/should_run/conc007.hs
new file mode 100644 (file)
index 0000000..ccd11be
--- /dev/null
@@ -0,0 +1,24 @@
+{-# OPTIONS -fglasgow-exts #-}
+
+module Main where
+
+import Concurrent
+import IOExts
+
+choose :: a -> a -> IO a
+choose a b = do
+   ready <- newMVar ()
+   answer <- newEmptyMVar
+   a_id <- forkIO (a `seq` takeMVar ready >> putMVar answer a)
+   b_id <- forkIO (b `seq` takeMVar ready >> putMVar answer b)
+   it <- takeMVar answer
+   killThread a_id
+   killThread b_id
+   return it
+
+main = do
+   let big = sum [1..]
+       small = sum [1..42]
+   test1 <- choose big small
+   test2 <- choose small big
+   print (test1,test2)
diff --git a/ghc/tests/concurrent/should_run/conc007.stdout b/ghc/tests/concurrent/should_run/conc007.stdout
new file mode 100644 (file)
index 0000000..ee81b5e
--- /dev/null
@@ -0,0 +1 @@
+(903,903)