Skip to content

Commit

Permalink
unbreak tests (removal of block/unblock)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmar committed May 10, 2013
1 parent 640750a commit 1527869
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 19 deletions.
11 changes: 5 additions & 6 deletions tests/concurrent/should_run/conc015.hs
Expand Up @@ -12,7 +12,7 @@ import Control.Exception

main = do
main_thread <- myThreadId
print =<< blocked -- False
print =<< getMaskingState -- False
m <- newEmptyMVar
m2 <- newEmptyMVar
forkIO (do takeMVar m
Expand All @@ -21,19 +21,18 @@ main = do
putMVar m2 ()
)
( do
block (do
mask $ \restore -> do
putMVar m ()
print =<< blocked -- True
print =<< getMaskingState -- True
sum [1..1] `seq` -- give 'foo' a chance to be raised
(unblock $ myDelay 500000)
(restore $ myDelay 500000)
`Control.Exception.catch`
\e -> putStrLn ("caught1: " ++ show (e::SomeException))
)
threadDelay 10000
takeMVar m2
)
`Control.Exception.catch`
\e -> do print =<< blocked
\e -> do print =<< getMaskingState
putStrLn ("caught2: " ++ show (e::SomeException))

-- compensate for the fact that threadDelay is non-interruptible
Expand Down
6 changes: 3 additions & 3 deletions tests/concurrent/should_run/conc015.stdout
@@ -1,5 +1,5 @@
False
True
Unmasked
MaskedInterruptible
caught1: foo
True
MaskedInterruptible
caught2: bar
5 changes: 2 additions & 3 deletions tests/concurrent/should_run/conc017.hs
Expand Up @@ -17,9 +17,9 @@ main = do
putMVar m3 ()
)
(do
block (do
mask $ \restore -> do
(do putMVar m1 ()
unblock (
restore (
-- unblocked, "foo" delivered to "caught1"
myDelay 100000
)
Expand All @@ -30,7 +30,6 @@ main = do
(sum [1..10000] `seq` return ())
`Control.Exception.catch`
\e -> putStrLn ("caught2: " ++ show (e::SomeException))
)
-- unblocked here, "bar" delivered to "caught3"
takeMVar m3
)
Expand Down
2 changes: 1 addition & 1 deletion tests/concurrent/should_run/conc020.hs
Expand Up @@ -3,7 +3,7 @@ import Control.Exception

main = do
m <- newEmptyMVar
t <- forkIO (block $ takeMVar m)
t <- forkIO (mask_ $ takeMVar m)
threadDelay 100000
throwTo t (ErrorCall "I'm Interruptible")
threadDelay 100000
Expand Down
2 changes: 1 addition & 1 deletion tests/concurrent/should_run/conc035.hs
Expand Up @@ -5,7 +5,7 @@ import qualified Control.Exception as E

trapHandler :: MVar Int -> MVar () -> IO ()
trapHandler inVar caughtVar =
(do E.block $ do
(do E.mask_ $ do
trapMsg <- takeMVar inVar
putStrLn ("Handler got: " ++ show trapMsg)
trapHandler inVar caughtVar
Expand Down
2 changes: 1 addition & 1 deletion tests/concurrent/should_run/conc058.hs
Expand Up @@ -6,7 +6,7 @@ import Control.Exception
-- not interruptible.
main = do
m <- newEmptyMVar
t <- forkIO (block $ threadDelay 1000000)
t <- forkIO (mask_ $ threadDelay 1000000)
threadDelay 100000
throwTo t (ErrorCall "I'm Interruptible")
threadDelay 100000
Expand Down
2 changes: 1 addition & 1 deletion tests/concurrent/should_run/conc065.hs
Expand Up @@ -6,7 +6,7 @@ import Control.Exception
-- This loop spends most of its time printing stuff, and very occasionally
-- pops outside 'block'. This test ensures that an thread trying to
-- throwTo this thread will eventually succeed.
loop = block (print "alive") >> loop
loop = mask_ (print "alive") >> loop

main = do tid <- forkIO loop
threadDelay 1
Expand Down
4 changes: 2 additions & 2 deletions tests/concurrent/should_run/conc066.hs
Expand Up @@ -6,8 +6,8 @@ import Control.Exception
-- This loop spends most of its time printing stuff, and very occasionally
-- executes 'unblock (return ())'. This test ensures that a thread waiting
-- to throwTo this thread is not blocked indefinitely.
loop = do unblock (return ()); print "alive"; loop
loop restore = do restore (return ()); print "alive"; loop restore

main = do tid <- forkIO (block loop)
main = do tid <- forkIO (mask $ \restore -> loop restore)
yield
killThread tid
2 changes: 1 addition & 1 deletion tests/concurrent/should_run/conc068.hs
Expand Up @@ -6,7 +6,7 @@ import GHC.Conc
main = do
main_thread <- myThreadId
m <- newEmptyMVar
sub_thread <- block $ forkIO $
sub_thread <- mask_ $ forkIO $
sum [1..100000] `seq`
throwTo main_thread (ErrorCall "foo")
killThread sub_thread
Expand Down

0 comments on commit 1527869

Please sign in to comment.