Skip to content

Commit 5fbc8ba

Browse files
committed
Tests to cover RT #130716
1 parent 12e6a25 commit 5fbc8ba

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

S17-supply/syntax.t

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

4-
plan 78;
4+
plan 81;
55

66
{
77
my $s = supply {
@@ -633,5 +633,34 @@ lives-ok {
633633
is @pre-emit, ['x','x','x','x','x'],
634634
'supply block loop did not run ahead of consumer';
635635
}
636+
{
637+
my $pre-emits = 0;
638+
my $post-emits = 0;
639+
sub make-supply() {
640+
supply {
641+
loop {
642+
$pre-emits++;
643+
emit(++$);
644+
$post-emits++;
645+
}
646+
}
647+
}
648+
649+
my $s2 = make-supply;
650+
my @received;
651+
react {
652+
whenever $s2 -> $n {
653+
push @received, $n;
654+
done if $n >= 5;
655+
}
656+
}
657+
658+
is @received, [1,2,3,4,5],
659+
'whenever tapping infinitely emitting synchronous supply terminates';
660+
is $pre-emits, 6,
661+
'supply block loop is terminated on emit to dead consumer (1)';
662+
is $post-emits, 5,
663+
'supply block loop is terminated on emit to dead consumer (2)';
664+
}
636665

637666
# vim: ft=perl6 expandtab sw=4

0 commit comments

Comments
 (0)