Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add tests for .cue( :every, :stop )
  • Loading branch information
lizmat committed Oct 29, 2014
1 parent 508eb10 commit b46b2fd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion S17-scheduler/every.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 15;
plan 18;

# real scheduling here
my $name = $*SCHEDULER.^name;
Expand All @@ -18,6 +18,23 @@ my $name = $*SCHEDULER.^name;
LEAVE $c.cancel;
}

{
# Also at risk of being a little fragile, but again hopefully OK on all
# but the most ridiculously loaded systems.
my $a = 0;
my $stop;
my $c = $*SCHEDULER.cue({ cas $a, {.succ} }, :every(0.1), :stop({$stop}));
isa_ok $c, Cancellation;
sleep 1;
$stop = True;

diag "seen $a runs" if !
ok 5 < $a < 15, "Cue with :every :stop schedules repeatedly";
my $seen = $a;
diag "seen {$a - $seen} runs after stop" if !
ok $seen <= $a <= $seen + 1, "Cue with :every :stop stops scheduling";
}

{
# Also at risk of being a little fragile, but again hopefully Ok on all
# but the most ridiculously loaded systems.
Expand Down

0 comments on commit b46b2fd

Please sign in to comment.