diff --git a/S17-promise/then.t b/S17-promise/then.t index 2e24427ccf..2036ea4712 100644 --- a/S17-promise/then.t +++ b/S17-promise/then.t @@ -1,7 +1,7 @@ use v6; use Test; -plan 14; +plan 15; { my $run_then = 0; @@ -15,7 +15,7 @@ plan 14; }); isa-ok $p2, Promise, "then returns a Promise"; is $run_then, 0, "Not run then yet"; - + $p1.keep(42); is $p2.result, 101, "Got correct result from then Promise"; ok $run_then, "Certainly ran the then"; @@ -29,7 +29,7 @@ plan 14; is $res.cause.message, "we fail it", "Got correct cause"; "oh noes" }); - + $p1.break("we fail it"); is $p2.result, "oh noes", "Got correct result from then Promise"; } @@ -46,3 +46,29 @@ plan 14; is $p2.status, Broken, "then Promise is broken"; is $p2.cause.message, "then died", "then Promise has correct cause"; } + +# RT #131509 +subtest 'dynamics accessible from .then' => { + plan 4; + + my @code; + my $*FOO; my @*FOO; my %*FOO; + my &*FOO = { @code.push: $_ }; + + await start { + $*FOO ~= 'prom'; + @*FOO.push: 'prom'; + %*FOO = 42; + &*FOO('prom'); + }.then: { + $*FOO ~= 'then'; + @*FOO.push: 'then'; + %*FOO = 72; + &*FOO('then'); + } + + is-deeply $*FOO, 'promthen', '$*FOO'; + is-deeply @*FOO, [], '@*FOO'; + is-deeply %*FOO, {:42prom, :72then}, '%*FOO'; + is-deeply @code, [], '&*FOO'; +}