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