Skip to content

Commit

Permalink
bring winner.t up to latest spec and unfudge
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Dec 18, 2013
1 parent 0fed404 commit 8842267
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions S17-concurrency/winner.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@ use Test;

plan 4;

#?rakudo skip 'syntax not valid yet'
#?rakudo.parrot skip 'no implementation of promise/winner'
{
my $p1 = Promise.in(1);
my $p2 = Promise.in(2);
my @seen;
is( do winner * {
is( winner * {
done $p1 { @seen.push: 'a'; 'first' }
done $p2 { @seen.push: 'b'; 'second' }
}, 'first', 'did we get the first promise' );
is( do winner * {
is(winner * {
done $p2 { @seen.push: 'b'; 'second' }
}, 'second', 'did we get the second promise' );
is ~@seen, 'a b', 'did promises fire in right order';
}

#?rakudo skip 'syntax not valid yet'
#?rakudo.parrot skip 'no implementation of supply/winner'
{
my $p = Publish.for(1..5);
my $p = Supply.for(1..5);
my $c = $p.Channel;
my @a;
loop {
winner $c {
more * => { say "pushing"; @a.push($^val) },
done * => { say "done"; @a.push("done"); last }
);
more * -> $val { @a.push($val) }
done * -> { @a.push("done"); last }
}
}
is ~@a, "1 2 3 4 5 done", "Publish.for and .Channel work";
}

0 comments on commit 8842267

Please sign in to comment.