| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mason::Tidy::t::Basic; |
|
2
|
|
|
|
|
|
|
BEGIN { |
|
3
|
1
|
|
|
1
|
|
846
|
$Mason::Tidy::t::Basic::VERSION = '2.57'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
1
|
|
|
1
|
|
497
|
use Mason::Tidy; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
57
|
|
|
6
|
1
|
|
|
1
|
|
1041
|
use Test::Class::Most parent => 'Test::Class'; |
|
|
1
|
|
|
|
|
42105
|
|
|
|
1
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub tidy { |
|
9
|
63
|
|
|
63
|
0
|
371
|
my %params = @_; |
|
10
|
63
|
50
|
|
|
|
285
|
my $source = $params{source} or die "source required"; |
|
11
|
63
|
|
66
|
|
|
321
|
my $expect = $params{expect} || $source; |
|
12
|
63
|
100
|
|
|
|
114
|
my $options = { mason_version => 2, %{ $params{options} || {} } }; |
|
|
63
|
|
|
|
|
606
|
|
|
13
|
63
|
|
|
|
|
197
|
my $desc = $params{desc}; |
|
14
|
63
|
100
|
|
|
|
203
|
if ( !defined($desc) ) { |
|
15
|
37
|
|
|
|
|
284
|
my ($caller) = ( ( caller(1) )[3] =~ /([^:]+$)/ ); |
|
16
|
37
|
|
|
|
|
1083
|
( my $source_flat = $source ) =~ s/\n/\\n/g; |
|
17
|
37
|
|
|
|
|
121
|
$desc = "$caller: $source_flat"; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
63
|
|
|
|
|
300
|
$source =~ s/\\n/\n/g; |
|
21
|
63
|
50
|
|
|
|
185
|
if ( defined($expect) ) { |
|
22
|
63
|
|
|
|
|
223
|
$expect =~ s/\\n/\n/g; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
63
|
|
|
|
|
2125
|
my $mt = Mason::Tidy->new( %$options, perltidy_argv => '--noprofile' ); |
|
26
|
63
|
|
|
|
|
328
|
my $dest = eval { $mt->tidy($source) }; |
|
|
63
|
|
|
|
|
239
|
|
|
27
|
63
|
|
|
|
|
179
|
my $err = $@; |
|
28
|
63
|
100
|
|
|
|
265
|
if ( my $expect_error = $params{expect_error} ) { |
|
29
|
2
|
|
|
|
|
21
|
like( $err, $expect_error, "got error - $desc" ); |
|
30
|
2
|
|
|
|
|
1509
|
is( $dest, undef, "no dest returned - $desc" ); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
else { |
|
33
|
61
|
|
|
|
|
585
|
is( $err, '', "no error - $desc" ); |
|
34
|
61
|
|
|
|
|
44109
|
is( $dest, $expect, "expected content - $desc" ); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub trim { |
|
39
|
0
|
|
|
0
|
0
|
|
my $str = $_[0]; |
|
40
|
0
|
0
|
|
|
|
|
return undef if !defined($str); |
|
41
|
0
|
|
|
|
|
|
for ($str) { s/^\s+//; s/\s+$// } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return $str; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub test_perl_sections : Tests { |
|
46
|
1
|
|
|
1
|
0
|
767
|
tidy( |
|
47
|
|
|
|
|
|
|
desc => 'init section', |
|
48
|
|
|
|
|
|
|
source => ' |
|
49
|
|
|
|
|
|
|
<%init> |
|
50
|
|
|
|
|
|
|
if($foo ) { |
|
51
|
|
|
|
|
|
|
my @ids = (1,2); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
</%init> |
|
54
|
|
|
|
|
|
|
', |
|
55
|
|
|
|
|
|
|
expect => ' |
|
56
|
|
|
|
|
|
|
<%init> |
|
57
|
|
|
|
|
|
|
if ($foo) { |
|
58
|
|
|
|
|
|
|
my @ids = ( 1, 2 ); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
</%init> |
|
61
|
|
|
|
|
|
|
' |
|
62
|
|
|
|
|
|
|
); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# This isn't ideal - would prefer it compressed to a single newline - but |
|
65
|
|
|
|
|
|
|
# both the <%init> and </%init> grab onto one of the newlines |
|
66
|
|
|
|
|
|
|
# |
|
67
|
1
|
|
|
|
|
598
|
tidy( |
|
68
|
|
|
|
|
|
|
desc => 'empty init section', |
|
69
|
|
|
|
|
|
|
source => "<%init>\n\n\n\n</%init>", |
|
70
|
|
|
|
|
|
|
expect => "<%init>\n\n</%init>", |
|
71
|
|
|
|
|
|
|
); |
|
72
|
1
|
|
|
1
|
|
77604
|
} |
|
|
1
|
|
|
|
|
30
|
|
|
|
1
|
|
|
|
|
11
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub test_mixed_sections : Tests { |
|
75
|
1
|
|
|
1
|
0
|
966
|
tidy( |
|
76
|
|
|
|
|
|
|
desc => 'method', |
|
77
|
|
|
|
|
|
|
source => '<%method foo>\n%if ( $foo) {\ncontent\n%}\n</%method>\n', |
|
78
|
|
|
|
|
|
|
expect => '<%method foo>\n% if ($foo) {\ncontent\n% }\n</%method>\n' |
|
79
|
|
|
|
|
|
|
); |
|
80
|
1
|
|
|
1
|
|
378
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub test_empty_method : Tests { |
|
83
|
1
|
|
|
1
|
0
|
714
|
tidy( source => 'foo\nbar\n' ); |
|
84
|
1
|
|
|
|
|
461
|
tidy( source => '<%method foo>\n</%method>\n' ); |
|
85
|
1
|
|
|
|
|
563
|
tidy( source => '<%method foo>\n%\n</%method>\n' ); |
|
86
|
1
|
|
|
|
|
414
|
tidy( source => '<%method foo>\n\n</%method>' ); |
|
87
|
1
|
|
|
|
|
387
|
tidy( source => '\n<%method foo>\n%\n%\n</%method>\n' ); |
|
88
|
1
|
|
|
1
|
|
287
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub test_text_section : Tests { |
|
91
|
1
|
|
|
1
|
0
|
1047
|
tidy( source => '<%text>\n% my $foo=5\n<%3+5%>\n</%text>\n' ); |
|
92
|
1
|
|
|
1
|
|
257
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub test_backslashes : Tests { |
|
95
|
1
|
|
|
1
|
0
|
600
|
tidy( source => 'Blah\\\n\n<%method foo>\\\nFoo\\\n% my $d = 5;\n</%method>\\\nBlurg\\\n' ); |
|
96
|
1
|
|
|
1
|
|
240
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub test_multiple_methods : Tests { |
|
99
|
1
|
|
|
1
|
0
|
908
|
tidy( |
|
100
|
|
|
|
|
|
|
desc => 'multiple method', |
|
101
|
|
|
|
|
|
|
source => ' |
|
102
|
|
|
|
|
|
|
<%method foo> |
|
103
|
|
|
|
|
|
|
%foo(); |
|
104
|
|
|
|
|
|
|
</%method> |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
<%method bar> |
|
107
|
|
|
|
|
|
|
<%perl> |
|
108
|
|
|
|
|
|
|
bar(); |
|
109
|
|
|
|
|
|
|
</%perl> |
|
110
|
|
|
|
|
|
|
</%method> |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
<%method .baz> |
|
113
|
|
|
|
|
|
|
%if (1) { |
|
114
|
|
|
|
|
|
|
<%blargh%> |
|
115
|
|
|
|
|
|
|
%} |
|
116
|
|
|
|
|
|
|
</%method> |
|
117
|
|
|
|
|
|
|
', |
|
118
|
|
|
|
|
|
|
expect => ' |
|
119
|
|
|
|
|
|
|
<%method foo> |
|
120
|
|
|
|
|
|
|
% foo(); |
|
121
|
|
|
|
|
|
|
</%method> |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
<%method bar> |
|
124
|
|
|
|
|
|
|
<%perl> |
|
125
|
|
|
|
|
|
|
bar(); |
|
126
|
|
|
|
|
|
|
</%perl> |
|
127
|
|
|
|
|
|
|
</%method> |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
<%method .baz> |
|
130
|
|
|
|
|
|
|
% if (1) { |
|
131
|
|
|
|
|
|
|
<% blargh %> |
|
132
|
|
|
|
|
|
|
% } |
|
133
|
|
|
|
|
|
|
</%method> |
|
134
|
|
|
|
|
|
|
' |
|
135
|
|
|
|
|
|
|
); |
|
136
|
1
|
|
|
1
|
|
279
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub test_args : Tests { |
|
139
|
1
|
|
|
1
|
0
|
3272
|
tidy( |
|
140
|
|
|
|
|
|
|
desc => 'perl lines', |
|
141
|
|
|
|
|
|
|
source => ' |
|
142
|
|
|
|
|
|
|
<%args> |
|
143
|
|
|
|
|
|
|
$a |
|
144
|
|
|
|
|
|
|
@b |
|
145
|
|
|
|
|
|
|
%c |
|
146
|
|
|
|
|
|
|
$d => "foo" |
|
147
|
|
|
|
|
|
|
@e => (1,2,3) |
|
148
|
|
|
|
|
|
|
%f => (a=>5, b=>6) |
|
149
|
|
|
|
|
|
|
</%args> |
|
150
|
|
|
|
|
|
|
', |
|
151
|
|
|
|
|
|
|
expect => ' |
|
152
|
|
|
|
|
|
|
<%args> |
|
153
|
|
|
|
|
|
|
$a |
|
154
|
|
|
|
|
|
|
@b |
|
155
|
|
|
|
|
|
|
%c |
|
156
|
|
|
|
|
|
|
$d => "foo" |
|
157
|
|
|
|
|
|
|
@e => (1,2,3) |
|
158
|
|
|
|
|
|
|
%f => (a=>5, b=>6) |
|
159
|
|
|
|
|
|
|
</%args> |
|
160
|
|
|
|
|
|
|
' |
|
161
|
|
|
|
|
|
|
); |
|
162
|
1
|
|
|
1
|
|
264
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub test_perl_lines_and_perl_blocks : Tests { |
|
165
|
1
|
|
|
1
|
0
|
1006
|
tidy( |
|
166
|
|
|
|
|
|
|
desc => 'perl lines with commented out tags', |
|
167
|
|
|
|
|
|
|
source => '% # <%init>\n% # <% $foo %>\n% # <& "foo" &>\n' |
|
168
|
|
|
|
|
|
|
); |
|
169
|
1
|
|
|
|
|
422
|
tidy( |
|
170
|
|
|
|
|
|
|
desc => 'perl lines', |
|
171
|
|
|
|
|
|
|
source => ' |
|
172
|
|
|
|
|
|
|
%my $d = 3; |
|
173
|
|
|
|
|
|
|
<%perl> |
|
174
|
|
|
|
|
|
|
if($foo ) { |
|
175
|
|
|
|
|
|
|
</%perl> |
|
176
|
|
|
|
|
|
|
<% blargh() %> |
|
177
|
|
|
|
|
|
|
%my @ids = (1,2); |
|
178
|
|
|
|
|
|
|
<%perl> |
|
179
|
|
|
|
|
|
|
my $foo = 3; |
|
180
|
|
|
|
|
|
|
if($bar) { |
|
181
|
|
|
|
|
|
|
my $s = 9; |
|
182
|
|
|
|
|
|
|
</%perl> |
|
183
|
|
|
|
|
|
|
% my $baz = 4; |
|
184
|
|
|
|
|
|
|
%} |
|
185
|
|
|
|
|
|
|
% } |
|
186
|
|
|
|
|
|
|
', |
|
187
|
|
|
|
|
|
|
expect => ' |
|
188
|
|
|
|
|
|
|
% my $d = 3; |
|
189
|
|
|
|
|
|
|
<%perl> |
|
190
|
|
|
|
|
|
|
if ($foo) { |
|
191
|
|
|
|
|
|
|
</%perl> |
|
192
|
|
|
|
|
|
|
<% blargh() %> |
|
193
|
|
|
|
|
|
|
% my @ids = ( 1, 2 ); |
|
194
|
|
|
|
|
|
|
<%perl> |
|
195
|
|
|
|
|
|
|
my $foo = 3; |
|
196
|
|
|
|
|
|
|
if ($bar) { |
|
197
|
|
|
|
|
|
|
my $s = 9; |
|
198
|
|
|
|
|
|
|
</%perl> |
|
199
|
|
|
|
|
|
|
% my $baz = 4; |
|
200
|
|
|
|
|
|
|
% } |
|
201
|
|
|
|
|
|
|
% } |
|
202
|
|
|
|
|
|
|
' |
|
203
|
|
|
|
|
|
|
); |
|
204
|
1
|
|
|
1
|
|
282
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub test_blocks_and_newlines : Tests { |
|
207
|
1
|
|
|
1
|
0
|
647
|
tidy( source => "<%perl>my \$foo=5;</%perl>" ); |
|
208
|
1
|
|
|
|
|
512
|
tidy( source => "<%perl>my \$foo=5;\n </%perl>" ); |
|
209
|
1
|
|
|
|
|
514
|
tidy( source => "<%perl>\nmy \$foo=5;</%perl>" ); |
|
210
|
1
|
|
|
|
|
472
|
tidy( |
|
211
|
|
|
|
|
|
|
source => "<%perl>\nmy \$foo=5;\n</%perl>", |
|
212
|
|
|
|
|
|
|
expect => "<%perl>\n my \$foo = 5;\n</%perl>" |
|
213
|
|
|
|
|
|
|
); |
|
214
|
1
|
|
|
|
|
554
|
tidy( |
|
215
|
|
|
|
|
|
|
source => '<%perl>\n\nmy $foo = 3;\n\nmy $bar = 4;\n\n</%perl>', |
|
216
|
|
|
|
|
|
|
expect => '<%perl>\n\n my $foo = 3;\n\n my $bar = 4;\n\n</%perl>', |
|
217
|
|
|
|
|
|
|
); |
|
218
|
1
|
|
|
|
|
539
|
tidy( |
|
219
|
|
|
|
|
|
|
source => '<%perl>\n\n\nmy $foo = 3;\n\n\nmy $bar = 4;\n\n\n</%perl>', |
|
220
|
|
|
|
|
|
|
expect => '<%perl>\n\n\n my $foo = 3;\n\n\n my $bar = 4;\n\n\n</%perl>', |
|
221
|
|
|
|
|
|
|
); |
|
222
|
1
|
|
|
|
|
490
|
tidy( |
|
223
|
|
|
|
|
|
|
source => "<%init>my \$foo=5;</%init>", |
|
224
|
|
|
|
|
|
|
expect => "<%init>my \$foo = 5;</%init>" |
|
225
|
|
|
|
|
|
|
); |
|
226
|
1
|
|
|
|
|
685
|
tidy( |
|
227
|
|
|
|
|
|
|
source => "<%init>my \$foo=5;\n </%init>", |
|
228
|
|
|
|
|
|
|
expect => "<%init>my \$foo = 5;\n </%init>" |
|
229
|
|
|
|
|
|
|
); |
|
230
|
1
|
|
|
|
|
595
|
tidy( |
|
231
|
|
|
|
|
|
|
source => "<%init>\nmy \$foo=5;</%init>", |
|
232
|
|
|
|
|
|
|
expect => "<%init>\nmy \$foo = 5;</%init>" |
|
233
|
|
|
|
|
|
|
); |
|
234
|
1
|
|
|
|
|
458
|
tidy( |
|
235
|
|
|
|
|
|
|
source => "<%init>\nmy \$foo=5;\n</%init>", |
|
236
|
|
|
|
|
|
|
expect => "<%init>\nmy \$foo = 5;\n</%init>" |
|
237
|
|
|
|
|
|
|
); |
|
238
|
1
|
|
|
|
|
533
|
tidy( |
|
239
|
|
|
|
|
|
|
source => '<%init>\n\nmy $foo = 3;\n\nmy $bar = 4;\n\n</%init>', |
|
240
|
|
|
|
|
|
|
expect => '<%init>\nmy $foo = 3;\nmy $bar = 4;\n</%init>', |
|
241
|
|
|
|
|
|
|
); |
|
242
|
1
|
|
|
1
|
|
428
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub test_tags : Tests { |
|
245
|
1
|
|
|
1
|
0
|
781
|
tidy( |
|
246
|
|
|
|
|
|
|
desc => 'subst tag', |
|
247
|
|
|
|
|
|
|
source => '<%$x%> text <%foo(5,6)%>', |
|
248
|
|
|
|
|
|
|
expect => '<% $x %> text <% foo( 5, 6 ) %>', |
|
249
|
|
|
|
|
|
|
); |
|
250
|
1
|
|
|
|
|
525
|
tidy( |
|
251
|
|
|
|
|
|
|
desc => 'comp call tag', |
|
252
|
|
|
|
|
|
|
source => '<&/foo/bar,a=>5,b=>6&> text <& $comp_path, str=>"foo"&>', |
|
253
|
|
|
|
|
|
|
expect => '<& /foo/bar, a => 5, b => 6 &> text <& $comp_path, str => "foo" &>', |
|
254
|
|
|
|
|
|
|
); |
|
255
|
1
|
|
|
|
|
522
|
tidy( |
|
256
|
|
|
|
|
|
|
desc => 'comp call w/content tag', |
|
257
|
|
|
|
|
|
|
source => '<&|/foo/bar,a=>5,b=>6&> text <& $comp_path, str=>"foo"&>', |
|
258
|
|
|
|
|
|
|
expect => '<&| /foo/bar, a => 5, b => 6 &> text <& $comp_path, str => "foo" &>', |
|
259
|
|
|
|
|
|
|
); |
|
260
|
1
|
|
|
1
|
|
323
|
} |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
4
|
|
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
sub test_filter_invoke : Tests { |
|
263
|
1
|
|
|
1
|
0
|
752
|
tidy( |
|
264
|
|
|
|
|
|
|
desc => 'filter invoke', |
|
265
|
|
|
|
|
|
|
source => ' |
|
266
|
|
|
|
|
|
|
%$.Trim(3,17) {{ |
|
267
|
|
|
|
|
|
|
%sub {uc($_[0] )} {{ |
|
268
|
|
|
|
|
|
|
%$.Fobernate() {{ |
|
269
|
|
|
|
|
|
|
This string will be trimmed, uppercased |
|
270
|
|
|
|
|
|
|
and fobernated |
|
271
|
|
|
|
|
|
|
% }} |
|
272
|
|
|
|
|
|
|
%}} |
|
273
|
|
|
|
|
|
|
% }} |
|
274
|
|
|
|
|
|
|
', |
|
275
|
|
|
|
|
|
|
expect => ' |
|
276
|
|
|
|
|
|
|
% $.Trim( 3, 17 ) {{ |
|
277
|
|
|
|
|
|
|
% sub { uc( $_[0] ) } {{ |
|
278
|
|
|
|
|
|
|
% $.Fobernate() {{ |
|
279
|
|
|
|
|
|
|
This string will be trimmed, uppercased |
|
280
|
|
|
|
|
|
|
and fobernated |
|
281
|
|
|
|
|
|
|
% }} |
|
282
|
|
|
|
|
|
|
% }} |
|
283
|
|
|
|
|
|
|
% }} |
|
284
|
|
|
|
|
|
|
' |
|
285
|
|
|
|
|
|
|
); |
|
286
|
1
|
|
|
1
|
|
304
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
sub test_filter_decl : Tests { |
|
289
|
1
|
|
|
1
|
0
|
789
|
tidy( |
|
290
|
|
|
|
|
|
|
desc => 'Mason 1 filter declaration (no arg)', |
|
291
|
|
|
|
|
|
|
source => ' |
|
292
|
|
|
|
|
|
|
Hi |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
<%filter> |
|
295
|
|
|
|
|
|
|
if (/abc/) { |
|
296
|
|
|
|
|
|
|
s/abc/def/; |
|
297
|
|
|
|
|
|
|
} |
|
298
|
|
|
|
|
|
|
</%filter> |
|
299
|
|
|
|
|
|
|
', |
|
300
|
|
|
|
|
|
|
expect => ' |
|
301
|
|
|
|
|
|
|
Hi |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
<%filter> |
|
304
|
|
|
|
|
|
|
if (/abc/) { |
|
305
|
|
|
|
|
|
|
s/abc/def/; |
|
306
|
|
|
|
|
|
|
} |
|
307
|
|
|
|
|
|
|
</%filter> |
|
308
|
|
|
|
|
|
|
' |
|
309
|
|
|
|
|
|
|
); |
|
310
|
|
|
|
|
|
|
|
|
311
|
1
|
|
|
|
|
528
|
tidy( |
|
312
|
|
|
|
|
|
|
desc => 'Mason 2 filter declaration (w/ arg)', |
|
313
|
|
|
|
|
|
|
source => ' |
|
314
|
|
|
|
|
|
|
<%filter Item ($class)> |
|
315
|
|
|
|
|
|
|
<li class="<%$class%>"> |
|
316
|
|
|
|
|
|
|
%if (my $x = $yield->()) { |
|
317
|
|
|
|
|
|
|
<% $x %> |
|
318
|
|
|
|
|
|
|
%} |
|
319
|
|
|
|
|
|
|
</li> |
|
320
|
|
|
|
|
|
|
</%filter> |
|
321
|
|
|
|
|
|
|
', |
|
322
|
|
|
|
|
|
|
expect => ' |
|
323
|
|
|
|
|
|
|
<%filter Item ($class)> |
|
324
|
|
|
|
|
|
|
<li class="<% $class %>"> |
|
325
|
|
|
|
|
|
|
% if ( my $x = $yield->() ) { |
|
326
|
|
|
|
|
|
|
<% $x %> |
|
327
|
|
|
|
|
|
|
% } |
|
328
|
|
|
|
|
|
|
</li> |
|
329
|
|
|
|
|
|
|
</%filter> |
|
330
|
|
|
|
|
|
|
' |
|
331
|
|
|
|
|
|
|
); |
|
332
|
1
|
|
|
1
|
|
322
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
13
|
|
|
333
|
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
sub test_perltidy_argv : Tests { |
|
335
|
1
|
|
|
1
|
0
|
769
|
tidy( |
|
336
|
|
|
|
|
|
|
desc => 'default indent 2', |
|
337
|
|
|
|
|
|
|
source => ' |
|
338
|
|
|
|
|
|
|
% if ($foo) { |
|
339
|
|
|
|
|
|
|
% if ($bar) { |
|
340
|
|
|
|
|
|
|
% baz(); |
|
341
|
|
|
|
|
|
|
% } |
|
342
|
|
|
|
|
|
|
% } |
|
343
|
|
|
|
|
|
|
', |
|
344
|
|
|
|
|
|
|
expect => ' |
|
345
|
|
|
|
|
|
|
% if ($foo) { |
|
346
|
|
|
|
|
|
|
% if ($bar) { |
|
347
|
|
|
|
|
|
|
% baz(); |
|
348
|
|
|
|
|
|
|
% } |
|
349
|
|
|
|
|
|
|
% } |
|
350
|
|
|
|
|
|
|
' |
|
351
|
|
|
|
|
|
|
); |
|
352
|
1
|
|
|
|
|
554
|
tidy( |
|
353
|
|
|
|
|
|
|
desc => 'perltidy_line_argv = -i=2', |
|
354
|
|
|
|
|
|
|
options => { perltidy_line_argv => '-i=2' }, |
|
355
|
|
|
|
|
|
|
source => ' |
|
356
|
|
|
|
|
|
|
% if ($foo) { |
|
357
|
|
|
|
|
|
|
% if ($bar) { |
|
358
|
|
|
|
|
|
|
% baz(); |
|
359
|
|
|
|
|
|
|
% } |
|
360
|
|
|
|
|
|
|
% } |
|
361
|
|
|
|
|
|
|
', |
|
362
|
|
|
|
|
|
|
expect => ' |
|
363
|
|
|
|
|
|
|
% if ($foo) { |
|
364
|
|
|
|
|
|
|
% if ($bar) { |
|
365
|
|
|
|
|
|
|
% baz(); |
|
366
|
|
|
|
|
|
|
% } |
|
367
|
|
|
|
|
|
|
% } |
|
368
|
|
|
|
|
|
|
' |
|
369
|
|
|
|
|
|
|
); |
|
370
|
1
|
|
|
1
|
|
376
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
371
|
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
sub test_blank_lines : Tests { |
|
373
|
1
|
|
|
1
|
0
|
703
|
tidy( source => '\n%\n' ); |
|
374
|
1
|
|
|
|
|
749
|
tidy( source => '%' ); |
|
375
|
1
|
|
|
|
|
412
|
tidy( source => '\n' ); |
|
376
|
1
|
|
|
|
|
410
|
tidy( source => '\n\n' ); |
|
377
|
1
|
|
|
|
|
379
|
tidy( source => '% foo();' ); |
|
378
|
1
|
|
|
|
|
447
|
tidy( source => '\n% foo();\n' ); |
|
379
|
1
|
|
|
|
|
443
|
tidy( source => '% foo()\n%' ); |
|
380
|
1
|
|
|
|
|
424
|
tidy( source => '\n% foo()\n%\n' ); |
|
381
|
1
|
|
|
|
|
452
|
tidy( source => ' Hello\n\n\n Goodbye\n' ); |
|
382
|
1
|
|
|
|
|
450
|
tidy( |
|
383
|
|
|
|
|
|
|
source => '<%perl>\nmy $foo = 5;\n\nmy $bar = 6;\n\n</%perl>', |
|
384
|
|
|
|
|
|
|
expect => '<%perl>\n my $foo = 5;\n\n my $bar = 6;\n\n</%perl>' |
|
385
|
|
|
|
|
|
|
); |
|
386
|
1
|
|
|
|
|
413
|
tidy( source => '\n%\n%\n% my $foo = 5;\n%\n% my $bar = 6;\n%\n%\n' ); |
|
387
|
1
|
|
|
|
|
438
|
tidy( source => '<%init>\nmy $foo = 5;\n</%init>\n\n' ); |
|
388
|
1
|
|
|
|
|
404
|
tidy( source => '% my $foo = 5;\n' ); |
|
389
|
1
|
|
|
|
|
396
|
tidy( source => '% my $foo = 5;' ); |
|
390
|
1
|
|
|
|
|
530
|
tidy( source => '% my $foo = 5;\n% my $bar = 6;\n' ); |
|
391
|
1
|
|
|
|
|
462
|
tidy( source => '% my $foo = 5;\n% my $bar = 6;' ); |
|
392
|
1
|
|
|
|
|
4654
|
tidy( source => '% my $foo = 5;\n% my $bar = 6;\n\n' ); |
|
393
|
1
|
|
|
1
|
|
544
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
12
|
|
|
394
|
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
sub test_single_line_block : Tests { |
|
396
|
1
|
|
|
1
|
0
|
793
|
tidy( |
|
397
|
|
|
|
|
|
|
source => '<%perl>my $foo = 5;</%perl>', |
|
398
|
|
|
|
|
|
|
expect => '<%perl>my $foo = 5;</%perl>' |
|
399
|
|
|
|
|
|
|
); |
|
400
|
1
|
|
|
1
|
|
295
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
401
|
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
sub test_indent_perl_block : Tests { |
|
403
|
1
|
|
|
1
|
0
|
811
|
my $source = ' |
|
404
|
|
|
|
|
|
|
<%perl> |
|
405
|
|
|
|
|
|
|
if ($foo) { |
|
406
|
|
|
|
|
|
|
$bar = 6; |
|
407
|
|
|
|
|
|
|
} |
|
408
|
|
|
|
|
|
|
</%perl> |
|
409
|
|
|
|
|
|
|
'; |
|
410
|
1
|
|
|
|
|
9
|
tidy( |
|
411
|
|
|
|
|
|
|
desc => 'indent_perl_block 0', |
|
412
|
|
|
|
|
|
|
options => { indent_perl_block => 0 }, |
|
413
|
|
|
|
|
|
|
source => $source, |
|
414
|
|
|
|
|
|
|
expect => ' |
|
415
|
|
|
|
|
|
|
<%perl> |
|
416
|
|
|
|
|
|
|
if ($foo) { |
|
417
|
|
|
|
|
|
|
$bar = 6; |
|
418
|
|
|
|
|
|
|
} |
|
419
|
|
|
|
|
|
|
</%perl> |
|
420
|
|
|
|
|
|
|
' |
|
421
|
|
|
|
|
|
|
); |
|
422
|
1
|
|
|
|
|
489
|
tidy( |
|
423
|
|
|
|
|
|
|
desc => 'indent_perl_block 2 (default)', |
|
424
|
|
|
|
|
|
|
source => $source, |
|
425
|
|
|
|
|
|
|
expect => ' |
|
426
|
|
|
|
|
|
|
<%perl> |
|
427
|
|
|
|
|
|
|
if ($foo) { |
|
428
|
|
|
|
|
|
|
$bar = 6; |
|
429
|
|
|
|
|
|
|
} |
|
430
|
|
|
|
|
|
|
</%perl> |
|
431
|
|
|
|
|
|
|
' |
|
432
|
|
|
|
|
|
|
); |
|
433
|
|
|
|
|
|
|
|
|
434
|
1
|
|
|
|
|
402
|
tidy( |
|
435
|
|
|
|
|
|
|
desc => 'indent_perl_block 4', |
|
436
|
|
|
|
|
|
|
options => { indent_perl_block => 4 }, |
|
437
|
|
|
|
|
|
|
source => $source, |
|
438
|
|
|
|
|
|
|
expect => ' |
|
439
|
|
|
|
|
|
|
<%perl> |
|
440
|
|
|
|
|
|
|
if ($foo) { |
|
441
|
|
|
|
|
|
|
$bar = 6; |
|
442
|
|
|
|
|
|
|
} |
|
443
|
|
|
|
|
|
|
</%perl> |
|
444
|
|
|
|
|
|
|
' |
|
445
|
|
|
|
|
|
|
); |
|
446
|
1
|
|
|
1
|
|
367
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
447
|
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
sub test_indent_block : Tests { |
|
449
|
1
|
|
|
1
|
0
|
809
|
my $source = ' |
|
450
|
|
|
|
|
|
|
<%init> |
|
451
|
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
if ($foo) { |
|
453
|
|
|
|
|
|
|
$bar = 6; |
|
454
|
|
|
|
|
|
|
} |
|
455
|
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
</%init> |
|
457
|
|
|
|
|
|
|
'; |
|
458
|
1
|
|
|
|
|
5
|
tidy( |
|
459
|
|
|
|
|
|
|
desc => 'indent_block 0 (default)', |
|
460
|
|
|
|
|
|
|
source => $source, |
|
461
|
|
|
|
|
|
|
expect => ' |
|
462
|
|
|
|
|
|
|
<%init> |
|
463
|
|
|
|
|
|
|
if ($foo) { |
|
464
|
|
|
|
|
|
|
$bar = 6; |
|
465
|
|
|
|
|
|
|
} |
|
466
|
|
|
|
|
|
|
</%init> |
|
467
|
|
|
|
|
|
|
' |
|
468
|
|
|
|
|
|
|
); |
|
469
|
1
|
|
|
|
|
525
|
tidy( |
|
470
|
|
|
|
|
|
|
desc => 'indent_block 2', |
|
471
|
|
|
|
|
|
|
options => { indent_block => 2 }, |
|
472
|
|
|
|
|
|
|
source => $source, |
|
473
|
|
|
|
|
|
|
expect => ' |
|
474
|
|
|
|
|
|
|
<%init> |
|
475
|
|
|
|
|
|
|
if ($foo) { |
|
476
|
|
|
|
|
|
|
$bar = 6; |
|
477
|
|
|
|
|
|
|
} |
|
478
|
|
|
|
|
|
|
</%init> |
|
479
|
|
|
|
|
|
|
' |
|
480
|
|
|
|
|
|
|
); |
|
481
|
1
|
|
|
1
|
|
409
|
} |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
5
|
|
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
sub test_errors : Tests { |
|
484
|
1
|
|
|
1
|
0
|
855
|
tidy( |
|
485
|
|
|
|
|
|
|
desc => 'syntax error', |
|
486
|
|
|
|
|
|
|
source => '% if ($foo) {', |
|
487
|
|
|
|
|
|
|
expect_error => qr/final indentation level/, |
|
488
|
|
|
|
|
|
|
); |
|
489
|
1
|
|
|
|
|
484
|
tidy( |
|
490
|
|
|
|
|
|
|
desc => 'no matching close block', |
|
491
|
|
|
|
|
|
|
source => "<%init>\nmy \$foo = bar;</%ini>", |
|
492
|
|
|
|
|
|
|
expect_error => qr/no matching end tag/, |
|
493
|
|
|
|
|
|
|
); |
|
494
|
1
|
|
|
1
|
|
320
|
} |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
4
|
|
|
495
|
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
sub test_here_docs : Tests { |
|
497
|
1
|
|
|
1
|
0
|
803
|
tidy( |
|
498
|
|
|
|
|
|
|
source => '<%perl>\nmy $text = <<"END";\nblah\nblah2\nEND\nprint $text;\n</%perl>', |
|
499
|
|
|
|
|
|
|
expect => '<%perl>\n my $text = <<"END";\nblah\nblah2\nEND\n print $text;\n</%perl>' |
|
500
|
|
|
|
|
|
|
); |
|
501
|
1
|
|
|
1
|
|
250
|
} |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
3
|
|
|
502
|
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
sub test_random_bugs : Tests { |
|
504
|
1
|
|
|
1
|
0
|
743
|
tidy( |
|
505
|
|
|
|
|
|
|
desc => 'final double brace (mason 1)', |
|
506
|
|
|
|
|
|
|
options => { mason_version => 1 }, |
|
507
|
|
|
|
|
|
|
source => ' |
|
508
|
|
|
|
|
|
|
% if ($foo) { |
|
509
|
|
|
|
|
|
|
% if ($bar) { |
|
510
|
|
|
|
|
|
|
% }} |
|
511
|
|
|
|
|
|
|
', |
|
512
|
|
|
|
|
|
|
expect => ' |
|
513
|
|
|
|
|
|
|
% if ($foo) { |
|
514
|
|
|
|
|
|
|
% if ($bar) { |
|
515
|
|
|
|
|
|
|
% }} |
|
516
|
|
|
|
|
|
|
' |
|
517
|
|
|
|
|
|
|
); |
|
518
|
1
|
|
|
|
|
395
|
tidy( |
|
519
|
|
|
|
|
|
|
desc => 'long comp call tag', |
|
520
|
|
|
|
|
|
|
source => |
|
521
|
|
|
|
|
|
|
'% # <& searchFormShared, report_title => $report_title, ask_site => 1, ask_date => 1, ask_search_terms => 1, ask_result_limit => 1 &>' |
|
522
|
|
|
|
|
|
|
); |
|
523
|
1
|
|
|
|
|
410
|
tidy( |
|
524
|
|
|
|
|
|
|
desc => '% at beginning of line inside multi-line <% %> or <& &>', |
|
525
|
|
|
|
|
|
|
source => '<& /layouts/master.mc,\n%ARGS\n&>\n<%\n%ARGS\n%>' |
|
526
|
|
|
|
|
|
|
); |
|
527
|
|
|
|
|
|
|
|
|
528
|
1
|
|
|
1
|
|
300
|
} |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
5
|
|
|
529
|
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
sub test_comprehensive : Tests { |
|
531
|
1
|
|
|
1
|
0
|
662
|
tidy( |
|
532
|
|
|
|
|
|
|
desc => 'comprehensive', |
|
533
|
|
|
|
|
|
|
source => ' |
|
534
|
|
|
|
|
|
|
some text |
|
535
|
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
% if ( $contents || $allow_empty ) { |
|
537
|
|
|
|
|
|
|
<ul> |
|
538
|
|
|
|
|
|
|
% foreach my $line (@lines) { |
|
539
|
|
|
|
|
|
|
<%perl> |
|
540
|
|
|
|
|
|
|
dothis(); |
|
541
|
|
|
|
|
|
|
andthat(); |
|
542
|
|
|
|
|
|
|
</%perl> |
|
543
|
|
|
|
|
|
|
<li> |
|
544
|
|
|
|
|
|
|
<%2+(3-4)*6%> |
|
545
|
|
|
|
|
|
|
</li> |
|
546
|
|
|
|
|
|
|
<li><% foo($.bar,$.baz, $.bleah) %></li> |
|
547
|
|
|
|
|
|
|
% } |
|
548
|
|
|
|
|
|
|
</ul> |
|
549
|
|
|
|
|
|
|
% } |
|
550
|
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
% $.Filter(3,2) {{ |
|
552
|
|
|
|
|
|
|
some filtered text |
|
553
|
|
|
|
|
|
|
%}} |
|
554
|
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
<&footer,color=>"blue",height => 3&> |
|
556
|
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
<%method foo> |
|
558
|
|
|
|
|
|
|
%if(defined($bar)) { |
|
559
|
|
|
|
|
|
|
% if ( $write_list) { |
|
560
|
|
|
|
|
|
|
even more text |
|
561
|
|
|
|
|
|
|
%} |
|
562
|
|
|
|
|
|
|
% } |
|
563
|
|
|
|
|
|
|
</%method> |
|
564
|
|
|
|
|
|
|
', |
|
565
|
|
|
|
|
|
|
expect => ' |
|
566
|
|
|
|
|
|
|
some text |
|
567
|
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
% if ( $contents || $allow_empty ) { |
|
569
|
|
|
|
|
|
|
<ul> |
|
570
|
|
|
|
|
|
|
% foreach my $line (@lines) { |
|
571
|
|
|
|
|
|
|
<%perl> |
|
572
|
|
|
|
|
|
|
dothis(); |
|
573
|
|
|
|
|
|
|
andthat(); |
|
574
|
|
|
|
|
|
|
</%perl> |
|
575
|
|
|
|
|
|
|
<li> |
|
576
|
|
|
|
|
|
|
<% 2 + ( 3 - 4 ) * 6 %> |
|
577
|
|
|
|
|
|
|
</li> |
|
578
|
|
|
|
|
|
|
<li><% foo( $.bar, $.baz, $.bleah ) %></li> |
|
579
|
|
|
|
|
|
|
% } |
|
580
|
|
|
|
|
|
|
</ul> |
|
581
|
|
|
|
|
|
|
% } |
|
582
|
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
% $.Filter( 3, 2 ) {{ |
|
584
|
|
|
|
|
|
|
some filtered text |
|
585
|
|
|
|
|
|
|
% }} |
|
586
|
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
<& footer, color => "blue", height => 3 &> |
|
588
|
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
<%method foo> |
|
590
|
|
|
|
|
|
|
% if ( defined($bar) ) { |
|
591
|
|
|
|
|
|
|
% if ($write_list) { |
|
592
|
|
|
|
|
|
|
even more text |
|
593
|
|
|
|
|
|
|
% } |
|
594
|
|
|
|
|
|
|
% } |
|
595
|
|
|
|
|
|
|
</%method> |
|
596
|
|
|
|
|
|
|
' |
|
597
|
|
|
|
|
|
|
); |
|
598
|
1
|
|
|
1
|
|
282
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
599
|
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
1; |