line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
|
|
|
|
|
|
package Test::Base; |
3
|
|
|
|
|
|
|
our $VERSION = '0.89'; |
4
|
5
|
|
|
5
|
|
5111
|
|
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
68
|
|
5
|
5
|
|
|
5
|
|
35
|
use Spiffy -Base; |
|
5
|
|
|
5
|
|
7
|
|
|
5
|
|
|
5
|
|
96
|
|
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
121
|
|
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
17
|
|
6
|
|
|
|
|
|
|
use Spiffy ':XXX'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $HAS_PROVIDER; |
9
|
5
|
|
|
5
|
|
297
|
BEGIN { |
10
|
|
|
|
|
|
|
$HAS_PROVIDER = eval "require Test::Builder::Provider; 1"; |
11
|
5
|
50
|
|
|
|
30
|
|
12
|
0
|
|
|
|
|
0
|
if ($HAS_PROVIDER) { |
13
|
|
|
|
|
|
|
Test::Builder::Provider->import('provides'); |
14
|
|
|
|
|
|
|
} |
15
|
5
|
|
|
5
|
|
215
|
else { |
|
5
|
|
|
|
|
9
|
|
16
|
|
|
|
|
|
|
*provides = sub { 1 }; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my @test_more_exports; |
22
|
5
|
|
|
5
|
|
112
|
BEGIN { |
23
|
|
|
|
|
|
|
@test_more_exports = qw( |
24
|
|
|
|
|
|
|
ok isnt like unlike is_deeply cmp_ok |
25
|
|
|
|
|
|
|
skip todo_skip pass fail |
26
|
|
|
|
|
|
|
eq_array eq_hash eq_set |
27
|
|
|
|
|
|
|
plan can_ok isa_ok diag |
28
|
|
|
|
|
|
|
use_ok |
29
|
|
|
|
|
|
|
$TODO |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
} |
32
|
5
|
|
|
5
|
|
2507
|
|
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
83
|
|
33
|
5
|
|
|
5
|
|
58
|
use Test::More import => \@test_more_exports; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
2172
|
|
34
|
|
|
|
|
|
|
use Carp; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
our @EXPORT = (@test_more_exports, qw( |
37
|
|
|
|
|
|
|
is no_diff |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
blocks next_block first_block |
40
|
|
|
|
|
|
|
delimiters spec_file spec_string |
41
|
|
|
|
|
|
|
filters filters_delay filter_arguments |
42
|
|
|
|
|
|
|
run run_compare run_is run_is_deeply run_like run_unlike |
43
|
|
|
|
|
|
|
skip_all_unless_require is_deep run_is_deep |
44
|
|
|
|
|
|
|
WWW XXX YYY ZZZ |
45
|
|
|
|
|
|
|
tie_output no_diag_on_only |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
find_my_self default_object |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
croak carp cluck confess |
50
|
|
|
|
|
|
|
)); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
field '_spec_file'; |
53
|
|
|
|
|
|
|
field '_spec_string'; |
54
|
|
|
|
|
|
|
field _filters => [qw(norm trim)]; |
55
|
|
|
|
|
|
|
field _filters_map => {}; |
56
|
|
|
|
|
|
|
field spec => |
57
|
|
|
|
|
|
|
-init => '$self->_spec_init'; |
58
|
|
|
|
|
|
|
field block_list => |
59
|
|
|
|
|
|
|
-init => '$self->_block_list_init'; |
60
|
|
|
|
|
|
|
field _next_list => []; |
61
|
|
|
|
|
|
|
field block_delim => |
62
|
|
|
|
|
|
|
-init => '$self->block_delim_default'; |
63
|
|
|
|
|
|
|
field data_delim => |
64
|
|
|
|
|
|
|
-init => '$self->data_delim_default'; |
65
|
|
|
|
|
|
|
field _filters_delay => 0; |
66
|
|
|
|
|
|
|
field _no_diag_on_only => 0; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
field block_delim_default => '==='; |
69
|
|
|
|
|
|
|
field data_delim_default => '---'; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $default_class; |
72
|
|
|
|
|
|
|
my $default_object; |
73
|
|
|
|
|
|
|
my $reserved_section_names = {}; |
74
|
12
|
|
|
12
|
0
|
20
|
|
75
|
12
|
|
66
|
|
|
58
|
sub default_object { |
76
|
12
|
|
|
|
|
20
|
$default_object ||= $default_class->new; |
77
|
|
|
|
|
|
|
return $default_object; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $import_called = 0; |
81
|
5
|
|
|
5
|
|
43
|
sub import() { |
82
|
5
|
50
|
|
|
|
78
|
$import_called = 1; |
83
|
|
|
|
|
|
|
my $class = (grep /^-base$/i, @_) |
84
|
|
|
|
|
|
|
? scalar(caller) |
85
|
5
|
50
|
|
|
|
44
|
: $_[0]; |
86
|
5
|
|
|
|
|
11
|
if (not defined $default_class) { |
87
|
|
|
|
|
|
|
$default_class = $class; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
# else { |
90
|
|
|
|
|
|
|
# croak "Can't use $class after using $default_class" |
91
|
|
|
|
|
|
|
# unless $default_class->isa($class); |
92
|
|
|
|
|
|
|
# } |
93
|
5
|
50
|
|
|
|
24
|
|
94
|
5
|
|
|
|
|
9
|
unless (grep /^-base$/i, @_) { |
95
|
5
|
|
|
|
|
22
|
my @args; |
96
|
0
|
0
|
|
|
|
0
|
for (my $ii = 1; $ii <= $#_; ++$ii) { |
97
|
0
|
|
|
|
|
0
|
if ($_[$ii] eq '-package') { |
98
|
|
|
|
|
|
|
++$ii; |
99
|
0
|
|
|
|
|
0
|
} else { |
100
|
|
|
|
|
|
|
push @args, $_[$ii]; |
101
|
|
|
|
|
|
|
} |
102
|
5
|
50
|
|
|
|
16
|
} |
103
|
|
|
|
|
|
|
Test::More->import(import => \@test_more_exports, @args) |
104
|
|
|
|
|
|
|
if @args; |
105
|
|
|
|
|
|
|
} |
106
|
5
|
|
|
|
|
18
|
|
107
|
5
|
|
|
|
|
95
|
_strict_warnings(); |
108
|
|
|
|
|
|
|
goto &Spiffy::import; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# Wrap Test::Builder::plan |
112
|
|
|
|
|
|
|
my $plan_code = \&Test::Builder::plan; |
113
|
|
|
|
|
|
|
my $Have_Plan = 0; |
114
|
5
|
|
|
5
|
|
34
|
{ |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
18610
|
|
115
|
|
|
|
|
|
|
no warnings 'redefine'; |
116
|
5
|
|
|
5
|
|
12
|
*Test::Builder::plan = sub { |
117
|
5
|
|
|
|
|
29
|
$Have_Plan = 1; |
118
|
|
|
|
|
|
|
goto &$plan_code; |
119
|
|
|
|
|
|
|
}; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $DIED = 0; |
123
|
|
|
|
|
|
|
$SIG{__DIE__} = sub { $DIED = 1; die @_ }; |
124
|
3
|
|
|
3
|
0
|
5
|
|
|
3
|
|
|
|
|
10
|
|
125
|
28
|
|
|
28
|
0
|
42
|
sub block_class { $self->find_class('Block') } |
|
28
|
|
|
|
|
49
|
|
126
|
|
|
|
|
|
|
sub filter_class { $self->find_class('Filter') } |
127
|
31
|
|
|
31
|
0
|
39
|
|
128
|
31
|
|
|
|
|
49
|
sub find_class { |
129
|
31
|
|
|
|
|
72
|
my $suffix = shift; |
130
|
31
|
100
|
|
|
|
113
|
my $class = ref($self) . "::$suffix"; |
131
|
2
|
|
|
|
|
8
|
return $class if $class->can('new'); |
132
|
2
|
50
|
|
|
|
9
|
$class = __PACKAGE__ . "::$suffix"; |
133
|
2
|
|
|
|
|
171
|
return $class if $class->can('new'); |
134
|
2
|
50
|
|
|
|
23
|
eval "require $class"; |
135
|
0
|
|
|
|
|
0
|
return $class if $class->can('new'); |
136
|
|
|
|
|
|
|
die "Can't find a class for $suffix"; |
137
|
|
|
|
|
|
|
} |
138
|
0
|
|
|
0
|
0
|
0
|
|
139
|
0
|
0
|
|
|
|
0
|
sub check_late { |
140
|
0
|
|
|
|
|
0
|
if ($self->{block_list}) { |
141
|
0
|
|
|
|
|
0
|
my $caller = (caller(1))[3]; |
142
|
0
|
|
|
|
|
0
|
$caller =~ s/.*:://; |
143
|
|
|
|
|
|
|
croak "Too late to call $caller()" |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
12
|
50
|
|
12
|
0
|
47
|
sub find_my_self() { |
148
|
|
|
|
|
|
|
my $self = ref($_[0]) eq $default_class |
149
|
|
|
|
|
|
|
? splice(@_, 0, 1) |
150
|
12
|
|
|
|
|
32
|
: default_object(); |
151
|
|
|
|
|
|
|
return $self, @_; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
2
|
|
|
2
|
0
|
80
|
sub blocks() { |
155
|
|
|
|
|
|
|
(my ($self), @_) = find_my_self(@_); |
156
|
2
|
50
|
|
|
|
10
|
|
157
|
|
|
|
|
|
|
croak "Invalid arguments passed to 'blocks'" |
158
|
2
|
50
|
33
|
|
|
10
|
if @_ > 1; |
159
|
|
|
|
|
|
|
croak sprintf("'%s' is invalid argument to blocks()", shift(@_)) |
160
|
|
|
|
|
|
|
if @_ && $_[0] !~ /^[a-zA-Z]\w*$/; |
161
|
2
|
|
|
|
|
46
|
|
162
|
|
|
|
|
|
|
my $blocks = $self->block_list; |
163
|
2
|
|
50
|
|
|
24
|
|
164
|
|
|
|
|
|
|
my $section_name = shift || ''; |
165
|
2
|
50
|
|
|
|
11
|
my @blocks = $section_name |
|
0
|
|
|
|
|
0
|
|
166
|
|
|
|
|
|
|
? (grep { exists $_->{$section_name} } @$blocks) |
167
|
|
|
|
|
|
|
: (@$blocks); |
168
|
2
|
50
|
|
|
|
72
|
|
169
|
|
|
|
|
|
|
return scalar(@blocks) unless wantarray; |
170
|
0
|
0
|
|
|
|
0
|
|
171
|
|
|
|
|
|
|
return (@blocks) if $self->_filters_delay; |
172
|
0
|
|
|
|
|
0
|
|
173
|
0
|
0
|
|
|
|
0
|
for my $block (@blocks) { |
174
|
|
|
|
|
|
|
$block->run_filters |
175
|
|
|
|
|
|
|
unless $block->is_filtered; |
176
|
|
|
|
|
|
|
} |
177
|
0
|
|
|
|
|
0
|
|
178
|
|
|
|
|
|
|
return (@blocks); |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
0
|
0
|
0
|
sub next_block() { |
182
|
0
|
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
183
|
0
|
0
|
|
|
|
0
|
my $list = $self->_next_list; |
184
|
0
|
|
|
|
|
0
|
if (@$list == 0) { |
|
0
|
|
|
|
|
0
|
|
185
|
0
|
|
|
|
|
0
|
$list = [@{$self->block_list}, undef]; |
186
|
|
|
|
|
|
|
$self->_next_list($list); |
187
|
0
|
|
|
|
|
0
|
} |
188
|
0
|
0
|
0
|
|
|
0
|
my $block = shift @$list; |
189
|
0
|
|
|
|
|
0
|
if (defined $block and not $block->is_filtered) { |
190
|
|
|
|
|
|
|
$block->run_filters; |
191
|
0
|
|
|
|
|
0
|
} |
192
|
|
|
|
|
|
|
return $block; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
0
|
|
|
0
|
0
|
0
|
sub first_block() { |
196
|
0
|
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
197
|
0
|
|
|
|
|
0
|
$self->_next_list([]); |
198
|
|
|
|
|
|
|
$self->next_block; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
0
|
|
|
0
|
0
|
0
|
sub filters_delay() { |
202
|
0
|
0
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
203
|
|
|
|
|
|
|
$self->_filters_delay(defined $_[0] ? shift : 1); |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
0
|
|
|
0
|
0
|
0
|
sub no_diag_on_only() { |
207
|
0
|
0
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
208
|
|
|
|
|
|
|
$self->_no_diag_on_only(defined $_[0] ? shift : 1); |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
0
|
|
|
0
|
0
|
0
|
sub delimiters() { |
212
|
0
|
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
213
|
0
|
|
|
|
|
0
|
$self->check_late; |
214
|
0
|
|
0
|
|
|
0
|
my ($block_delimiter, $data_delimiter) = @_; |
215
|
0
|
|
0
|
|
|
0
|
$block_delimiter ||= $self->block_delim_default; |
216
|
0
|
|
|
|
|
0
|
$data_delimiter ||= $self->data_delim_default; |
217
|
0
|
|
|
|
|
0
|
$self->block_delim($block_delimiter); |
218
|
0
|
|
|
|
|
0
|
$self->data_delim($data_delimiter); |
219
|
|
|
|
|
|
|
return $self; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
0
|
|
|
0
|
0
|
0
|
sub spec_file() { |
223
|
0
|
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
224
|
0
|
|
|
|
|
0
|
$self->check_late; |
225
|
0
|
|
|
|
|
0
|
$self->_spec_file(shift); |
226
|
|
|
|
|
|
|
return $self; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
0
|
|
|
0
|
0
|
0
|
sub spec_string() { |
230
|
0
|
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
231
|
0
|
|
|
|
|
0
|
$self->check_late; |
232
|
0
|
|
|
|
|
0
|
$self->_spec_string(shift); |
233
|
|
|
|
|
|
|
return $self; |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
1
|
|
|
1
|
0
|
5
|
sub filters() { |
237
|
1
|
50
|
|
|
|
5
|
(my ($self), @_) = find_my_self(@_); |
238
|
1
|
|
|
|
|
31
|
if (ref($_[0]) eq 'HASH') { |
239
|
|
|
|
|
|
|
$self->_filters_map(shift); |
240
|
|
|
|
|
|
|
} |
241
|
0
|
|
|
|
|
0
|
else { |
242
|
0
|
|
|
|
|
0
|
my $filters = $self->_filters; |
243
|
|
|
|
|
|
|
push @$filters, @_; |
244
|
1
|
|
|
|
|
2
|
} |
245
|
|
|
|
|
|
|
return $self; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
0
|
|
|
0
|
0
|
0
|
sub filter_arguments() { |
249
|
|
|
|
|
|
|
$Test::Base::Filter::arguments; |
250
|
|
|
|
|
|
|
} |
251
|
0
|
|
|
0
|
0
|
0
|
|
252
|
0
|
0
|
0
|
|
|
0
|
sub have_text_diff { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
253
|
|
|
|
|
|
|
eval { require Text::Diff; 1 } && |
254
|
|
|
|
|
|
|
$Text::Diff::VERSION >= 0.35 && |
255
|
|
|
|
|
|
|
$Algorithm::Diff::VERSION >= 1.15; |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
provides 'is'; |
259
|
7
|
|
|
7
|
0
|
20
|
sub is($$;$) { |
260
|
7
|
|
|
|
|
17
|
(my ($self), @_) = find_my_self(@_); |
261
|
7
|
50
|
|
|
|
18
|
my ($actual, $expected, $name) = @_; |
262
|
7
|
50
|
66
|
|
|
64
|
local $Test::Builder::Level = $Test::Builder::Level + 1 unless $HAS_PROVIDER; |
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
263
|
|
|
|
|
|
|
if ($ENV{TEST_SHOW_NO_DIFFS} or |
264
|
|
|
|
|
|
|
not defined $actual or |
265
|
|
|
|
|
|
|
not defined $expected or |
266
|
|
|
|
|
|
|
$actual eq $expected or |
267
|
|
|
|
|
|
|
not($self->have_text_diff) or |
268
|
|
|
|
|
|
|
$expected !~ /\n./s |
269
|
7
|
|
|
|
|
21
|
) { |
270
|
|
|
|
|
|
|
Test::More::is($actual, $expected, $name); |
271
|
|
|
|
|
|
|
} |
272
|
0
|
0
|
|
|
|
0
|
else { |
273
|
0
|
|
|
|
|
0
|
$name = '' unless defined $name; |
274
|
0
|
|
|
|
|
0
|
ok $actual eq $expected, $name; |
275
|
|
|
|
|
|
|
diag Text::Diff::diff(\$expected, \$actual); |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
|
279
|
2
|
|
|
2
|
0
|
9
|
sub run(&;$) { |
280
|
2
|
|
|
|
|
5
|
(my ($self), @_) = find_my_self(@_); |
281
|
2
|
|
|
|
|
5
|
my $callback = shift; |
|
2
|
|
|
|
|
47
|
|
282
|
3
|
50
|
|
|
|
107
|
for my $block (@{$self->block_list}) { |
283
|
3
|
|
|
|
|
8
|
$block->run_filters unless $block->is_filtered; |
|
3
|
|
|
|
|
10
|
|
284
|
|
|
|
|
|
|
&{$callback}($block); |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
|
288
|
0
|
|
|
0
|
|
0
|
my $name_error = "Can't determine section names"; |
289
|
0
|
0
|
|
|
|
0
|
sub _section_names { |
290
|
0
|
0
|
|
|
|
0
|
return unless defined $self->spec; |
291
|
0
|
0
|
|
|
|
0
|
return @_ if @_ == 2; |
292
|
|
|
|
|
|
|
my $block = $self->first_block |
293
|
|
|
|
|
|
|
or croak $name_error; |
294
|
0
|
|
|
|
|
0
|
my @names = grep { |
295
|
0
|
0
|
|
|
|
0
|
$_ !~ /^(ONLY|LAST|SKIP)$/; |
|
0
|
|
|
|
|
0
|
|
296
|
0
|
0
|
|
|
|
0
|
} @{$block->{_section_order}[0] || []}; |
297
|
|
|
|
|
|
|
croak "$name_error. Need two sections in first block" |
298
|
0
|
|
|
|
|
0
|
unless @names == 2; |
299
|
|
|
|
|
|
|
return @names; |
300
|
|
|
|
|
|
|
} |
301
|
0
|
|
|
0
|
|
0
|
|
302
|
0
|
0
|
|
|
|
0
|
sub _assert_plan { |
303
|
|
|
|
|
|
|
plan('no_plan') unless $Have_Plan; |
304
|
|
|
|
|
|
|
} |
305
|
5
|
|
|
5
|
|
15148
|
|
306
|
5
|
0
|
33
|
|
|
137
|
sub END { |
|
|
|
33
|
|
|
|
|
307
|
|
|
|
|
|
|
run_compare() unless $Have_Plan or $DIED or not $import_called; |
308
|
|
|
|
|
|
|
} |
309
|
|
|
|
|
|
|
|
310
|
0
|
|
|
0
|
0
|
0
|
sub run_compare() { |
311
|
0
|
0
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
312
|
0
|
|
|
|
|
0
|
return unless defined $self->spec; |
313
|
0
|
|
|
|
|
0
|
$self->_assert_plan; |
314
|
0
|
|
|
|
|
0
|
my ($x, $y) = $self->_section_names(@_); |
315
|
0
|
|
|
|
|
0
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
|
0
|
|
|
|
|
0
|
|
316
|
0
|
0
|
0
|
|
|
0
|
for my $block (@{$self->block_list}) { |
317
|
0
|
0
|
|
|
|
0
|
next unless exists($block->{$x}) and exists($block->{$y}); |
318
|
0
|
0
|
|
|
|
0
|
$block->run_filters unless $block->is_filtered; |
|
|
0
|
|
|
|
|
|
319
|
0
|
0
|
|
|
|
0
|
if (ref $block->$x) { |
320
|
|
|
|
|
|
|
is_deeply($block->$x, $block->$y, |
321
|
|
|
|
|
|
|
$block->name ? $block->name : ()); |
322
|
|
|
|
|
|
|
} |
323
|
0
|
0
|
|
|
|
0
|
elsif (ref $block->$y eq 'Regexp') { |
324
|
0
|
0
|
|
|
|
0
|
my $regexp = ref $y ? $y : $block->$y; |
325
|
|
|
|
|
|
|
like($block->$x, $regexp, $block->name ? $block->name : ()); |
326
|
|
|
|
|
|
|
} |
327
|
0
|
0
|
|
|
|
0
|
else { |
328
|
|
|
|
|
|
|
is($block->$x, $block->$y, $block->name ? $block->name : ()); |
329
|
|
|
|
|
|
|
} |
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
|
333
|
0
|
|
|
0
|
0
|
0
|
sub run_is() { |
334
|
0
|
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
335
|
0
|
|
|
|
|
0
|
$self->_assert_plan; |
336
|
0
|
|
|
|
|
0
|
my ($x, $y) = $self->_section_names(@_); |
337
|
0
|
|
|
|
|
0
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
|
0
|
|
|
|
|
0
|
|
338
|
0
|
0
|
0
|
|
|
0
|
for my $block (@{$self->block_list}) { |
339
|
0
|
0
|
|
|
|
0
|
next unless exists($block->{$x}) and exists($block->{$y}); |
340
|
0
|
0
|
|
|
|
0
|
$block->run_filters unless $block->is_filtered; |
341
|
|
|
|
|
|
|
is($block->$x, $block->$y, |
342
|
|
|
|
|
|
|
$block->name ? $block->name : () |
343
|
|
|
|
|
|
|
); |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
} |
346
|
|
|
|
|
|
|
|
347
|
0
|
|
|
0
|
0
|
0
|
sub run_is_deeply() { |
348
|
0
|
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
349
|
0
|
|
|
|
|
0
|
$self->_assert_plan; |
350
|
0
|
|
|
|
|
0
|
my ($x, $y) = $self->_section_names(@_); |
|
0
|
|
|
|
|
0
|
|
351
|
0
|
0
|
0
|
|
|
0
|
for my $block (@{$self->block_list}) { |
352
|
0
|
0
|
|
|
|
0
|
next unless exists($block->{$x}) and exists($block->{$y}); |
353
|
0
|
0
|
|
|
|
0
|
$block->run_filters unless $block->is_filtered; |
354
|
|
|
|
|
|
|
is_deeply($block->$x, $block->$y, |
355
|
|
|
|
|
|
|
$block->name ? $block->name : () |
356
|
|
|
|
|
|
|
); |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
|
360
|
0
|
|
|
0
|
0
|
0
|
sub run_like() { |
361
|
0
|
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
362
|
0
|
|
|
|
|
0
|
$self->_assert_plan; |
363
|
0
|
|
|
|
|
0
|
my ($x, $y) = $self->_section_names(@_); |
|
0
|
|
|
|
|
0
|
|
364
|
0
|
0
|
0
|
|
|
0
|
for my $block (@{$self->block_list}) { |
365
|
0
|
0
|
|
|
|
0
|
next unless exists($block->{$x}) and defined($y); |
366
|
0
|
0
|
|
|
|
0
|
$block->run_filters unless $block->is_filtered; |
367
|
0
|
0
|
|
|
|
0
|
my $regexp = ref $y ? $y : $block->$y; |
368
|
|
|
|
|
|
|
like($block->$x, $regexp, |
369
|
|
|
|
|
|
|
$block->name ? $block->name : () |
370
|
|
|
|
|
|
|
); |
371
|
|
|
|
|
|
|
} |
372
|
|
|
|
|
|
|
} |
373
|
|
|
|
|
|
|
|
374
|
0
|
|
|
0
|
0
|
0
|
sub run_unlike() { |
375
|
0
|
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
376
|
0
|
|
|
|
|
0
|
$self->_assert_plan; |
377
|
0
|
|
|
|
|
0
|
my ($x, $y) = $self->_section_names(@_); |
|
0
|
|
|
|
|
0
|
|
378
|
0
|
0
|
0
|
|
|
0
|
for my $block (@{$self->block_list}) { |
379
|
0
|
0
|
|
|
|
0
|
next unless exists($block->{$x}) and defined($y); |
380
|
0
|
0
|
|
|
|
0
|
$block->run_filters unless $block->is_filtered; |
381
|
0
|
0
|
|
|
|
0
|
my $regexp = ref $y ? $y : $block->$y; |
382
|
|
|
|
|
|
|
unlike($block->$x, $regexp, |
383
|
|
|
|
|
|
|
$block->name ? $block->name : () |
384
|
|
|
|
|
|
|
); |
385
|
|
|
|
|
|
|
} |
386
|
|
|
|
|
|
|
} |
387
|
|
|
|
|
|
|
|
388
|
0
|
|
|
0
|
0
|
0
|
sub skip_all_unless_require() { |
389
|
0
|
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
390
|
0
|
0
|
|
|
|
0
|
my $module = shift; |
391
|
|
|
|
|
|
|
eval "require $module; 1" |
392
|
|
|
|
|
|
|
or Test::More::plan( |
393
|
|
|
|
|
|
|
skip_all => "$module failed to load" |
394
|
|
|
|
|
|
|
); |
395
|
|
|
|
|
|
|
} |
396
|
|
|
|
|
|
|
|
397
|
0
|
|
|
0
|
0
|
0
|
sub is_deep() { |
398
|
0
|
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
399
|
0
|
|
|
|
|
0
|
require Test::Deep; |
400
|
|
|
|
|
|
|
Test::Deep::cmp_deeply(@_); |
401
|
|
|
|
|
|
|
} |
402
|
|
|
|
|
|
|
|
403
|
0
|
|
|
0
|
0
|
0
|
sub run_is_deep() { |
404
|
0
|
|
|
|
|
0
|
(my ($self), @_) = find_my_self(@_); |
405
|
0
|
|
|
|
|
0
|
$self->_assert_plan; |
406
|
0
|
|
|
|
|
0
|
my ($x, $y) = $self->_section_names(@_); |
|
0
|
|
|
|
|
0
|
|
407
|
0
|
0
|
0
|
|
|
0
|
for my $block (@{$self->block_list}) { |
408
|
0
|
0
|
|
|
|
0
|
next unless exists($block->{$x}) and exists($block->{$y}); |
409
|
0
|
0
|
|
|
|
0
|
$block->run_filters unless $block->is_filtered; |
410
|
|
|
|
|
|
|
is_deep($block->$x, $block->$y, |
411
|
|
|
|
|
|
|
$block->name ? $block->name : () |
412
|
|
|
|
|
|
|
); |
413
|
|
|
|
|
|
|
} |
414
|
|
|
|
|
|
|
} |
415
|
2
|
|
|
2
|
|
5
|
|
416
|
2
|
|
|
|
|
4
|
sub _pre_eval { |
417
|
2
|
50
|
|
|
|
7
|
my $spec = shift; |
418
|
2
|
50
|
|
|
|
11
|
return unless defined $spec; |
419
|
|
|
|
|
|
|
return $spec unless $spec =~ |
420
|
0
|
|
|
|
|
0
|
s/\A\s*<<<(.*?)>>>\s*$//sm; |
421
|
0
|
|
|
|
|
0
|
my $eval_code = $1; |
422
|
0
|
0
|
|
|
|
0
|
eval "package main; $eval_code"; |
423
|
0
|
|
|
|
|
0
|
croak $@ if $@; |
424
|
|
|
|
|
|
|
return $spec; |
425
|
|
|
|
|
|
|
} |
426
|
2
|
|
|
2
|
|
4
|
|
427
|
2
|
|
|
|
|
40
|
sub _block_list_init { |
428
|
2
|
50
|
|
|
|
8
|
my $spec = $self->spec; |
429
|
2
|
|
|
|
|
10
|
return [] unless defined $spec; |
430
|
2
|
|
|
|
|
48
|
$spec = $self->_pre_eval($spec); |
431
|
2
|
|
|
|
|
96
|
my $cd = $self->block_delim; |
432
|
2
|
|
|
|
|
11
|
my @hunks = ($spec =~ /^(\Q${cd}\E.*?(?=^\Q${cd}\E|\z))/msg); |
433
|
2
|
|
|
|
|
58
|
my $blocks = $self->_choose_blocks(@hunks); |
434
|
2
|
|
|
|
|
4
|
$self->block_list($blocks); # Need to set early for possible filter use |
435
|
2
|
|
|
|
|
6
|
my $seq = 1; |
436
|
3
|
|
|
|
|
53
|
for my $block (@$blocks) { |
437
|
3
|
|
|
|
|
49
|
$block->blocks_object($self); |
438
|
|
|
|
|
|
|
$block->seq_num($seq++); |
439
|
2
|
|
|
|
|
7
|
} |
440
|
|
|
|
|
|
|
return $blocks; |
441
|
|
|
|
|
|
|
} |
442
|
2
|
|
|
2
|
|
6
|
|
443
|
2
|
|
|
|
|
4
|
sub _choose_blocks { |
444
|
2
|
|
|
|
|
5
|
my $blocks = []; |
445
|
3
|
|
|
|
|
11
|
for my $hunk (@_) { |
446
|
3
|
50
|
|
|
|
8
|
my $block = $self->_make_block($hunk); |
447
|
0
|
0
|
|
|
|
0
|
if (exists $block->{ONLY}) { |
448
|
|
|
|
|
|
|
diag "I found ONLY: maybe you're debugging?" |
449
|
0
|
|
|
|
|
0
|
unless $self->_no_diag_on_only; |
450
|
|
|
|
|
|
|
return [$block]; |
451
|
3
|
50
|
|
|
|
10
|
} |
452
|
3
|
|
|
|
|
5
|
next if exists $block->{SKIP}; |
453
|
3
|
50
|
|
|
|
9
|
push @$blocks, $block; |
454
|
0
|
|
|
|
|
0
|
if (exists $block->{LAST}) { |
455
|
|
|
|
|
|
|
return $blocks; |
456
|
|
|
|
|
|
|
} |
457
|
2
|
|
|
|
|
5
|
} |
458
|
|
|
|
|
|
|
return $blocks; |
459
|
|
|
|
|
|
|
} |
460
|
11
|
|
|
11
|
|
13
|
|
461
|
11
|
|
|
|
|
16
|
sub _check_reserved { |
462
|
|
|
|
|
|
|
my $id = shift; |
463
|
11
|
50
|
33
|
|
|
54
|
croak "'$id' is a reserved name. Use something else.\n" |
464
|
|
|
|
|
|
|
if $reserved_section_names->{$id} or |
465
|
|
|
|
|
|
|
$id =~ /^_/; |
466
|
|
|
|
|
|
|
} |
467
|
3
|
|
|
3
|
|
4
|
|
468
|
3
|
|
|
|
|
6
|
sub _make_block { |
469
|
3
|
|
|
|
|
65
|
my $hunk = shift; |
470
|
3
|
|
|
|
|
51
|
my $cd = $self->block_delim; |
471
|
3
|
|
|
|
|
11
|
my $dd = $self->data_delim; |
472
|
3
|
50
|
|
|
|
59
|
my $block = $self->block_class->new; |
473
|
3
|
|
|
|
|
10
|
$hunk =~ s/\A\Q${cd}\E[ \t]*(.*)\s+// or die; |
474
|
3
|
|
|
|
|
82
|
my $name = $1; |
475
|
3
|
|
|
|
|
10
|
my @parts = split /^\Q${dd}\E +\(?(\w+)\)? *(.*)?\n/m, $hunk; |
476
|
3
|
|
50
|
|
|
17
|
my $description = shift @parts; |
477
|
3
|
50
|
|
|
|
8
|
$description ||= ''; |
478
|
3
|
|
|
|
|
7
|
unless ($description =~ /\S/) { |
479
|
|
|
|
|
|
|
$description = $name; |
480
|
3
|
|
|
|
|
17
|
} |
481
|
3
|
|
|
|
|
11
|
$description =~ s/\s*\z//; |
482
|
|
|
|
|
|
|
$block->set_value(description => $description); |
483
|
3
|
|
|
|
|
5
|
|
484
|
3
|
|
|
|
|
6
|
my $section_map = {}; |
485
|
3
|
|
|
|
|
9
|
my $section_order = []; |
486
|
11
|
|
|
|
|
27
|
while (@parts) { |
487
|
11
|
|
|
|
|
23
|
my ($type, $filters, $value) = splice(@parts, 0, 3); |
488
|
11
|
100
|
|
|
|
19
|
$self->_check_reserved($type); |
489
|
11
|
50
|
|
|
|
19
|
$value = '' unless defined $value; |
490
|
11
|
100
|
|
|
|
31
|
$filters = '' unless defined $filters; |
491
|
6
|
50
|
|
|
|
14
|
if ($filters =~ /:(\s|\z)/) { |
492
|
|
|
|
|
|
|
croak "Extra lines not allowed in '$type' section" |
493
|
6
|
|
|
|
|
24
|
if $value =~ /\S/; |
494
|
6
|
50
|
|
|
|
20
|
($filters, $value) = split /\s*:(?:\s+|\z)/, $filters, 2; |
495
|
6
|
|
|
|
|
30
|
$value = '' unless defined $value; |
496
|
|
|
|
|
|
|
$value =~ s/^\s*(.*?)\s*$/$1/; |
497
|
11
|
|
|
|
|
32
|
} |
498
|
|
|
|
|
|
|
$section_map->{$type} = { |
499
|
|
|
|
|
|
|
filters => $filters, |
500
|
11
|
|
|
|
|
17
|
}; |
501
|
11
|
|
|
|
|
21
|
push @$section_order, $type; |
502
|
|
|
|
|
|
|
$block->set_value($type, $value); |
503
|
3
|
|
|
|
|
10
|
} |
504
|
3
|
|
|
|
|
9
|
$block->set_value(name => $name); |
505
|
3
|
|
|
|
|
9
|
$block->set_value(_section_map => $section_map); |
506
|
3
|
|
|
|
|
8
|
$block->set_value(_section_order => $section_order); |
507
|
|
|
|
|
|
|
return $block; |
508
|
|
|
|
|
|
|
} |
509
|
2
|
|
|
2
|
|
4
|
|
510
|
2
|
50
|
|
|
|
40
|
sub _spec_init { |
511
|
|
|
|
|
|
|
return $self->_spec_string |
512
|
2
|
|
|
|
|
8
|
if $self->_spec_string; |
513
|
2
|
|
|
|
|
4
|
local $/; |
514
|
2
|
50
|
|
|
|
35
|
my $spec; |
515
|
0
|
0
|
|
|
|
0
|
if (my $spec_file = $self->_spec_file) { |
516
|
0
|
|
|
|
|
0
|
open FILE, $spec_file or die $!; |
517
|
0
|
|
|
|
|
0
|
$spec = <FILE>; |
518
|
|
|
|
|
|
|
close FILE; |
519
|
|
|
|
|
|
|
} |
520
|
2
|
|
|
|
|
14
|
else { |
521
|
2
|
|
|
|
|
11
|
require Scalar::Util; |
522
|
2
|
50
|
|
|
|
7
|
my $handle = Scalar::Util::openhandle( \*main::DATA ); |
523
|
2
|
|
|
|
|
42
|
if ($handle) { |
524
|
|
|
|
|
|
|
$spec = <$handle>; |
525
|
|
|
|
|
|
|
} |
526
|
2
|
|
|
|
|
18
|
} |
527
|
|
|
|
|
|
|
return $spec; |
528
|
|
|
|
|
|
|
} |
529
|
|
|
|
|
|
|
|
530
|
5
|
|
|
5
|
|
27
|
sub _strict_warnings() { |
531
|
5
|
|
|
|
|
10
|
require Filter::Util::Call; |
532
|
|
|
|
|
|
|
my $done = 0; |
533
|
|
|
|
|
|
|
Filter::Util::Call::filter_add( |
534
|
5
|
50
|
|
5
|
|
19
|
sub { |
535
|
5
|
|
|
|
|
15
|
return 0 if $done; |
536
|
5
|
|
|
|
|
92
|
my ($data, $end) = ('', ''); |
537
|
265
|
50
|
|
|
|
350
|
while (my $status = Filter::Util::Call::filter_read()) { |
538
|
265
|
100
|
|
|
|
416
|
return $status if $status < 0; |
539
|
5
|
|
|
|
|
11
|
if (/^__(?:END|DATA)__\r?$/) { |
540
|
5
|
|
|
|
|
12
|
$end = $_; |
541
|
|
|
|
|
|
|
last; |
542
|
260
|
|
|
|
|
291
|
} |
543
|
260
|
|
|
|
|
444
|
$data .= $_; |
544
|
|
|
|
|
|
|
$_ = ''; |
545
|
5
|
|
|
|
|
42
|
} |
546
|
5
|
|
|
|
|
144
|
$_ = "use strict;use warnings;$data$end"; |
547
|
|
|
|
|
|
|
$done = 1; |
548
|
5
|
|
|
|
|
38
|
} |
549
|
|
|
|
|
|
|
); |
550
|
|
|
|
|
|
|
} |
551
|
|
|
|
|
|
|
|
552
|
0
|
|
|
0
|
0
|
0
|
sub tie_output() { |
553
|
0
|
0
|
|
|
|
0
|
my $handle = shift; |
554
|
0
|
|
|
|
|
0
|
die "No buffer to tie" unless @_; |
555
|
|
|
|
|
|
|
tie *$handle, 'Test::Base::Handle', $_[0]; |
556
|
|
|
|
|
|
|
} |
557
|
0
|
|
|
0
|
0
|
0
|
|
558
|
0
|
|
|
|
|
0
|
sub no_diff { |
559
|
|
|
|
|
|
|
$ENV{TEST_SHOW_NO_DIFFS} = 1; |
560
|
|
|
|
|
|
|
} |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
package Test::Base::Handle; |
563
|
|
|
|
|
|
|
|
564
|
0
|
|
|
0
|
|
0
|
sub TIEHANDLE() { |
565
|
0
|
|
|
|
|
0
|
my $class = shift; |
566
|
|
|
|
|
|
|
bless \ $_[0], $class; |
567
|
|
|
|
|
|
|
} |
568
|
0
|
|
|
0
|
|
0
|
|
569
|
0
|
|
|
|
|
0
|
sub PRINT { |
570
|
|
|
|
|
|
|
$$self .= $_ for @_; |
571
|
|
|
|
|
|
|
} |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
#=============================================================================== |
574
|
|
|
|
|
|
|
# Test::Base::Block |
575
|
|
|
|
|
|
|
# |
576
|
|
|
|
|
|
|
# This is the default class for accessing a Test::Base block object. |
577
|
|
|
|
|
|
|
#=============================================================================== |
578
|
|
|
|
|
|
|
package Test::Base::Block; |
579
|
|
|
|
|
|
|
our @ISA = qw(Spiffy); |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
our @EXPORT = qw(block_accessor); |
582
|
0
|
|
|
0
|
|
0
|
|
583
|
0
|
|
|
|
|
0
|
sub AUTOLOAD { |
584
|
|
|
|
|
|
|
return; |
585
|
|
|
|
|
|
|
} |
586
|
|
|
|
|
|
|
|
587
|
23
|
|
|
23
|
|
36
|
sub block_accessor() { |
588
|
5
|
|
|
5
|
|
39
|
my $accessor = shift; |
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
817
|
|
589
|
23
|
50
|
|
|
|
74
|
no strict 'refs'; |
590
|
|
|
|
|
|
|
return if defined &$accessor; |
591
|
36
|
|
|
36
|
|
666
|
*$accessor = sub { |
592
|
36
|
50
|
|
|
|
68
|
my $self = shift; |
593
|
0
|
|
|
|
|
0
|
if (@_) { |
594
|
|
|
|
|
|
|
Carp::croak "Not allowed to set values for '$accessor'"; |
595
|
36
|
50
|
|
|
|
42
|
} |
|
36
|
|
|
|
|
146
|
|
596
|
|
|
|
|
|
|
my @list = @{$self->{$accessor} || []}; |
597
|
36
|
100
|
|
|
|
142
|
return wantarray |
598
|
|
|
|
|
|
|
? (@list) |
599
|
23
|
|
|
|
|
185
|
: $list[0]; |
600
|
|
|
|
|
|
|
}; |
601
|
|
|
|
|
|
|
} |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
block_accessor 'name'; |
604
|
|
|
|
|
|
|
block_accessor 'description'; |
605
|
|
|
|
|
|
|
Spiffy::field 'seq_num'; |
606
|
|
|
|
|
|
|
Spiffy::field 'is_filtered'; |
607
|
|
|
|
|
|
|
Spiffy::field 'blocks_object'; |
608
|
|
|
|
|
|
|
Spiffy::field 'original_values' => {}; |
609
|
51
|
|
|
51
|
|
63
|
|
610
|
5
|
|
|
5
|
|
43
|
sub set_value { |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
956
|
|
611
|
51
|
|
|
|
|
58
|
no strict 'refs'; |
612
|
51
|
100
|
|
|
|
143
|
my $accessor = shift; |
613
|
|
|
|
|
|
|
block_accessor $accessor |
614
|
51
|
|
|
|
|
189
|
unless defined &$accessor; |
615
|
|
|
|
|
|
|
$self->{$accessor} = [@_]; |
616
|
|
|
|
|
|
|
} |
617
|
3
|
|
|
3
|
|
6
|
|
618
|
3
|
|
|
|
|
9
|
sub run_filters { |
619
|
3
|
|
|
|
|
9
|
my $map = $self->_section_map; |
620
|
3
|
50
|
|
|
|
58
|
my $order = $self->_section_order; |
621
|
|
|
|
|
|
|
Carp::croak "Attempt to filter a block twice" |
622
|
3
|
|
|
|
|
8
|
if $self->is_filtered; |
623
|
11
|
|
|
|
|
27
|
for my $type (@$order) { |
624
|
11
|
|
|
|
|
66
|
my $filters = $map->{$type}{filters}; |
625
|
11
|
|
|
|
|
217
|
my @value = $self->$type; |
626
|
11
|
|
|
|
|
34
|
$self->original_values->{$type} = $value[0]; |
627
|
28
|
50
|
|
|
|
75
|
for my $filter ($self->_get_filters($type, $filters)) { |
628
|
|
|
|
|
|
|
$Test::Base::Filter::arguments = |
629
|
28
|
|
|
|
|
60
|
$filter =~ s/=(.*)$// ? $1 : undef; |
630
|
5
|
|
|
5
|
|
31
|
my $function = "main::$filter"; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
2479
|
|
631
|
28
|
50
|
|
|
|
110
|
no strict 'refs'; |
632
|
0
|
0
|
0
|
|
|
0
|
if (defined &$function) { |
633
|
|
|
|
|
|
|
local $_ = |
634
|
|
|
|
|
|
|
(@value == 1 and not defined($value[0])) ? undef : |
635
|
0
|
|
|
|
|
0
|
join '', @value; |
636
|
0
|
|
|
|
|
0
|
my $old = $_; |
637
|
0
|
0
|
0
|
|
|
0
|
@value = &$function(@value); |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
638
|
|
|
|
|
|
|
if (not(@value) or |
639
|
|
|
|
|
|
|
@value == 1 and defined($value[0]) and $value[0] =~ /\A(\d+|)\z/ |
640
|
0
|
0
|
0
|
|
|
0
|
) { |
641
|
0
|
|
|
|
|
0
|
if ($value[0] && $_ eq $old) { |
642
|
|
|
|
|
|
|
Test::Base::diag("Filters returning numbers are supposed to do munging \$_: your filter '$function' apparently doesn't."); |
643
|
0
|
|
|
|
|
0
|
} |
644
|
|
|
|
|
|
|
@value = ($_); |
645
|
|
|
|
|
|
|
} |
646
|
|
|
|
|
|
|
} |
647
|
28
|
|
|
|
|
494
|
else { |
648
|
28
|
50
|
|
|
|
48
|
my $filter_object = $self->blocks_object->filter_class->new; |
649
|
|
|
|
|
|
|
die "Can't find a function or method for '$filter' filter\n" |
650
|
28
|
|
|
|
|
461
|
unless $filter_object->can($filter); |
651
|
28
|
|
|
|
|
70
|
$filter_object->current_block($self); |
652
|
|
|
|
|
|
|
@value = $filter_object->$filter(@value); |
653
|
|
|
|
|
|
|
} |
654
|
|
|
|
|
|
|
# Set the value after each filter since other filters may be |
655
|
28
|
|
|
|
|
62
|
# introspecting. |
656
|
|
|
|
|
|
|
$self->set_value($type, @value); |
657
|
|
|
|
|
|
|
} |
658
|
3
|
|
|
|
|
51
|
} |
659
|
|
|
|
|
|
|
$self->is_filtered(1); |
660
|
|
|
|
|
|
|
} |
661
|
11
|
|
|
11
|
|
17
|
|
662
|
11
|
|
|
|
|
16
|
sub _get_filters { |
663
|
11
|
|
100
|
|
|
37
|
my $type = shift; |
664
|
11
|
|
|
|
|
43
|
my $string = shift || ''; |
665
|
11
|
|
|
|
|
22
|
$string =~ s/\s*(.*?)\s*/$1/; |
666
|
11
|
|
100
|
|
|
198
|
my @filters = (); |
667
|
11
|
50
|
|
|
|
31
|
my $map_filters = $self->blocks_object->_filters_map->{$type} || []; |
668
|
11
|
|
|
|
|
21
|
$map_filters = [ $map_filters ] unless ref $map_filters; |
669
|
11
|
|
|
|
|
17
|
my @append = (); |
670
|
11
|
|
|
|
|
150
|
for ( |
671
|
|
|
|
|
|
|
@{$self->blocks_object->_filters}, |
672
|
|
|
|
|
|
|
@$map_filters, |
673
|
|
|
|
|
|
|
split(/\s+/, $string), |
674
|
28
|
|
|
|
|
36
|
) { |
675
|
28
|
50
|
|
|
|
46
|
my $filter = $_; |
676
|
28
|
50
|
|
|
|
59
|
last unless length $filter; |
|
|
50
|
|
|
|
|
|
677
|
0
|
|
|
|
|
0
|
if ($filter =~ s/^-//) { |
|
0
|
|
|
|
|
0
|
|
678
|
|
|
|
|
|
|
@filters = grep { $_ ne $filter } @filters; |
679
|
|
|
|
|
|
|
} |
680
|
0
|
|
|
|
|
0
|
elsif ($filter =~ s/^\+//) { |
681
|
|
|
|
|
|
|
push @append, $filter; |
682
|
|
|
|
|
|
|
} |
683
|
28
|
|
|
|
|
48
|
else { |
684
|
|
|
|
|
|
|
push @filters, $filter; |
685
|
|
|
|
|
|
|
} |
686
|
11
|
|
|
|
|
27
|
} |
687
|
|
|
|
|
|
|
return @filters, @append; |
688
|
|
|
|
|
|
|
} |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
{ |
691
|
|
|
|
|
|
|
%$reserved_section_names = map { |
692
|
|
|
|
|
|
|
($_, 1); |
693
|
|
|
|
|
|
|
} keys(%Test::Base::Block::), qw( new DESTROY ); |
694
|
|
|
|
|
|
|
} |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
1; |