@@ -169,8 +169,11 @@ testUnclosure TestTransport{..} rtable = do
169
169
node <- newLocalNode testTransport rtable
170
170
done <- newEmptyMVar
171
171
forkProcess node $ do
172
- 120 <- join . unClosure $ factorialClosure 5
172
+ i <- join . unClosure $ factorialClosure 5
173
173
liftIO $ putMVar done ()
174
+ if i == 720
175
+ then return ()
176
+ else error " Something went horribly wrong"
174
177
takeMVar done
175
178
176
179
testBind :: TestTransport -> RemoteTable -> Assertion
@@ -180,8 +183,11 @@ testBind TestTransport{..} rtable = do
180
183
runProcess node $ do
181
184
us <- getSelfPid
182
185
join . unClosure $ sendFac 6 us
183
- (720 :: Int ) <- expect
186
+ (i :: Int ) <- expect
184
187
liftIO $ putMVar done ()
188
+ if i == 720
189
+ then return ()
190
+ else error " Something went horribly wrong"
185
191
takeMVar done
186
192
187
193
testSendPureClosure :: TestTransport -> RemoteTable -> Assertion
@@ -194,7 +200,7 @@ testSendPureClosure TestTransport{..} rtable = do
194
200
addr <- forkProcess node $ do
195
201
cl <- expect
196
202
fn <- unClosure cl :: Process (Int -> Int )
197
- 13 <- return $ fn 6
203
+ (_ :: Int ) <- return $ fn 6
198
204
liftIO $ putMVar serverDone ()
199
205
putMVar serverAddr addr
200
206
@@ -218,8 +224,11 @@ testSendIOClosure TestTransport{..} rtable = do
218
224
liftIO $ do
219
225
someMVar <- newEmptyMVar
220
226
io someMVar
221
- 5 <- readMVar someMVar
227
+ i <- readMVar someMVar
222
228
putMVar serverDone ()
229
+ if i == 5
230
+ then return ()
231
+ else error " Something went horribly wrong"
223
232
putMVar serverAddr addr
224
233
225
234
forkIO $ do
@@ -248,8 +257,10 @@ testSendProcClosure TestTransport{..} rtable = do
248
257
runProcess node $ do
249
258
pid <- getSelfPid
250
259
send theirAddr (cpSend $ (mkStatic 'sdictInt) pid)
251
- 5 <- expect :: Process Int
252
- liftIO $ putMVar clientDone ()
260
+ i <- expect :: Process Int
261
+ if i == 5
262
+ then liftIO $ putMVar clientDone ()
263
+ else error " Something went horribly wrong"
253
264
254
265
takeMVar clientDone
255
266
@@ -269,8 +280,9 @@ testSpawn TestTransport{..} rtable = do
269
280
pid <- getSelfPid
270
281
pid' <- spawn nid (sendPidClosure pid)
271
282
pid'' <- expect
272
- True <- return $ pid' == pid''
273
- liftIO $ putMVar clientDone ()
283
+ if pid' == pid''
284
+ then liftIO $ putMVar clientDone ()
285
+ else error " Something went horribly wrong"
274
286
275
287
takeMVar clientDone
276
288
@@ -294,8 +306,9 @@ testSpawnRace TestTransport{..} rtable = do
294
306
spawnLocal $ spawn (localNodeId node2) (sendPidClosure pid) >>= send pid
295
307
pid' <- expect :: Process ProcessId
296
308
pid'' <- expect :: Process ProcessId
297
- True <- return $ pid' == pid''
298
- return ()
309
+ if pid' == pid''
310
+ then return ()
311
+ else error " Something went horribly wrong"
299
312
300
313
where
301
314
@@ -332,8 +345,10 @@ testCall TestTransport{..} rtable = do
332
345
node <- newLocalNode testTransport rtable
333
346
nid <- readMVar serverNodeAddr
334
347
runProcess node $ do
335
- (120 :: Int ) <- call $ (mkStatic 'sdictInt) nid (factorialClosure 5 )
336
- liftIO $ putMVar clientDone ()
348
+ (a :: Int ) <- call $ (mkStatic 'sdictInt) nid (factorialClosure 5 )
349
+ if a == 120
350
+ then liftIO $ putMVar clientDone ()
351
+ else error " something went horribly wrong"
337
352
338
353
takeMVar clientDone
339
354
@@ -350,8 +365,10 @@ testCallBind TestTransport{..} rtable = do
350
365
node <- newLocalNode testTransport rtable
351
366
nid <- readMVar serverNodeAddr
352
367
runProcess node $ do
353
- (120 :: Int ) <- call $ (mkStatic 'sdictInt) nid (factorial' 5 )
354
- liftIO $ putMVar clientDone ()
368
+ (a :: Int ) <- call $ (mkStatic 'sdictInt) nid (factorial' 5 )
369
+ if a == 120
370
+ then liftIO $ putMVar clientDone ()
371
+ else error " Something went horribly wrong"
355
372
356
373
takeMVar clientDone
357
374
@@ -362,9 +379,11 @@ testSeq TestTransport{..} rtable = do
362
379
runProcess node $ do
363
380
us <- getSelfPid
364
381
join . unClosure $ sendFac 5 us `seqCP` sendFac 6 us
365
- 120 :: Int <- expect
366
- 720 :: Int <- expect
367
- liftIO $ putMVar done ()
382
+ a :: Int <- expect
383
+ b :: Int <- expect
384
+ if a == 120 && b == 720
385
+ then liftIO $ putMVar done ()
386
+ else error " Something went horribly wrong"
368
387
takeMVar done
369
388
370
389
-- Test 'spawnSupervised'
@@ -407,12 +426,15 @@ testSpawnSupervised TestTransport{..} rtable = do
407
426
liftIO $ putMVar linkUp ()
408
427
-- because monitor message was sent before message to process
409
428
-- we hope that it will be processed before
410
- ProcessMonitorNotification ref' pid' (DiedException e) <- expect
411
- True <- return $ ref' == ref
412
- && pid' == child
413
- && e == show (ProcessLinkException super (DiedException (show supervisorDeath)))
414
- liftIO $ putMVar thirdProcessDone ()
415
-
429
+ res <- expect
430
+ case res of
431
+ (ProcessMonitorNotification ref' pid' (DiedException e)) ->
432
+ if (ref' == ref && pid' == child &&
433
+ e == show (ProcessLinkException super
434
+ (DiedException (show supervisorDeath))))
435
+ then liftIO $ putMVar thirdProcessDone ()
436
+ else error " Something went horribly wrong"
437
+ _ -> error " Something went horribly wrong"
416
438
takeMVar thirdProcessDone
417
439
where
418
440
supervisorDeath :: IOException
@@ -426,8 +448,10 @@ testSpawnInvalid TestTransport{..} rtable = do
426
448
(pid, ref) <- spawnMonitor (localNodeId node) (closure (staticLabel " ThisDoesNotExist" ) empty)
427
449
ProcessMonitorNotification ref' pid' _reason <- expect
428
450
-- Depending on the exact interleaving, reason might be NoProc or the exception thrown by the absence of the static closure
429
- True <- return $ ref' == ref && pid == pid'
430
- liftIO $ putMVar done ()
451
+ res <- return $ ref' == ref && pid == pid'
452
+ if res == True
453
+ then liftIO $ putMVar done ()
454
+ else error " Something went horribly wrong"
431
455
takeMVar done
432
456
433
457
testClosureExpect :: TestTransport -> RemoteTable -> Assertion
@@ -439,8 +463,10 @@ testClosureExpect TestTransport{..} rtable = do
439
463
us <- getSelfPid
440
464
them <- spawn nodeId $ cpExpect $ (mkStatic 'sdictInt) `bindCP` cpSend $ (mkStatic 'sdictInt) us
441
465
send them (1234 :: Int )
442
- (1234 :: Int ) <- expect
443
- liftIO $ putMVar done ()
466
+ (res :: Int ) <- expect
467
+ if res == 1234
468
+ then liftIO $ putMVar done ()
469
+ else error " Something went horribly wrong"
444
470
takeMVar done
445
471
446
472
testSpawnChannel :: TestTransport -> RemoteTable -> Assertion
@@ -465,8 +491,10 @@ testTDict TestTransport{..} rtable = do
465
491
done <- newEmptyMVar
466
492
[node1, node2] <- replicateM 2 $ newLocalNode testTransport rtable
467
493
forkProcess node1 $ do
468
- True <- call $ (functionTDict 'isPrime) (localNodeId node2) ($ (mkClosure 'isPrime) (79 :: Integer ))
469
- liftIO $ putMVar done ()
494
+ res <- call $ (functionTDict 'isPrime) (localNodeId node2) ($ (mkClosure 'isPrime) (79 :: Integer ))
495
+ if res == True
496
+ then liftIO $ putMVar done ()
497
+ else error " Something went horribly wrong..."
470
498
takeMVar done
471
499
472
500
testFib :: TestTransport -> RemoteTable -> Assertion
@@ -503,9 +531,12 @@ testSpawnReconnect testtrans@TestTransport{..} rtable = do
503
531
liftIO $ threadDelay 100000
504
532
505
533
count <- liftIO $ takeMVar iv
506
- True <- return $ count == 2 || count == 3 -- It depends on which message we get first in 'spawn'
534
+ res <- return $ count == 2 || count == 3 -- It depends on which message we get first in 'spawn'
507
535
508
536
liftIO $ putMVar done ()
537
+ if res /= True
538
+ then error " Something went horribly wrong"
539
+ else return ()
509
540
510
541
takeMVar done
511
542
0 commit comments