Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (17 sloc) 0.56 kB
#! nqp
# Tests for contextual variables
plan(6);
sub foo() { $*VAR }
{
my $*VAR := 'abc';
ok($*VAR eq 'abc', 'basic contextual declaration works');
ok(foo() eq 'abc', 'called subroutine sees caller $*VAR');
sub bar() { $*VAR }
ok(bar() eq 'abc', 'called subroutine sees caller $*VAR');
{
my $*VAR := 'def';
ok( $*VAR eq 'def', 'basic nested contextual works');
ok( foo() eq 'def', 'called subroutine sees caller $*VAR');
ok( bar() eq 'def', 'called subroutine sees caller not outer');
}
}
Jump to Line
Something went wrong with that request. Please try again.