line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mason::t::Autobase; |
2
|
|
|
|
|
|
|
$Mason::t::Autobase::VERSION = '2.24'; |
3
|
1
|
|
|
1
|
|
850
|
use Test::Class::Most parent => 'Mason::Test::Class'; |
|
1
|
|
|
|
|
30010
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub test_autobase : Tests { |
6
|
1
|
|
|
1
|
0
|
839
|
my $self = shift; |
7
|
1
|
|
|
|
|
10
|
my $interp = $self->interp; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $check_parent = sub { |
10
|
24
|
|
|
24
|
|
110
|
my ( $path, $parent ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
24
|
50
|
|
|
|
713
|
my $base_comp_class = $interp->load($path) |
13
|
|
|
|
|
|
|
or die "could not load '$path'"; |
14
|
24
|
100
|
|
|
|
659
|
my $parent_comp_class = ( $parent =~ /\// ) ? $interp->load($parent) : $parent; |
15
|
24
|
|
|
|
|
350
|
cmp_deeply( [ $base_comp_class->meta->superclasses ], |
16
|
|
|
|
|
|
|
[$parent_comp_class], "parent of $path is $parent" ); |
17
|
1
|
|
|
|
|
6
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $add = sub { |
20
|
12
|
|
|
12
|
|
35
|
my ( $path, $extends ) = @_; |
21
|
|
|
|
|
|
|
|
22
|
12
|
100
|
|
|
|
81
|
$self->add_comp( |
23
|
|
|
|
|
|
|
path => $path, |
24
|
|
|
|
|
|
|
src => ( $extends ? "<%flags>\nextends => $extends\n</%flags>" : " " ) |
25
|
|
|
|
|
|
|
); |
26
|
1
|
|
|
|
|
5
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $remove = sub { |
29
|
4
|
|
|
4
|
|
6
|
my ($path) = @_; |
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
21
|
$self->remove_comp( path => $path, ); |
32
|
1
|
|
|
|
|
5
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Add components with no autobases, make sure they inherit from |
35
|
|
|
|
|
|
|
# Mason::Component |
36
|
|
|
|
|
|
|
# |
37
|
1
|
|
|
|
|
3
|
$add->('/comp.mc'); |
38
|
1
|
|
|
|
|
3
|
$add->('/foo/comp.mc'); |
39
|
1
|
|
|
|
|
4
|
$add->('/foo/bar/comp.mc'); |
40
|
1
|
|
|
|
|
4
|
$add->('/foo/bar/baz/comp.mc'); |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
6
|
my $base_class = $self->interp->component_class; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
5
|
$check_parent->( '/comp.mc', $base_class ); |
45
|
1
|
|
|
|
|
9174
|
$check_parent->( '/foo/comp.mc', $base_class ); |
46
|
1
|
|
|
|
|
1651
|
$check_parent->( '/foo/bar/comp.mc', $base_class ); |
47
|
1
|
|
|
|
|
1424
|
$check_parent->( '/foo/bar/baz/comp.mc', $base_class ); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Add autobases, test the parents of the components and autobases |
50
|
|
|
|
|
|
|
# |
51
|
1
|
|
|
|
|
1426
|
$add->('/Base.mc'); |
52
|
1
|
|
|
|
|
4
|
$add->('/foo/Base.mc'); |
53
|
1
|
|
|
|
|
3
|
$add->('/foo/bar/baz/Base.mc'); |
54
|
1
|
|
|
|
|
8
|
$self->interp->_flush_load_cache(); |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
33
|
$check_parent->( '/Base.mc', $base_class ); |
57
|
1
|
|
|
|
|
1525
|
$check_parent->( '/foo/Base.mc', '/Base.mc' ); |
58
|
1
|
|
|
|
|
1371
|
$check_parent->( '/foo/bar/baz/Base.mc', '/foo/Base.mc' ); |
59
|
1
|
|
|
|
|
1625
|
$check_parent->( '/comp.mc', '/Base.mc' ); |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
1607
|
$check_parent->( '/foo/comp.mc', '/foo/Base.mc' ); |
62
|
1
|
|
|
|
|
1568
|
$check_parent->( '/foo/bar/comp.mc', '/foo/Base.mc' ); |
63
|
1
|
|
|
|
|
1916
|
$check_parent->( '/foo/bar/baz/comp.mc', '/foo/bar/baz/Base.mc' ); |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
1238
|
$add->( '/foo/bar/baz/none.mc', "undef" ); |
66
|
1
|
|
|
|
|
5
|
$check_parent->( '/foo/bar/baz/none.mc', $base_class ); |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
1622
|
$add->( '/foo/bar/baz/top.mc', "'/Base.mc'" ); |
69
|
1
|
|
|
|
|
4
|
$check_parent->( '/foo/bar/baz/top.mc', '/Base.mc' ); |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
1505
|
$add->( '/foo/bar/baz/top2.mc', "'../../Base.mc'" ); |
72
|
1
|
|
|
|
|
5
|
$check_parent->( '/foo/bar/baz/top2.mc', '/foo/Base.mc' ); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Multiple autobases same directory |
75
|
1
|
|
|
|
|
1536
|
$add->('/Base.mp'); |
76
|
1
|
|
|
|
|
4
|
$add->('/foo/Base.mp'); |
77
|
1
|
|
|
|
|
7
|
$self->interp->_flush_load_cache(); |
78
|
1
|
|
|
|
|
43
|
$check_parent->( '/Base.mp', $base_class ); |
79
|
1
|
|
|
|
|
1614
|
$check_parent->( '/Base.mc', '/Base.mp' ); |
80
|
1
|
|
|
|
|
1523
|
$check_parent->( '/foo/Base.mp', '/Base.mc' ); |
81
|
1
|
|
|
|
|
1547
|
$check_parent->( '/foo/Base.mc', '/foo/Base.mp' ); |
82
|
1
|
|
|
|
|
1593
|
$check_parent->( '/foo/comp.mc', '/foo/Base.mc' ); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Remove most autobases, test parents again |
85
|
|
|
|
|
|
|
# |
86
|
1
|
|
|
|
|
1582
|
$remove->('/Base.mp'); |
87
|
1
|
|
|
|
|
4
|
$remove->('/Base.mc'); |
88
|
1
|
|
|
|
|
4
|
$remove->('/foo/Base.mp'); |
89
|
1
|
|
|
|
|
4
|
$remove->('/foo/Base.mc'); |
90
|
1
|
|
|
|
|
6
|
$self->interp->_flush_load_cache(); |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
33
|
$check_parent->( '/comp.mc', $base_class ); |
93
|
1
|
|
|
|
|
1510
|
$check_parent->( '/foo/comp.mc', $base_class ); |
94
|
1
|
|
|
|
|
1549
|
$check_parent->( '/foo/bar/comp.mc', $base_class ); |
95
|
1
|
|
|
|
|
1536
|
$check_parent->( '/foo/bar/baz/comp.mc', '/foo/bar/baz/Base.mc' ); |
96
|
1
|
|
|
|
|
1600
|
$check_parent->( '/foo/bar/baz/Base.mc', $base_class ); |
97
|
1
|
|
|
1
|
|
426
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub test_cycles : Tests { |
100
|
1
|
|
|
1
|
0
|
1460
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# An inheritance cycle |
103
|
|
|
|
|
|
|
# |
104
|
1
|
|
|
|
|
12
|
$self->add_comp( |
105
|
|
|
|
|
|
|
path => '/cycle/Base.mc', |
106
|
|
|
|
|
|
|
src => "<%flags>\nextends => '/cycle/c/index.mc'\n</%flags>\n", |
107
|
|
|
|
|
|
|
); |
108
|
1
|
|
|
|
|
18
|
$self->test_comp( |
109
|
|
|
|
|
|
|
path => '/cycle/c/index.mc', |
110
|
|
|
|
|
|
|
src => "ok", |
111
|
|
|
|
|
|
|
expect_error => qr/inheritance cycle/, |
112
|
|
|
|
|
|
|
); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# This isn't a cycle but a bug that tried to preload default parent was causing |
115
|
|
|
|
|
|
|
# it to infinite loop |
116
|
|
|
|
|
|
|
# |
117
|
1
|
|
|
|
|
12
|
$self->add_comp( |
118
|
|
|
|
|
|
|
path => '/pseudo/Base.mc', |
119
|
|
|
|
|
|
|
src => "<%flags>\nextends => '/pseudo/c/index.mc'\n</%flags>\n", |
120
|
|
|
|
|
|
|
); |
121
|
1
|
|
|
|
|
8
|
$self->test_comp( |
122
|
|
|
|
|
|
|
path => '/pseudo/c/index.mc', |
123
|
|
|
|
|
|
|
src => "<%flags>\nextends => undef\n</%flags>\nok", |
124
|
|
|
|
|
|
|
expect => 'ok', |
125
|
|
|
|
|
|
|
); |
126
|
1
|
|
|
1
|
|
329
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub test_wrapping : Tests { |
129
|
1
|
|
|
1
|
0
|
265
|
my $self = shift; |
130
|
|
|
|
|
|
|
|
131
|
1
|
|
|
|
|
10
|
$self->add_comp( |
132
|
|
|
|
|
|
|
path => '/wrap/Base.mc', |
133
|
|
|
|
|
|
|
src => ' |
134
|
|
|
|
|
|
|
<%augment wrap> |
135
|
|
|
|
|
|
|
<html> |
136
|
|
|
|
|
|
|
% inner(); |
137
|
|
|
|
|
|
|
</html> |
138
|
|
|
|
|
|
|
</%augment> |
139
|
|
|
|
|
|
|
' |
140
|
|
|
|
|
|
|
); |
141
|
1
|
|
|
|
|
5
|
$self->add_comp( |
142
|
|
|
|
|
|
|
path => '/wrap/subdir/Base.mc', |
143
|
|
|
|
|
|
|
src => ' |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
<%method hello> |
146
|
|
|
|
|
|
|
Hello world |
147
|
|
|
|
|
|
|
</%method> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
' |
150
|
|
|
|
|
|
|
); |
151
|
1
|
|
|
|
|
5
|
$self->add_comp( |
152
|
|
|
|
|
|
|
path => '/wrap/subdir/subdir2/Base.mc', |
153
|
|
|
|
|
|
|
src => ' |
154
|
|
|
|
|
|
|
<%augment wrap> |
155
|
|
|
|
|
|
|
<body> |
156
|
|
|
|
|
|
|
% inner(); |
157
|
|
|
|
|
|
|
</body> |
158
|
|
|
|
|
|
|
</%augment> |
159
|
|
|
|
|
|
|
' |
160
|
|
|
|
|
|
|
); |
161
|
1
|
|
|
|
|
9
|
$self->test_comp( |
162
|
|
|
|
|
|
|
path => '/wrap/subdir/subdir2/wrap_me.mc', |
163
|
|
|
|
|
|
|
src => '<% $self->hello %>', |
164
|
|
|
|
|
|
|
expect => ' |
165
|
|
|
|
|
|
|
<html> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
<body> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Hello world |
170
|
|
|
|
|
|
|
</body> |
171
|
|
|
|
|
|
|
</html> |
172
|
|
|
|
|
|
|
' |
173
|
|
|
|
|
|
|
); |
174
|
1
|
|
|
|
|
8
|
$self->test_comp( |
175
|
|
|
|
|
|
|
path => '/wrap/subdir/subdir2/dont_wrap_me.mc', |
176
|
|
|
|
|
|
|
src => ' |
177
|
|
|
|
|
|
|
<%class>method wrap { $.main() }</%class> |
178
|
|
|
|
|
|
|
<% $self->hello() %> |
179
|
|
|
|
|
|
|
', |
180
|
|
|
|
|
|
|
expect => 'Hello world' |
181
|
|
|
|
|
|
|
); |
182
|
1
|
|
|
|
|
9
|
$self->test_comp( |
183
|
|
|
|
|
|
|
path => '/wrap/subdir/subdir2/dont_wrap_me_either.mc', |
184
|
|
|
|
|
|
|
src => ' |
185
|
|
|
|
|
|
|
<%class>CLASS->no_wrap;</%class> |
186
|
|
|
|
|
|
|
<% $self->hello() %> |
187
|
|
|
|
|
|
|
', |
188
|
|
|
|
|
|
|
expect => 'Hello world' |
189
|
|
|
|
|
|
|
); |
190
|
1
|
|
|
1
|
|
253
|
} |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# not yet implemented |
193
|
|
|
|
|
|
|
sub _test_no_main_in_autobase { |
194
|
0
|
|
|
0
|
|
|
my $self = shift; |
195
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
$self->test_comp( |
197
|
|
|
|
|
|
|
path => '/wrap/Base.mc', |
198
|
|
|
|
|
|
|
src => ' |
199
|
|
|
|
|
|
|
<body> |
200
|
|
|
|
|
|
|
% inner(); |
201
|
|
|
|
|
|
|
</body> |
202
|
|
|
|
|
|
|
', |
203
|
|
|
|
|
|
|
expect_error => qr/content found in main body of autobase/, |
204
|
|
|
|
|
|
|
); |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub test_recompute_inherit : Tests { |
208
|
1
|
|
|
1
|
0
|
282
|
my $self = shift; |
209
|
1
|
|
|
|
|
17
|
my $interp = $self->interp; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
# Test that /comp.mc class can be recomputed without garbage collection issues. |
212
|
|
|
|
|
|
|
# |
213
|
|
|
|
|
|
|
my $remove = sub { |
214
|
0
|
|
|
0
|
|
0
|
my ($path) = @_; |
215
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
0
|
$self->remove_comp( path => $path, ); |
217
|
1
|
|
|
|
|
5
|
}; |
218
|
|
|
|
|
|
|
|
219
|
1
|
|
|
|
|
8
|
$self->add_comp( path => '/comp.mc', src => ' ' ); |
220
|
1
|
|
|
|
|
6
|
$self->interp->load('/comp.mc'); |
221
|
1
|
|
|
|
|
17
|
$self->add_comp( path => '/Base.mc', src => ' ' ); |
222
|
1
|
|
|
|
|
6
|
$self->interp->_flush_load_cache(); |
223
|
1
|
|
|
|
|
31
|
$self->interp->load('/comp.mc'); |
224
|
1
|
|
|
|
|
16
|
ok(1); |
225
|
|
|
|
|
|
|
|
226
|
1
|
|
|
|
|
701
|
return; |
227
|
1
|
|
|
1
|
|
288
|
} |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
3
|
|
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
1; |