Created
June 18, 2016 18:41
-
-
Save zoffixznet/de7e5532e218ce3998a77191c0910fb1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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