diff options
author | Simon Marlow <marlowsd@gmail.com> | 2012-12-13 08:23:49 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2012-12-13 08:24:22 +0000 |
commit | ec335ed4d90deffc80b7df9558468ad2f8c1d3ac (patch) | |
tree | fd8efbf5e9116372df4d541d8343ae903fe0ccec /libraries/base/tests/qsemn001.hs | |
parent | 65d4f18c0a2dc4d4f591358701132e2f077783b1 (diff) | |
download | haskell-ec335ed4d90deffc80b7df9558468ad2f8c1d3ac.tar.gz |
fix qsem001 & qsemn001
Diffstat (limited to 'libraries/base/tests/qsemn001.hs')
-rw-r--r-- | libraries/base/tests/qsemn001.hs | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/libraries/base/tests/qsemn001.hs b/libraries/base/tests/qsemn001.hs index db44bbbb49..c98f62e937 100644 --- a/libraries/base/tests/qsemn001.hs +++ b/libraries/base/tests/qsemn001.hs @@ -33,61 +33,61 @@ tests = [ semn :: Assertion semn = do - c <- newTChanIO + c <- newEmptyMVar q <- new 0 - t1 <- forkIO $ do wait q 1; atomically $ writeTChan c 'a' + t1 <- forkIO $ do wait q 1; putMVar c 'a' threadDelay 10000 - t2 <- forkIO $ do wait q 2; atomically $ writeTChan c 'b' + t2 <- forkIO $ do wait q 2; putMVar c 'b' threadDelay 10000 - t3 <- forkIO $ do wait q 3; atomically $ writeTChan c 'c' + t3 <- forkIO $ do wait q 3; putMVar c 'c' threadDelay 10000 signal q 1 - a <- atomically $ readTChan c + a <- takeMVar c signal q 2 - b <- atomically $ readTChan c + b <- takeMVar c signal q 3 - c <- atomically $ readTChan c + c <- takeMVar c [a,b,c] @?= "abc" semn2 :: Assertion semn2 = do - c <- newTChanIO + c <- newEmptyMVar q <- new 0 - t1 <- forkIO $ do wait q 1; threadDelay 10000; atomically $ writeTChan c 'a' + t1 <- forkIO $ do wait q 1; threadDelay 10000; putMVar c 'a' threadDelay 10000 - t2 <- forkIO $ do wait q 2; threadDelay 20000; atomically $ writeTChan c 'b' + t2 <- forkIO $ do wait q 2; threadDelay 20000; putMVar c 'b' threadDelay 10000 - t3 <- forkIO $ do wait q 3; threadDelay 30000; atomically $ writeTChan c 'c' + t3 <- forkIO $ do wait q 3; threadDelay 30000; putMVar c 'c' threadDelay 10000 signal q 6 - a <- atomically $ readTChan c - b <- atomically $ readTChan c - c <- atomically $ readTChan c + a <- takeMVar c + b <- takeMVar c + c <- takeMVar c [a,b,c] @?= "abc" semn3 :: Assertion semn3 = do - c <- newTChanIO + c <- newEmptyMVar q <- new 0 - t1 <- forkIO $ do wait q 1; threadDelay 10000; atomically $ writeTChan c 'a' + t1 <- forkIO $ do wait q 1; threadDelay 10000; putMVar c 'a' threadDelay 10000 - t2 <- forkIO $ do wait q 2; threadDelay 20000; atomically $ writeTChan c 'b' + t2 <- forkIO $ do wait q 2; threadDelay 20000; putMVar c 'b' threadDelay 10000 - t3 <- forkIO $ do wait q 3; threadDelay 30000; atomically $ writeTChan c 'c' + t3 <- forkIO $ do wait q 3; threadDelay 30000; putMVar c 'c' threadDelay 10000 signal q 3 - a <- atomically $ readTChan c - b <- atomically $ readTChan c + a <- takeMVar c + b <- takeMVar c threadDelay 10000 [a,b] @?= "ab" - d <- atomically $ isEmptyTChan c + d <- isEmptyMVar c d @?= True signal q 1 threadDelay 10000 - d <- atomically $ isEmptyTChan c + d <- isEmptyMVar c d @?= True signal q 2 - x <- atomically $ readTChan c + x <- takeMVar c x @?= 'c' semn_kill :: Assertion |