File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,26 @@ test_cancelParallel = do
202
202
log (if v then " Success: Canceling composite of two Parallel succeeded"
203
203
else " Failure: Canceling composite of two Parallel failed" )
204
204
205
+ test_cancelRaceLeft :: TestAVar Unit
206
+ test_cancelRaceLeft = do
207
+ var <- makeVar
208
+ c <- sequential
209
+ $ parallel (later' 250 $ putVar var true )
210
+ <|> parallel (later' 100 $ pure unit)
211
+ later' 500 $ putVar var false
212
+ l <- takeVar var
213
+ when l $ throwError (error " Failure: left side ran even though it lost the race" )
214
+
215
+ test_cancelRaceRight :: TestAVar Unit
216
+ test_cancelRaceRight = do
217
+ var <- makeVar
218
+ c <- sequential
219
+ $ parallel (later' 100 $ pure unit)
220
+ <|> parallel (later' 250 $ putVar var true )
221
+ later' 500 $ putVar var false
222
+ l <- takeVar var
223
+ when l $ throwError (error " Failure: right side ran even though it lost the race" )
224
+
205
225
test_syncTailRecM :: TestAVar Unit
206
226
test_syncTailRecM = do
207
227
v <- makeVar' false
@@ -305,6 +325,12 @@ main = do
305
325
log " Testing cancel of Parallel (<|>)"
306
326
test_cancelParallel
307
327
328
+ log " Testing cancel of left branch in parallel (<|>)"
329
+ test_cancelRaceLeft
330
+
331
+ log " Testing cancel of right branch in parallel (<|>)"
332
+ test_cancelRaceRight
333
+
308
334
log " Testing synchronous tailRecM"
309
335
test_syncTailRecM
310
336
You can’t perform that action at this time.
0 commit comments