Skip to content

Commit

Permalink
Tests to cover RT #130716
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Sep 27, 2017
1 parent 12e6a25 commit 5fbc8ba
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion S17-supply/syntax.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 78;
plan 81;

{
my $s = supply {
Expand Down Expand Up @@ -633,5 +633,34 @@ lives-ok {
is @pre-emit, ['x','x','x','x','x'],
'supply block loop did not run ahead of consumer';
}
{
my $pre-emits = 0;
my $post-emits = 0;
sub make-supply() {
supply {
loop {
$pre-emits++;
emit(++$);
$post-emits++;
}
}
}

my $s2 = make-supply;
my @received;
react {
whenever $s2 -> $n {
push @received, $n;
done if $n >= 5;
}
}

is @received, [1,2,3,4,5],
'whenever tapping infinitely emitting synchronous supply terminates';
is $pre-emits, 6,
'supply block loop is terminated on emit to dead consumer (1)';
is $post-emits, 5,
'supply block loop is terminated on emit to dead consumer (2)';
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit 5fbc8ba

Please sign in to comment.