line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mason::t::Autobase; |
2
|
|
|
|
|
|
|
$Mason::t::Autobase::VERSION = '2.23'; |
3
|
1
|
|
|
1
|
|
795
|
use Test::Class::Most parent => 'Mason::Test::Class'; |
|
1
|
|
|
|
|
29659
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub test_autobase : Tests { |
6
|
1
|
|
|
1
|
0
|
933
|
my $self = shift; |
7
|
1
|
|
|
|
|
9
|
my $interp = $self->interp; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $check_parent = sub { |
10
|
24
|
|
|
24
|
|
73
|
my ( $path, $parent ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
24
|
50
|
|
|
|
561
|
my $base_comp_class = $interp->load($path) |
13
|
|
|
|
|
|
|
or die "could not load '$path'"; |
14
|
24
|
100
|
|
|
|
610
|
my $parent_comp_class = ( $parent =~ /\// ) ? $interp->load($parent) : $parent; |
15
|
24
|
|
|
|
|
332
|
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
|
|
28
|
my ( $path, $extends ) = @_; |
21
|
|
|
|
|
|
|
|
22
|
12
|
100
|
|
|
|
70
|
$self->add_comp( |
23
|
|
|
|
|
|
|
path => $path, |
24
|
|
|
|
|
|
|
src => ( $extends ? "<%flags>\nextends => $extends\n</%flags>" : " " ) |
25
|
|
|
|
|
|
|
); |
26
|
1
|
|
|
|
|
4
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $remove = sub { |
29
|
4
|
|
|
4
|
|
7
|
my ($path) = @_; |
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
21
|
$self->remove_comp( path => $path, ); |
32
|
1
|
|
|
|
|
4
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Add components with no autobases, make sure they inherit from |
35
|
|
|
|
|
|
|
# Mason::Component |
36
|
|
|
|
|
|
|
# |
37
|
1
|
|
|
|
|
2
|
$add->('/comp.mc'); |
38
|
1
|
|
|
|
|
2
|
$add->('/foo/comp.mc'); |
39
|
1
|
|
|
|
|
3
|
$add->('/foo/bar/comp.mc'); |
40
|
1
|
|
|
|
|
3
|
$add->('/foo/bar/baz/comp.mc'); |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
4
|
my $base_class = $self->interp->component_class; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
4
|
$check_parent->( '/comp.mc', $base_class ); |
45
|
1
|
|
|
|
|
8735
|
$check_parent->( '/foo/comp.mc', $base_class ); |
46
|
1
|
|
|
|
|
1136
|
$check_parent->( '/foo/bar/comp.mc', $base_class ); |
47
|
1
|
|
|
|
|
1107
|
$check_parent->( '/foo/bar/baz/comp.mc', $base_class ); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Add autobases, test the parents of the components and autobases |
50
|
|
|
|
|
|
|
# |
51
|
1
|
|
|
|
|
1103
|
$add->('/Base.mc'); |
52
|
1
|
|
|
|
|
2
|
$add->('/foo/Base.mc'); |
53
|
1
|
|
|
|
|
3
|
$add->('/foo/bar/baz/Base.mc'); |
54
|
1
|
|
|
|
|
5
|
$self->interp->_flush_load_cache(); |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
32
|
$check_parent->( '/Base.mc', $base_class ); |
57
|
1
|
|
|
|
|
1152
|
$check_parent->( '/foo/Base.mc', '/Base.mc' ); |
58
|
1
|
|
|
|
|
1249
|
$check_parent->( '/foo/bar/baz/Base.mc', '/foo/Base.mc' ); |
59
|
1
|
|
|
|
|
1220
|
$check_parent->( '/comp.mc', '/Base.mc' ); |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
1282
|
$check_parent->( '/foo/comp.mc', '/foo/Base.mc' ); |
62
|
1
|
|
|
|
|
1214
|
$check_parent->( '/foo/bar/comp.mc', '/foo/Base.mc' ); |
63
|
1
|
|
|
|
|
1170
|
$check_parent->( '/foo/bar/baz/comp.mc', '/foo/bar/baz/Base.mc' ); |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
1174
|
$add->( '/foo/bar/baz/none.mc', "undef" ); |
66
|
1
|
|
|
|
|
3
|
$check_parent->( '/foo/bar/baz/none.mc', $base_class ); |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
1161
|
$add->( '/foo/bar/baz/top.mc', "'/Base.mc'" ); |
69
|
1
|
|
|
|
|
4
|
$check_parent->( '/foo/bar/baz/top.mc', '/Base.mc' ); |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
1249
|
$add->( '/foo/bar/baz/top2.mc', "'../../Base.mc'" ); |
72
|
1
|
|
|
|
|
3
|
$check_parent->( '/foo/bar/baz/top2.mc', '/foo/Base.mc' ); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Multiple autobases same directory |
75
|
1
|
|
|
|
|
1218
|
$add->('/Base.mp'); |
76
|
1
|
|
|
|
|
3
|
$add->('/foo/Base.mp'); |
77
|
1
|
|
|
|
|
5
|
$self->interp->_flush_load_cache(); |
78
|
1
|
|
|
|
|
36
|
$check_parent->( '/Base.mp', $base_class ); |
79
|
1
|
|
|
|
|
1116
|
$check_parent->( '/Base.mc', '/Base.mp' ); |
80
|
1
|
|
|
|
|
1132
|
$check_parent->( '/foo/Base.mp', '/Base.mc' ); |
81
|
1
|
|
|
|
|
1146
|
$check_parent->( '/foo/Base.mc', '/foo/Base.mp' ); |
82
|
1
|
|
|
|
|
1189
|
$check_parent->( '/foo/comp.mc', '/foo/Base.mc' ); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Remove most autobases, test parents again |
85
|
|
|
|
|
|
|
# |
86
|
1
|
|
|
|
|
1187
|
$remove->('/Base.mp'); |
87
|
1
|
|
|
|
|
4
|
$remove->('/Base.mc'); |
88
|
1
|
|
|
|
|
2
|
$remove->('/foo/Base.mp'); |
89
|
1
|
|
|
|
|
4
|
$remove->('/foo/Base.mc'); |
90
|
1
|
|
|
|
|
5
|
$self->interp->_flush_load_cache(); |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
32
|
$check_parent->( '/comp.mc', $base_class ); |
93
|
1
|
|
|
|
|
1115
|
$check_parent->( '/foo/comp.mc', $base_class ); |
94
|
1
|
|
|
|
|
1165
|
$check_parent->( '/foo/bar/comp.mc', $base_class ); |
95
|
1
|
|
|
|
|
1100
|
$check_parent->( '/foo/bar/baz/comp.mc', '/foo/bar/baz/Base.mc' ); |
96
|
1
|
|
|
|
|
1138
|
$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
|
1268
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# An inheritance cycle |
103
|
|
|
|
|
|
|
# |
104
|
1
|
|
|
|
|
10
|
$self->add_comp( |
105
|
|
|
|
|
|
|
path => '/cycle/Base.mc', |
106
|
|
|
|
|
|
|
src => "<%flags>\nextends => '/cycle/c/index.mc'\n</%flags>\n", |
107
|
|
|
|
|
|
|
); |
108
|
1
|
|
|
|
|
11
|
$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
|
|
|
|
|
11
|
$self->add_comp( |
118
|
|
|
|
|
|
|
path => '/pseudo/Base.mc', |
119
|
|
|
|
|
|
|
src => "<%flags>\nextends => '/pseudo/c/index.mc'\n</%flags>\n", |
120
|
|
|
|
|
|
|
); |
121
|
1
|
|
|
|
|
7
|
$self->test_comp( |
122
|
|
|
|
|
|
|
path => '/pseudo/c/index.mc', |
123
|
|
|
|
|
|
|
src => "<%flags>\nextends => undef\n</%flags>\nok", |
124
|
|
|
|
|
|
|
expect => 'ok', |
125
|
|
|
|
|
|
|
); |
126
|
1
|
|
|
1
|
|
307
|
} |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub test_wrapping : Tests { |
129
|
1
|
|
|
1
|
0
|
250
|
my $self = shift; |
130
|
|
|
|
|
|
|
|
131
|
1
|
|
|
|
|
9
|
$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
|
|
|
|
|
8
|
$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
|
|
|
|
|
6
|
$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
|
|
|
|
|
6
|
$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
|
|
254
|
} |
|
1
|
|
|
|
|
3
|
|
|
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
|
252
|
my $self = shift; |
209
|
1
|
|
|
|
|
7
|
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
|
|
|
|
|
7
|
$self->add_comp( path => '/comp.mc', src => ' ' ); |
220
|
1
|
|
|
|
|
4
|
$self->interp->load('/comp.mc'); |
221
|
1
|
|
|
|
|
16
|
$self->add_comp( path => '/Base.mc', src => ' ' ); |
222
|
1
|
|
|
|
|
6
|
$self->interp->_flush_load_cache(); |
223
|
1
|
|
|
|
|
32
|
$self->interp->load('/comp.mc'); |
224
|
1
|
|
|
|
|
15
|
ok(1); |
225
|
|
|
|
|
|
|
|
226
|
1
|
|
|
|
|
348
|
return; |
227
|
1
|
|
|
1
|
|
392
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
1; |