[commit: base] master: fix qsem001 & qsemn001 (829dcf8)
Simon Marlow
marlowsd at gmail.com
Thu Dec 13 09:24:35 CET 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/829dcf8f359ba1efbb58e4c679454c87824fef65
>---------------------------------------------------------------
commit 829dcf8f359ba1efbb58e4c679454c87824fef65
Author: Simon Marlow <marlowsd at gmail.com>
Date: Thu Dec 13 08:23:49 2012 +0000
fix qsem001 & qsemn001
>---------------------------------------------------------------
tests/qsem001.stdout | 5 +++++
tests/qsemn001.hs | 46 +++++++++++++++++++++++-----------------------
tests/qsemn001.stdout | 5 +++++
3 files changed, 33 insertions(+), 23 deletions(-)
diff --git a/tests/qsem001.stdout b/tests/qsem001.stdout
new file mode 100644
index 0000000..5a569f7
--- /dev/null
+++ b/tests/qsem001.stdout
@@ -0,0 +1,5 @@
+test sem1
+test sem2
+test sem_kill
+test sem_fifo
+test sem_bracket
diff --git a/tests/qsemn001.hs b/tests/qsemn001.hs
index db44bbb..c98f62e 100644
--- a/tests/qsemn001.hs
+++ b/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
diff --git a/tests/qsemn001.stdout b/tests/qsemn001.stdout
new file mode 100644
index 0000000..7b7dd94
--- /dev/null
+++ b/tests/qsemn001.stdout
@@ -0,0 +1,5 @@
+test semn
+test semn2
+test semn3
+test semn_kill
+test semn_bracket
More information about the Cvs-libraries
mailing list