File Coverage

inc/Test/Base.pm
Criterion Covered Total %
statement 79 382 20.6
branch 17 192 8.8
condition 12 83 14.4
subroutine 23 64 35.9
pod 0 29 0.0
total 131 750 17.4


line stmt bran cond sub pod time code
1             package Test::Base;
2             our $VERSION = '0.86';
3              
4 10     10   38041 use Spiffy -Base;
  10         45  
  10         122  
5 10     10   158 use Spiffy ':XXX';
  10     10   21  
  10     10   408  
  10         61  
  10         17  
  10         417  
  10         52  
  10         20  
  10         114  
6              
7             my $HAS_PROVIDER;
8             BEGIN {
9 10     10   732 $HAS_PROVIDER = eval "require Test::Builder::Provider; 1";
10              
11 10 50       68 if ($HAS_PROVIDER) {
12 0         0 Test::Builder::Provider->import('provides');
13             }
14             else {
15 10     10   647 *provides = sub { 1 };
  10         21  
16             }
17             }
18              
19              
20             my @test_more_exports;
21             BEGIN {
22 10     10   299 @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 10     10   19617 use Test::More import => \@test_more_exports;
  10         367418  
  10         127  
33 10     10   3824 use Carp;
  10         25  
  10         5831  
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 125     125 0 192 sub default_object {
75 125   66     1335 $default_object ||= $default_class->new;
76 125         236 return $default_object;
77             }
78              
79             my $import_called = 0;
80             sub import() {
81 20     20   688 $import_called = 1;
82 20 100       242 my $class = (grep /^-base$/i, @_)
83             ? scalar(caller)
84             : $_[0];
85 20 100       101 if (not defined $default_class) {
86 10         23 $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 20 100       138 unless (grep /^-base$/i, @_) {
94 10         35 my @args;
95 10         78 for (my $ii = 1; $ii <= $#_; ++$ii) {
96 20 50       153 if ($_[$ii] eq '-package') {
97 0         0 ++$ii;
98             } else {
99 20         126 push @args, $_[$ii];
100             }
101             }
102 10 50       199 Test::More->import(import => \@test_more_exports, @args)
103             if @args;
104             }
105              
106 20         8681 _strict_warnings();
107 20         477 goto &Spiffy::import;
108             }
109              
110             # Wrap Test::Builder::plan
111             my $plan_code = \&Test::Builder::plan;
112             my $Have_Plan = 0;
113             {
114 10     10   69 no warnings 'redefine';
  10         26  
  10         95764  
115             *Test::Builder::plan = sub {
116 10     10   6001 $Have_Plan = 1;
117 10         103 goto &$plan_code;
118             };
119             }
120              
121             my $DIED = 0;
122             $SIG{__DIE__} = sub { $DIED = 1; die @_ };
123              
124 0     0 0 0 sub block_class { $self->find_class('Block') }
  0         0  
125 0     0 0 0 sub filter_class { $self->find_class('Filter') }
  0         0  
126              
127 0     0 0 0 sub find_class {
128 0         0 my $suffix = shift;
129 0         0 my $class = ref($self) . "::$suffix";
130 0 0       0 return $class if $class->can('new');
131 0         0 $class = __PACKAGE__ . "::$suffix";
132 0 0       0 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 125 50   125 0 455 my $self = ref($_[0]) eq $default_class
148             ? splice(@_, 0, 1)
149             : default_object();
150 125         598 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 0     0 0 0 (my ($self), @_) = find_my_self(@_);
237 0 0       0 if (ref($_[0]) eq 'HASH') {
238 0         0 $self->_filters_map(shift);
239             }
240             else {
241 0         0 my $filters = $self->_filters;
242 0         0 push @$filters, @_;
243             }
244 0         0 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 125     125 0 2120 (my ($self), @_) = find_my_self(@_);
260 125         293 my ($actual, $expected, $name) = @_;
261 125 50       369 local $Test::Builder::Level = $Test::Builder::Level + 1 unless $HAS_PROVIDER;
262 125 50 66     1451 if ($ENV{TEST_SHOW_NO_DIFFS} or
      66        
      66        
      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 125         473 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 0     0   0 sub _section_names {
289 0 0       0 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 0     0   0 sub _assert_plan {
301 0 0       0 plan('no_plan') unless $Have_Plan;
302             }
303              
304 10     10   4204 sub END {
305 10 0 33     603 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 0     0 0 0 (my ($self), @_) = find_my_self(@_);
332 0         0 $self->_assert_plan;
333 0         0 my ($x, $y) = $self->_section_names(@_);
334 0         0 local $Test::Builder::Level = $Test::Builder::Level + 1;
335 0         0 for my $block (@{$self->block_list}) {
  0         0  
336 0 0 0     0 next unless exists($block->{$x}) and exists($block->{$y});
337 0 0       0 $block->run_filters unless $block->is_filtered;
338 0 0       0 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 0     0   0 sub _pre_eval {
414 0         0 my $spec = shift;
415 0 0       0 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 0     0   0 sub _block_list_init {
424 0         0 my $spec = $self->spec;
425 0         0 $spec = $self->_pre_eval($spec);
426 0         0 my $cd = $self->block_delim;
427 0         0 my @hunks = ($spec =~ /^(\Q${cd}\E.*?(?=^\Q${cd}\E|\z))/msg);
428 0         0 my $blocks = $self->_choose_blocks(@hunks);
429 0         0 $self->block_list($blocks); # Need to set early for possible filter use
430 0         0 my $seq = 1;
431 0         0 for my $block (@$blocks) {
432 0         0 $block->blocks_object($self);
433 0         0 $block->seq_num($seq++);
434             }
435 0         0 return $blocks;
436             }
437              
438 0     0   0 sub _choose_blocks {
439 0         0 my $blocks = [];
440 0         0 for my $hunk (@_) {
441 0         0 my $block = $self->_make_block($hunk);
442 0 0       0 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 0 0       0 next if exists $block->{SKIP};
448 0         0 push @$blocks, $block;
449 0 0       0 if (exists $block->{LAST}) {
450 0         0 return $blocks;
451             }
452             }
453 0         0 return $blocks;
454             }
455              
456 0     0   0 sub _check_reserved {
457 0         0 my $id = shift;
458 0 0 0     0 croak "'$id' is a reserved name. Use something else.\n"
459             if $reserved_section_names->{$id} or
460             $id =~ /^_/;
461             }
462              
463 0     0   0 sub _make_block {
464 0         0 my $hunk = shift;
465 0         0 my $cd = $self->block_delim;
466 0         0 my $dd = $self->data_delim;
467 0         0 my $block = $self->block_class->new;
468 0 0       0 $hunk =~ s/\A\Q${cd}\E[ \t]*(.*)\s+// or die;
469 0         0 my $name = $1;
470 0         0 my @parts = split /^\Q${dd}\E +\(?(\w+)\)? *(.*)?\n/m, $hunk;
471 0         0 my $description = shift @parts;
472 0   0     0 $description ||= '';
473 0 0       0 unless ($description =~ /\S/) {
474 0         0 $description = $name;
475             }
476 0         0 $description =~ s/\s*\z//;
477 0         0 $block->set_value(description => $description);
478              
479 0         0 my $section_map = {};
480 0         0 my $section_order = [];
481 0         0 while (@parts) {
482 0         0 my ($type, $filters, $value) = splice(@parts, 0, 3);
483 0         0 $self->_check_reserved($type);
484 0 0       0 $value = '' unless defined $value;
485 0 0       0 $filters = '' unless defined $filters;
486 0 0       0 if ($filters =~ /:(\s|\z)/) {
487 0 0       0 croak "Extra lines not allowed in '$type' section"
488             if $value =~ /\S/;
489 0         0 ($filters, $value) = split /\s*:(?:\s+|\z)/, $filters, 2;
490 0 0       0 $value = '' unless defined $value;
491 0         0 $value =~ s/^\s*(.*?)\s*$/$1/;
492             }
493 0         0 $section_map->{$type} = {
494             filters => $filters,
495             };
496 0         0 push @$section_order, $type;
497 0         0 $block->set_value($type, $value);
498             }
499 0         0 $block->set_value(name => $name);
500 0         0 $block->set_value(_section_map => $section_map);
501 0         0 $block->set_value(_section_order => $section_order);
502 0         0 return $block;
503             }
504              
505 0     0   0 sub _spec_init {
506 0 0       0 return $self->_spec_string
507             if $self->_spec_string;
508 0         0 local $/;
509 0         0 my $spec;
510 0 0       0 if (my $spec_file = $self->_spec_file) {
511 0         0 warn "$spec_file";
512 0 0       0 open FILE, $spec_file or die $!;
513 0         0 $spec = ;
514 0         0 close FILE;
515             }
516             else {
517 0         0 $spec = do {
518             package main;
519 10     10   234 no warnings 'once';
  10         22  
  10         31878  
520 0         0 ;
521             };
522             }
523 0         0 return $spec;
524             }
525              
526             sub _strict_warnings() {
527 20     20   184 require Filter::Util::Call;
528 20         46 my $done = 0;
529             Filter::Util::Call::filter_add(
530             sub {
531 40 100   40   55991 return 0 if $done;
532 20         45 my ($data, $end) = ('', '');
533 20         277 while (my $status = Filter::Util::Call::filter_read()) {
534 429 50       2052 return $status if $status < 0;
535 429 50       820 if (/^__(?:END|DATA)__\r?$/) {
536 0         0 $end = $_;
537 0         0 last;
538             }
539 429         616 $data .= $_;
540 429         1866 $_ = '';
541             }
542 20         119 $_ = "use strict;use warnings;$data$end";
543 20         532 $done = 1;
544             }
545 20         186 );
546             }
547              
548             sub tie_output() {
549 0     0 0 0 my $handle = shift;
550 0 0       0 die "No buffer to tie" unless @_;
551 0         0 tie *$handle, 'Test::Base::Handle', $_[0];
552             }
553              
554 0     0 0 0 sub no_diff {
555 0         0 $ENV{TEST_SHOW_NO_DIFFS} = 1;
556             }
557              
558             package Test::Base::Handle;
559              
560             sub TIEHANDLE() {
561 0     0   0 my $class = shift;
562 0         0 bless \ $_[0], $class;
563             }
564              
565 0     0   0 sub PRINT {
566 0         0 $$self .= $_ for @_;
567             }
568              
569             #===============================================================================
570             # Test::Base::Block
571             #
572             # This is the default class for accessing a Test::Base block object.
573             #===============================================================================
574             package Test::Base::Block;
575             our @ISA = qw(Spiffy);
576              
577             our @EXPORT = qw(block_accessor);
578              
579 0     0   0 sub AUTOLOAD {
580 0         0 return;
581             }
582              
583             sub block_accessor() {
584 20     20   48 my $accessor = shift;
585 10     10   110 no strict 'refs';
  10         30  
  10         2983  
586 20 50       154 return if defined &$accessor;
587             *$accessor = sub {
588 0     0     my $self = shift;
589 0 0         if (@_) {
590 0           Carp::croak "Not allowed to set values for '$accessor'";
591             }
592 0 0         my @list = @{$self->{$accessor} || []};
  0            
593             return wantarray
594 0 0         ? (@list)
595             : $list[0];
596 20         245 };
597             }
598              
599             block_accessor 'name';
600             block_accessor 'description';
601             Spiffy::field 'seq_num';
602             Spiffy::field 'is_filtered';
603             Spiffy::field 'blocks_object';
604             Spiffy::field 'original_values' => {};
605              
606 0     0     sub set_value {
607 10     10   61 no strict 'refs';
  10         42  
  10         2482  
608 0           my $accessor = shift;
609 0 0         block_accessor $accessor
610             unless defined &$accessor;
611 0           $self->{$accessor} = [@_];
612             }
613              
614 0     0     sub run_filters {
615 0           my $map = $self->_section_map;
616 0           my $order = $self->_section_order;
617 0 0         Carp::croak "Attempt to filter a block twice"
618             if $self->is_filtered;
619 0           for my $type (@$order) {
620 0           my $filters = $map->{$type}{filters};
621 0           my @value = $self->$type;
622 0           $self->original_values->{$type} = $value[0];
623 0           for my $filter ($self->_get_filters($type, $filters)) {
624 0 0         $Test::Base::Filter::arguments =
625             $filter =~ s/=(.*)$// ? $1 : undef;
626 0           my $function = "main::$filter";
627 10     10   62 no strict 'refs';
  10         19  
  10         6590  
628 0 0         if (defined &$function) {
629 0 0 0       local $_ =
630             (@value == 1 and not defined($value[0])) ? undef :
631             join '', @value;
632 0           my $old = $_;
633 0           @value = &$function(@value);
634 0 0 0       if (not(@value) or
      0        
      0        
635             @value == 1 and defined($value[0]) and $value[0] =~ /\A(\d+|)\z/
636             ) {
637 0 0 0       if ($value[0] && $_ eq $old) {
638 0           Test::Base::diag("Filters returning numbers are supposed to do munging \$_: your filter '$function' apparently doesn't.");
639             }
640 0           @value = ($_);
641             }
642             }
643             else {
644 0           my $filter_object = $self->blocks_object->filter_class->new;
645 0 0         die "Can't find a function or method for '$filter' filter\n"
646             unless $filter_object->can($filter);
647 0           $filter_object->current_block($self);
648 0           @value = $filter_object->$filter(@value);
649             }
650             # Set the value after each filter since other filters may be
651             # introspecting.
652 0           $self->set_value($type, @value);
653             }
654             }
655 0           $self->is_filtered(1);
656             }
657              
658 0     0     sub _get_filters {
659 0           my $type = shift;
660 0   0       my $string = shift || '';
661 0           $string =~ s/\s*(.*?)\s*/$1/;
662 0           my @filters = ();
663 0   0       my $map_filters = $self->blocks_object->_filters_map->{$type} || [];
664 0 0         $map_filters = [ $map_filters ] unless ref $map_filters;
665 0           my @append = ();
666 0           for (
667 0           @{$self->blocks_object->_filters},
668             @$map_filters,
669             split(/\s+/, $string),
670             ) {
671 0           my $filter = $_;
672 0 0         last unless length $filter;
673 0 0         if ($filter =~ s/^-//) {
    0          
674 0           @filters = grep { $_ ne $filter } @filters;
  0            
675             }
676             elsif ($filter =~ s/^\+//) {
677 0           push @append, $filter;
678             }
679             else {
680 0           push @filters, $filter;
681             }
682             }
683 0           return @filters, @append;
684             }
685              
686             {
687             %$reserved_section_names = map {
688             ($_, 1);
689             } keys(%Test::Base::Block::), qw( new DESTROY );
690             }
691              
692             1;