Skip to content

Commit ef5cb4d

Browse files
Implement a test for unsafeUSend.
1 parent e2c5dff commit ef5cb4d

File tree

1 file changed

+21
-0
lines changed
  • distributed-process-tests/src/Control/Distributed/Process/Tests

1 file changed

+21
-0
lines changed

distributed-process-tests/src/Control/Distributed/Process/Tests/CH.hs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,26 @@ testUnsafeSend TestTransport{..} = do
13851385

13861386
takeMVar clientDone
13871387

1388+
testUnsafeUSend :: TestTransport -> Assertion
1389+
testUnsafeUSend TestTransport{..} = do
1390+
serverAddr <- newEmptyMVar
1391+
clientDone <- newEmptyMVar
1392+
1393+
localNode <- newLocalNode testTransport initRemoteTable
1394+
void $ forkProcess localNode $ do
1395+
self <- getSelfPid
1396+
liftIO $ putMVar serverAddr self
1397+
clientAddr <- expect
1398+
unsafeUSend clientAddr ()
1399+
1400+
void $ forkProcess localNode $ do
1401+
serverPid <- liftIO $ takeMVar serverAddr
1402+
getSelfPid >>= unsafeUSend serverPid
1403+
() <- expect
1404+
liftIO $ putMVar clientDone ()
1405+
1406+
takeMVar clientDone
1407+
13881408
testUnsafeNSend :: TestTransport -> Assertion
13891409
testUnsafeNSend TestTransport{..} = do
13901410
clientDone <- newEmptyMVar
@@ -1539,6 +1559,7 @@ tests testtrans = return [
15391559
, testCase "TextCallLocal" (testCallLocal testtrans)
15401560
-- Unsafe Primitives
15411561
, testCase "TestUnsafeSend" (testUnsafeSend testtrans)
1562+
, testCase "TestUnsafeUSend" (testUnsafeUSend testtrans)
15421563
, testCase "TestUnsafeNSend" (testUnsafeNSend testtrans)
15431564
, testCase "TestUnsafeSendChan" (testUnsafeSendChan testtrans)
15441565
-- usend

0 commit comments

Comments
 (0)