Skip to content

Commit b46b2fd

Browse files
committed
Add tests for .cue( :every, :stop )
1 parent 508eb10 commit b46b2fd

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

S17-scheduler/every.t

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use v6;
22
use Test;
33

4-
plan 15;
4+
plan 18;
55

66
# real scheduling here
77
my $name = $*SCHEDULER.^name;
@@ -18,6 +18,23 @@ my $name = $*SCHEDULER.^name;
1818
LEAVE $c.cancel;
1919
}
2020

21+
{
22+
# Also at risk of being a little fragile, but again hopefully OK on all
23+
# but the most ridiculously loaded systems.
24+
my $a = 0;
25+
my $stop;
26+
my $c = $*SCHEDULER.cue({ cas $a, {.succ} }, :every(0.1), :stop({$stop}));
27+
isa_ok $c, Cancellation;
28+
sleep 1;
29+
$stop = True;
30+
31+
diag "seen $a runs" if !
32+
ok 5 < $a < 15, "Cue with :every :stop schedules repeatedly";
33+
my $seen = $a;
34+
diag "seen {$a - $seen} runs after stop" if !
35+
ok $seen <= $a <= $seen + 1, "Cue with :every :stop stops scheduling";
36+
}
37+
2138
{
2239
# Also at risk of being a little fragile, but again hopefully Ok on all
2340
# but the most ridiculously loaded systems.

0 commit comments

Comments
 (0)