Skip to content

Commit

Permalink
Test iterating over lexpads
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Feb 14, 2018
1 parent ce918d5 commit 7ba7de1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion t/nqp/101-lexpad-stuff.t
@@ -1,4 +1,4 @@
plan(16);
plan(18);
sub more-inner() {
my $outer := nqp::ctxcaller(nqp::ctx());
my $outermost := nqp::ctxcaller(nqp::ctxcaller(nqp::ctx()));
Expand Down Expand Up @@ -103,3 +103,23 @@ my sub elems_on_caller() {
my $*c := 300;
elems_on_caller();
}

my sub iterate_over_ctx() {
my $*FOO := 123;
my $found_foo;
my $found_foo_key;
for nqp::ctxlexpad(nqp::ctx) {
if ~$_ eq '$*FOO' {
$found_foo := nqp::iterval($_);
}

if $_.key eq '$*FOO' {
$found_foo_key := $_.value;
}
}

is($found_foo, 123, 'iterating over ctx works');
is($found_foo_key, 123, 'iterating over ctx works .key/.value');
}

iterate_over_ctx();

0 comments on commit 7ba7de1

Please sign in to comment.