Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created June 18, 2016 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/de7e5532e218ce3998a77191c0910fb1 to your computer and use it in GitHub Desktop.
Save zoffixznet/de7e5532e218ce3998a77191c0910fb1 to your computer and use it in GitHub Desktop.
use Test;
{
my $supplier = Supplier.new;
my $supply = $supplier.Supply;
my @seen;
$supply.act: { @seen.push: "Fizz" if $_ %% 3 }
$supply.act: { @seen.push: "Buzz" if $_ %% 5 }
$supply.act: { @seen.push: $_ unless $_%%3 || $_%%5 }
await do for 1..20 { start { sleep rand; $supplier.emit($_) } }
is +@seen, 21, 'do we have right number of elements';
is @seen.sort,
"1 2 4 7 8 11 13 14 16 17 19 Buzz Buzz Buzz Buzz Fizz Fizz Fizz Fizz Fizz Fizz",
'did we get the right string';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment