Skip to content

Commit

Permalink
Test covering first part of RT #130716 solution
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Sep 27, 2017
1 parent 292e1d9 commit ed27a26
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion S17-supply/syntax.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 75;
plan 78;

{
my $s = supply {
Expand Down Expand Up @@ -604,4 +604,34 @@ lives-ok {
is $i, 15, 'react without block works';
}

# RT #130716
{
my @pre-emit;
my $ran-done = True;
sub make-supply() {
supply {
until my $done {
@pre-emit.push('x');
emit(++$);
}
CLOSE { $ran-done = True; $done = True }
}
}

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 supply that syncrhonously emits sees values';
ok $ran-done, 'done block in source supply was run';
is @pre-emit, ['x','x','x','x','x'],
'supply block loop did not run ahead of consumer';
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit ed27a26

Please sign in to comment.