Skip to content

Commit 6008277

Browse files
committed
Add tests for dynamic-scope pragma
1 parent ae6ebad commit 6008277

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

S02-names/dynamic-scope.t

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use v6;
2+
use Test;
3+
plan 4;
4+
5+
my $a;
6+
nok $a.VAR.dynamic, 'Variables default to not being dynamically scoped';
7+
8+
subtest 'Pragma dynamic-scope without args' => {
9+
use dynamic-scope;
10+
my $b;
11+
ok $b.VAR.dynamic, 'Works on normal variable declarations';
12+
my ($c, $d);
13+
ok $c.VAR.dynamic, 'Works on variables declared in list form (1)';
14+
ok $d.VAR.dynamic, 'Works on variables declared in list form (2)';
15+
}
16+
17+
my $x;
18+
nok $x.VAR.dynamic, 'The dynamic-scope pragma works lexically';
19+
20+
subtest 'Pragma dynamic-scope with args' => {
21+
use dynamic-scope <$e $g>;
22+
my $e;
23+
ok $e.VAR.dynamic, 'Works on normal variable declarations with matching name';
24+
my $f;
25+
nok $f.VAR.dynamic, 'Does not make variables without matching name dynamic';
26+
my ($g, $h);
27+
ok $g.VAR.dynamic, 'Works on variables declared in list form (1)';
28+
nok $h.VAR.dynamic, 'Works on variables declared in list form (2)';
29+
}
30+
31+
# vim: ft=perl6

0 commit comments

Comments
 (0)