Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Created September 3, 2021 13:58
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 dogbert17/77beccab7a3b31555a1381aca322e5fa to your computer and use it in GitHub Desktop.
Save dogbert17/77beccab7a3b31555a1381aca322e5fa to your computer and use it in GitHub Desktop.
Cut down version of t/spec/S17-promise/start.t
use Test;
# https://github.com/Raku/old-issue-tracker/issues/4237
{
my @p = map { start { my @a = [ rand xx 1_000 ]; @a } }, ^10;
for @p.kv -> $i, $_ {
ok .result, "Got result from Promise populating/returning an array ($i)";
is .result.elems, 1000, "Correct number of results in array ($i)";
}
}
# https://github.com/Raku/old-issue-tracker/issues/4246
{
sub foo() {
my $p = start { $*E + 1 }
return $p.result;
}
my $*E = 5;
is foo(), 6, 'Code running in start can see dynamic variables of the start point';
}
# https://github.com/Raku/old-issue-tracker/issues/5529
{
grammar G {
token TOP { .+ { make ~$/ } }
}
my $warned = False;
await do for ^300 {
start {
CONTROL {
when CX::Warn {
$warned = True;
}
}
G.parse("x" x 1000)
}
}
nok $warned, 'No spurious warnings when using closures in grammar rules';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment