Skip to content

Commit ed27a26

Browse files
committed
Test covering first part of RT #130716 solution
1 parent 292e1d9 commit ed27a26

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

S17-supply/syntax.t

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

4-
plan 75;
4+
plan 78;
55

66
{
77
my $s = supply {
@@ -604,4 +604,34 @@ lives-ok {
604604
is $i, 15, 'react without block works';
605605
}
606606

607+
# RT #130716
608+
{
609+
my @pre-emit;
610+
my $ran-done = True;
611+
sub make-supply() {
612+
supply {
613+
until my $done {
614+
@pre-emit.push('x');
615+
emit(++$);
616+
}
617+
CLOSE { $ran-done = True; $done = True }
618+
}
619+
}
620+
621+
my $s2 = make-supply;
622+
my @received;
623+
react {
624+
whenever $s2 -> $n {
625+
push @received, $n;
626+
done if $n >= 5;
627+
}
628+
}
629+
630+
is @received, [1,2,3,4,5],
631+
'whenever tapping supply that syncrhonously emits sees values';
632+
ok $ran-done, 'done block in source supply was run';
633+
is @pre-emit, ['x','x','x','x','x'],
634+
'supply block loop did not run ahead of consumer';
635+
}
636+
607637
# vim: ft=perl6 expandtab sw=4

0 commit comments

Comments
 (0)