Skip to content

Instantly share code, notes, and snippets.

@zengargoyle
Created October 25, 2015 19:10
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 zengargoyle/5324c93684d6f5a376a3 to your computer and use it in GitHub Desktop.
Save zengargoyle/5324c93684d6f5a376a3 to your computer and use it in GitHub Desktop.
use Test;
for 1,1,2,2 -> $num, $value {
say "top for loop " ~ "value($value) from channel is num($num)";
my $c = Channel.new;
my $p = start { $c.send($value) };
my $r = start {
await $p;
$c.close;
};
loop {
say "top loop " ~ "value($value) from channel is num($num)";
earliest $c {
more * {
say "top more " ~ "value($value) from channel is num($num)";
is $_, $num, "value($value) from channel is num($num)";
}
done * { last }
}
}
await $r;
}
done-testing;
top for loop value(1) from channel is num(1)
top loop value(1) from channel is num(1)
top more value(1) from channel is num(1)
ok 1 - value(1) from channel is num(1)
top loop value(1) from channel is num(1)
top for loop value(2) from channel is num(2)
top loop value(2) from channel is num(2)
top more value(1) from channel is num(1)
not ok 2 - value(1) from channel is num(1)
# Failed test 'value(1) from channel is num(1)'
# at huh.p6 line 15
# expected: '1'
# got: '2'
top loop value(2) from channel is num(2)
1..2
# Looks like you failed 1 test of 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment