Skip to content

Commit

Permalink
Turns out we have enough in place to pass 21-contextual.t too. :-)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Oct 19, 2010
1 parent e6de8a1 commit 4d3bf73
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions t/nqp/21-contextual.t
@@ -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');
}
}


0 comments on commit 4d3bf73

Please sign in to comment.