line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mason::t::Globals; |
2
|
|
|
|
|
|
|
$Mason::t::Globals::VERSION = '2.22'; |
3
|
1
|
|
|
1
|
|
1648
|
use Test::Class::Most parent => 'Mason::Test::Class'; |
|
1
|
|
|
|
|
53220
|
|
|
1
|
|
|
|
|
8
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub test_globals : Tests { |
6
|
|
|
|
|
|
|
my $self = shift; |
7
|
|
|
|
|
|
|
$self->setup_interp( allow_globals => [qw(scalar $scalar2)] ); |
8
|
|
|
|
|
|
|
my $interp = $self->interp; |
9
|
|
|
|
|
|
|
$interp->set_global( 'scalar', 5 ); |
10
|
|
|
|
|
|
|
$interp->set_global( '$scalar2', 'vanilla' ); |
11
|
|
|
|
|
|
|
throws_ok { $interp->set_global( '$bad', 8 ) } qr/\$bad is not in the allowed globals list/; |
12
|
|
|
|
|
|
|
$self->add_comp( |
13
|
|
|
|
|
|
|
path => '/values', |
14
|
|
|
|
|
|
|
src => ' |
15
|
|
|
|
|
|
|
scalar = <% $scalar %> |
16
|
|
|
|
|
|
|
$scalar2 = <% $scalar2 %> |
17
|
|
|
|
|
|
|
', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
$self->test_comp( |
20
|
|
|
|
|
|
|
src => ' |
21
|
|
|
|
|
|
|
<& /values &> |
22
|
|
|
|
|
|
|
% $scalar++; |
23
|
|
|
|
|
|
|
% $scalar2 .= "s"; |
24
|
|
|
|
|
|
|
<& /values &> |
25
|
|
|
|
|
|
|
', |
26
|
|
|
|
|
|
|
expect => ' |
27
|
|
|
|
|
|
|
scalar = 5 |
28
|
|
|
|
|
|
|
$scalar2 = vanilla |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
scalar = 6 |
32
|
|
|
|
|
|
|
$scalar2 = vanillas |
33
|
|
|
|
|
|
|
', |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |