From 5fbc8ba3fda5e17f42752c8fabd9d357a6761ba1 Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Wed, 27 Sep 2017 18:13:12 +0200 Subject: [PATCH] Tests to cover RT #130716 --- S17-supply/syntax.t | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/S17-supply/syntax.t b/S17-supply/syntax.t index 497b6d2117..a599653331 100644 --- a/S17-supply/syntax.t +++ b/S17-supply/syntax.t @@ -1,7 +1,7 @@ use v6; use Test; -plan 78; +plan 81; { my $s = supply { @@ -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