Skip to content

Commit

Permalink
Test issues with &await
Browse files Browse the repository at this point in the history
Closes rakudo/rakudo#1323
Rakudo fix: rakudo/rakudo@c51f1796e6

Include test for both 6.c and 6.d languages, since we use two
separate sets of &awaits for them and each has different failure modes
in the bug.
  • Loading branch information
zoffixznet committed Dec 20, 2017
1 parent 6a027d3 commit 9a9ec49
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
14 changes: 13 additions & 1 deletion S17-promise/nonblocking-await.t
@@ -1,7 +1,7 @@
use v6.d.PREVIEW;
use Test;

plan 27;
plan 28;

# Limit scheduler to just 4 real threads, so we'll clearly be needing the
# non-blocking await support for these to pass.
Expand Down Expand Up @@ -271,3 +271,15 @@ PROCESS::<$SCHEDULER> := ThreadPoolScheduler.new(max_threads => 4);
is @foo.elems, 4, "slips awaited over get flattened out";
}
}

{ # https://github.com/rakudo/rakudo/issues/1323
# Await must be called in sink context here to trigger the covered bug.
# Gymnastics with atomic ints are just to reduce test runtime; the point
# of the test is that await awaits in this case for all Promises to
# complete instead of just returning immediately.
# (same test exists in 6.c tests on purpose; to cover Rakudo impl)
my atomicint $x;
sub p { start { sleep .3; $x++ } }
await [[[p(), [p(), [p(),]]], [p(), p(), p()]], [p(), p(), p()]];
is-deeply $x, 9, '&await awaits when given nested containerized iterables';
}
14 changes: 13 additions & 1 deletion S17-promise/start.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 59;
plan 60;

throws-like { await }, Exception, "a bare await should not work";

Expand Down Expand Up @@ -248,3 +248,15 @@ lives-ok {
});
nok $wrong, 'No data races on closure interpolation in strings';
}

{ # https://github.com/rakudo/rakudo/issues/1323
# Await must be called in sink context here to trigger the covered bug.
# Gymnastics with atomic ints are just to reduce test runtime; the point
# of the test is that await awaits in this case for all Promises to
# complete instead of just returning immediately.
# (same test exists in 6.d tests on purpose; to cover Rakudo impl)
my atomicint $x;
sub p { start { sleep .3; $x++ } }
await [[[p(), [p(), [p(),]]], [p(), p(), p()]], [p(), p(), p()]];
is-deeply $x, 9, '&await awaits when given nested containerized iterables';
}

0 comments on commit 9a9ec49

Please sign in to comment.