@@ -15,7 +15,7 @@ import Control.Concurrent.MVar
1515 , takeMVar
1616 , readMVar
1717 )
18−import Control.Monad (replicateM_, replicateM, forever)
18+import Control.Monad (replicateM_, replicateM, forever, void)
1919import Control.Exception (SomeException, throwIO)
2020import qualified Control.Exception as Ex (catch)
2121import Control.Applicative ((<$>), (<*>), pure, (<|>))
@@ -39,6 +39,8 @@ import Control.Distributed.Process.Serializable (Serializable)
3939import Test.HUnit (Assertion)
4040import Test.Framework (Test, defaultMain, testGroup)
4141import Test.Framework.Providers.HUnit (testCase)
42+import Control.Rematch hiding (expect, match)
43+import qualified Control.Rematch as Rematch (expect)
4244
4345newtype Ping = Ping ProcessId
4446 deriving (Typeable, Binary, Show)
@@ -1074,6 +1076,20 @@ testCatches transport = do
10741076
10751077 takeMVar done
10761078
1079+testMaskRestoreScope :: NT.Transport -> Assertion
1080+testMaskRestoreScope transport = do
1081+ localNode <- newLocalNode transport initRemoteTable
1082+ parentPid <- newEmptyMVar :: IO (MVar ProcessId)
1083+ spawnedPid <- newEmptyMVar :: IO (MVar ProcessId)
1084+
1085+ void $ runProcess localNode $ mask $ \unmask -> do
1086+ getSelfPid >>= liftIO . putMVar parentPid
1087+ void $ spawnLocal $ unmask (getSelfPid >>= liftIO . putMVar spawnedPid)
1088+
1089+ parent <- liftIO $ takeMVar parentPid
1090+ child <- liftIO $ takeMVar spawnedPid
1091+ Rematch.expect parent $ isNot $ equalTo child
1092+
10771093testDie :: NT.Transport -> Assertion
10781094testDie transport = do
10791095 localNode <- newLocalNode transport initRemoteTable
@@ -1178,6 +1194,7 @@ tests (transport, transportInternals) = [
11781194 , testCase "PrettyExit" (testPrettyExit transport)
11791195 , testCase "CatchesExit" (testCatchesExit transport)
11801196 , testCase "Catches" (testCatches transport)
1197+ , testCase "MaskRestoreScope" (testMaskRestoreScope transport)
11811198 , testCase "ExitLocal" (testExitLocal transport)
11821199 , testCase "ExitRemote" (testExitRemote transport)
11831200 ]