Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turns out we have enough in place to pass 21-contextual.t too. :-)
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#! 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'); | ||
} | ||
} | ||
|
||
|