line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mason::t::Syntax; |
2
|
|
|
|
|
|
|
$Mason::t::Syntax::VERSION = '2.22'; |
3
|
1
|
|
|
1
|
|
1246
|
use Test::Class::Most parent => 'Mason::Test::Class'; |
|
1
|
|
|
|
|
55035
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub test_replace : Tests { |
6
|
|
|
|
|
|
|
shift->test_comp( |
7
|
|
|
|
|
|
|
src => <<'EOF', |
8
|
|
|
|
|
|
|
<BODY> |
9
|
|
|
|
|
|
|
<% "Hello World!" %> |
10
|
|
|
|
|
|
|
</BODY> |
11
|
|
|
|
|
|
|
EOF |
12
|
|
|
|
|
|
|
expect => <<'EOF', |
13
|
|
|
|
|
|
|
<BODY> |
14
|
|
|
|
|
|
|
Hello World! |
15
|
|
|
|
|
|
|
</BODY> |
16
|
|
|
|
|
|
|
EOF |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub test_percent : Tests { |
21
|
|
|
|
|
|
|
shift->test_comp( |
22
|
|
|
|
|
|
|
src => <<'EOF', |
23
|
|
|
|
|
|
|
<BODY> |
24
|
|
|
|
|
|
|
% my $message = "Hello World!"; |
25
|
|
|
|
|
|
|
<% $message %> |
26
|
|
|
|
|
|
|
</BODY> |
27
|
|
|
|
|
|
|
EOF |
28
|
|
|
|
|
|
|
expect => <<'EOF', |
29
|
|
|
|
|
|
|
<BODY> |
30
|
|
|
|
|
|
|
Hello World! |
31
|
|
|
|
|
|
|
</BODY> |
32
|
|
|
|
|
|
|
EOF |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub test_fake_percent : Tests { |
37
|
|
|
|
|
|
|
shift->test_comp( |
38
|
|
|
|
|
|
|
src => <<'EOF', |
39
|
|
|
|
|
|
|
some text, a %, and some text |
40
|
|
|
|
|
|
|
EOF |
41
|
|
|
|
|
|
|
expect => <<'EOF', |
42
|
|
|
|
|
|
|
some text, a %, and some text |
43
|
|
|
|
|
|
|
EOF |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub test_empty_percents : Tests { |
48
|
|
|
|
|
|
|
shift->test_comp( |
49
|
|
|
|
|
|
|
src => <<'EOF', |
50
|
|
|
|
|
|
|
some text, |
51
|
|
|
|
|
|
|
% |
52
|
|
|
|
|
|
|
and some more |
53
|
|
|
|
|
|
|
EOF |
54
|
|
|
|
|
|
|
expect => <<'EOF', |
55
|
|
|
|
|
|
|
some text, |
56
|
|
|
|
|
|
|
and some more |
57
|
|
|
|
|
|
|
EOF |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub test_empty_percents2 : Tests { |
62
|
|
|
|
|
|
|
shift->test_comp( |
63
|
|
|
|
|
|
|
src => <<'EOF', |
64
|
|
|
|
|
|
|
some text, |
65
|
|
|
|
|
|
|
% |
66
|
|
|
|
|
|
|
% $m->print('foo, '); |
67
|
|
|
|
|
|
|
% $m->print(undef); |
68
|
|
|
|
|
|
|
and some more |
69
|
|
|
|
|
|
|
EOF |
70
|
|
|
|
|
|
|
expect => <<'EOF', |
71
|
|
|
|
|
|
|
some text, |
72
|
|
|
|
|
|
|
foo, and some more |
73
|
|
|
|
|
|
|
EOF |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Deprecated syntax |
78
|
|
|
|
|
|
|
# |
79
|
|
|
|
|
|
|
sub test_double_percent : Tests { |
80
|
|
|
|
|
|
|
shift->test_comp( |
81
|
|
|
|
|
|
|
src => <<'EOF', |
82
|
|
|
|
|
|
|
<%class> |
83
|
|
|
|
|
|
|
my $i = 5; |
84
|
|
|
|
|
|
|
</%class> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
%% my $j = 0; |
87
|
|
|
|
|
|
|
%% if ($i == 5) { |
88
|
|
|
|
|
|
|
%% $j = $i+1; |
89
|
|
|
|
|
|
|
%% } |
90
|
|
|
|
|
|
|
<% $.bar %> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
<%method bar> |
93
|
|
|
|
|
|
|
j = <% $j %> |
94
|
|
|
|
|
|
|
</%method> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
EOF |
97
|
|
|
|
|
|
|
expect => <<'EOF', |
98
|
|
|
|
|
|
|
j = 6 |
99
|
|
|
|
|
|
|
EOF |
100
|
|
|
|
|
|
|
); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub test_pure_perl : Tests { |
104
|
|
|
|
|
|
|
shift->test_comp( |
105
|
|
|
|
|
|
|
path => '/pureperl.mp', |
106
|
|
|
|
|
|
|
src => 'sub main { print "hello from main" }', |
107
|
|
|
|
|
|
|
expect => 'hello from main', |
108
|
|
|
|
|
|
|
); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# Deprecated syntax |
112
|
|
|
|
|
|
|
# |
113
|
|
|
|
|
|
|
sub test_args : Tests { |
114
|
|
|
|
|
|
|
my $self = shift; |
115
|
|
|
|
|
|
|
$self->add_comp( |
116
|
|
|
|
|
|
|
path => '/args.mc', |
117
|
|
|
|
|
|
|
src => ' |
118
|
|
|
|
|
|
|
<%args> |
119
|
|
|
|
|
|
|
a |
120
|
|
|
|
|
|
|
b # comment |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# comment |
123
|
|
|
|
|
|
|
c=>5 |
124
|
|
|
|
|
|
|
d => 6 |
125
|
|
|
|
|
|
|
e => "foo" # comment |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
f => (isa => "Num", default => 7) |
128
|
|
|
|
|
|
|
g => (isa => "Num", default => 8) # comment |
129
|
|
|
|
|
|
|
</%args> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
a = <% $.a %> |
132
|
|
|
|
|
|
|
b = <% $.b %> |
133
|
|
|
|
|
|
|
c = <% $.c %> |
134
|
|
|
|
|
|
|
d = <% $.d %> |
135
|
|
|
|
|
|
|
e = <% $.e %> |
136
|
|
|
|
|
|
|
f = <% $.f %> |
137
|
|
|
|
|
|
|
g = <% $.g %> |
138
|
|
|
|
|
|
|
', |
139
|
|
|
|
|
|
|
); |
140
|
|
|
|
|
|
|
$self->test_comp( |
141
|
|
|
|
|
|
|
src => '<& /args.mc, a => 3, b => 4 &>', |
142
|
|
|
|
|
|
|
expect => ' |
143
|
|
|
|
|
|
|
a = 3 |
144
|
|
|
|
|
|
|
b = 4 |
145
|
|
|
|
|
|
|
c = 5 |
146
|
|
|
|
|
|
|
d = 6 |
147
|
|
|
|
|
|
|
e = foo |
148
|
|
|
|
|
|
|
f = 7 |
149
|
|
|
|
|
|
|
g = 8 |
150
|
|
|
|
|
|
|
' |
151
|
|
|
|
|
|
|
); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub test_multiline_comment : Tests { |
155
|
|
|
|
|
|
|
my $self = shift; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
$self->test_comp( |
158
|
|
|
|
|
|
|
src => ' |
159
|
|
|
|
|
|
|
hi<% |
160
|
|
|
|
|
|
|
# comment |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# another comment |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
%>bye |
165
|
|
|
|
|
|
|
', |
166
|
|
|
|
|
|
|
expect => 'hibye', |
167
|
|
|
|
|
|
|
); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# Deprecated syntax |
171
|
|
|
|
|
|
|
# |
172
|
|
|
|
|
|
|
sub test_shared : Tests { |
173
|
|
|
|
|
|
|
shift->test_parse( |
174
|
|
|
|
|
|
|
src => ' |
175
|
|
|
|
|
|
|
<%shared> |
176
|
|
|
|
|
|
|
$.foo # a comment |
177
|
|
|
|
|
|
|
$.bar => "something" |
178
|
|
|
|
|
|
|
$.baz => ( isa => "Num", default => 5 ) |
179
|
|
|
|
|
|
|
# another comment |
180
|
|
|
|
|
|
|
</%shared> |
181
|
|
|
|
|
|
|
', |
182
|
|
|
|
|
|
|
expect => [ |
183
|
|
|
|
|
|
|
q/has 'foo' => (init_arg => undef/, |
184
|
|
|
|
|
|
|
q/has 'bar' => (init_arg => undef, default => "something"/, |
185
|
|
|
|
|
|
|
q/has 'baz' => (init_arg => undef, isa => "Num", default => 5/ |
186
|
|
|
|
|
|
|
], |
187
|
|
|
|
|
|
|
); |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub test_dollar_dot : Tests { |
191
|
|
|
|
|
|
|
shift->test_comp( |
192
|
|
|
|
|
|
|
src => ' |
193
|
|
|
|
|
|
|
<%class> |
194
|
|
|
|
|
|
|
has "bar" => (default => 4); |
195
|
|
|
|
|
|
|
has "foo" => (default => 3); |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
</%class> |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
<% $self->show %> |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
<%method show> |
202
|
|
|
|
|
|
|
foo = <% $.foo %> |
203
|
|
|
|
|
|
|
bar = <% $.bar %> |
204
|
|
|
|
|
|
|
</%method> |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
<%init> |
207
|
|
|
|
|
|
|
$self->foo(5); |
208
|
|
|
|
|
|
|
$self->bar(6); |
209
|
|
|
|
|
|
|
</%init> |
210
|
|
|
|
|
|
|
', |
211
|
|
|
|
|
|
|
expect => ' |
212
|
|
|
|
|
|
|
foo = 5 |
213
|
|
|
|
|
|
|
bar = 6 |
214
|
|
|
|
|
|
|
' |
215
|
|
|
|
|
|
|
); |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub test_dollar_m : Tests { |
219
|
|
|
|
|
|
|
my $self = shift; |
220
|
|
|
|
|
|
|
$self->test_comp( |
221
|
|
|
|
|
|
|
src => ' |
222
|
|
|
|
|
|
|
<%class> |
223
|
|
|
|
|
|
|
method foo () { $m->print("foo\n") } |
224
|
|
|
|
|
|
|
</%class> |
225
|
|
|
|
|
|
|
<%method bar><%perl>$m->print("bar\n");</%perl></%method> |
226
|
|
|
|
|
|
|
<% $.foo %> |
227
|
|
|
|
|
|
|
<% $.bar %> |
228
|
|
|
|
|
|
|
% $m->print("baz\n"); |
229
|
|
|
|
|
|
|
', |
230
|
|
|
|
|
|
|
expect => ' |
231
|
|
|
|
|
|
|
foo |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
bar |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
baz |
236
|
|
|
|
|
|
|
', |
237
|
|
|
|
|
|
|
); |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
sub test_class_global : Tests { |
241
|
|
|
|
|
|
|
my $self = shift; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
$self->test_comp( |
244
|
|
|
|
|
|
|
src => '<% ref($self) eq CLASS ? 1 : 0 %> <% ref($self) eq $CLASS ? 1 : 0 %>', |
245
|
|
|
|
|
|
|
expect => qr/1 1/, |
246
|
|
|
|
|
|
|
); |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
1; |