Skip to content

Commit b4b75e1

Browse files
committed
Try a more robust way to de-flappy this test.
1 parent 20d3fc8 commit b4b75e1

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

S17-supply/syntax.t

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,29 +333,30 @@ plan 55;
333333
my $trigger1 = Supplier.new;
334334
my $trigger2 = Supplier.new;
335335

336-
my $lock = Lock.new;
337-
my $cv1 = $lock.condition;
338-
my $cv2 = $lock.condition;
336+
my $p1 = Promise.new;
337+
my $p2 = Promise.new;
338+
my $p3 = Promise.new;
339339

340340
my $s = supply {
341341
whenever $trigger1 -> $value {
342-
$lock.protect({ $cv1.signal; $cv2.wait });
342+
$p1.keep(True);
343+
await $p2;
343344
emit "a $value";
344345
}
345346
whenever $trigger2 -> $value {
346347
emit "the $value";
348+
$p3.keep(True);
347349
}
348350
}
349351

350352
my @collected;
351353
$s.tap({ @collected.push($_) });
352354

353355
start { $trigger1.emit('bear'); }
354-
$lock.protect({ $cv1.wait });
356+
await $p1;
355357
start { $trigger2.emit('wolf'); }
356-
sleep 0.5;
357-
$lock.protect({ $cv2.signal });
358-
sleep 0.5;
358+
$p2.keep(True);
359+
await $p3;
359360

360361
is @collected, ['a bear', 'the wolf'], 'Can only be in one whatever block at a time';
361362
}

0 commit comments

Comments
 (0)