Created
September 3, 2021 13:58
-
-
Save dogbert17/77beccab7a3b31555a1381aca322e5fa to your computer and use it in GitHub Desktop.
Cut down version of t/spec/S17-promise/start.t
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; | |
# 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