| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Base::Less; |
|
2
|
10
|
|
|
10
|
|
21478
|
use strict; |
|
|
10
|
|
|
|
|
18
|
|
|
|
10
|
|
|
|
|
429
|
|
|
3
|
10
|
|
|
10
|
|
52
|
use warnings; |
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
249
|
|
|
4
|
10
|
|
|
10
|
|
1161
|
use utf8; |
|
|
10
|
|
|
|
|
24
|
|
|
|
10
|
|
|
|
|
52
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
10
|
|
|
10
|
|
12059
|
use parent qw/Test::Builder::Module Exporter/; |
|
|
10
|
|
|
|
|
3523
|
|
|
|
10
|
|
|
|
|
55
|
|
|
9
|
10
|
|
|
10
|
|
235866
|
use Test::More; |
|
|
10
|
|
|
|
|
79919
|
|
|
|
10
|
|
|
|
|
234
|
|
|
10
|
10
|
|
|
10
|
|
17934
|
use Data::Section::TestBase (); |
|
|
10
|
|
|
|
|
39
|
|
|
|
10
|
|
|
|
|
222
|
|
|
11
|
10
|
|
|
10
|
|
59
|
use Carp (); |
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
3563
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = (@Test::More::EXPORT, qw/filters blocks register_filter run run_is run_is_deeply/); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our %FILTER_MAP; |
|
16
|
|
|
|
|
|
|
our %FILTERS; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub register_filter($&) { |
|
19
|
40
|
|
|
40
|
1
|
241
|
my ($name, $code) = @_; |
|
20
|
40
|
|
|
|
|
143
|
$FILTERS{$name} = $code; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub filters($) { |
|
24
|
6
|
|
|
6
|
1
|
93
|
my $data = shift; |
|
25
|
6
|
|
|
|
|
34
|
for my $key (keys %$data) { |
|
26
|
8
|
|
50
|
|
|
66
|
$FILTER_MAP{$key} ||= []; |
|
27
|
8
|
|
|
|
|
15
|
push @{$FILTER_MAP{$key}}, @{$data->{$key}}; |
|
|
8
|
|
|
|
|
19
|
|
|
|
8
|
|
|
|
|
36
|
|
|
28
|
|
|
|
|
|
|
} |
|
29
|
6
|
|
|
|
|
23
|
return; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub blocks() { |
|
33
|
7
|
|
|
7
|
1
|
52
|
my @blocks = _get_blocks(scalar(caller(0))); |
|
34
|
7
|
|
|
|
|
78
|
return @blocks; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _get_blocks { |
|
38
|
14
|
|
|
14
|
|
32
|
my $package = shift; |
|
39
|
|
|
|
|
|
|
|
|
40
|
10
|
|
|
10
|
|
58
|
my $d = do { no strict 'refs'; \*{"${package}::DATA"} }; |
|
|
10
|
|
|
|
|
1237
|
|
|
|
10
|
|
|
|
|
11426
|
|
|
|
14
|
|
|
|
|
29
|
|
|
|
14
|
|
|
|
|
25
|
|
|
|
14
|
|
|
|
|
88
|
|
|
41
|
14
|
50
|
|
|
|
78
|
unless (defined fileno $d) { |
|
42
|
0
|
|
|
|
|
0
|
Carp::croak("Missing __DATA__ section in $package."); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
14
|
|
|
|
|
158
|
seek $d, 0, 0; |
|
45
|
|
|
|
|
|
|
|
|
46
|
14
|
|
|
|
|
1098
|
my $content = join '', <$d>; |
|
47
|
|
|
|
|
|
|
|
|
48
|
14
|
|
|
|
|
274
|
my $parser = Text::TestBase->new(); |
|
49
|
14
|
|
|
|
|
82
|
my @blocks = $parser->parse($content); |
|
50
|
14
|
|
|
|
|
40
|
my @retval; |
|
51
|
14
|
|
|
|
|
51
|
for my $block (@blocks) { |
|
52
|
26
|
|
|
|
|
103
|
for my $section_name ($block->get_section_names) { |
|
53
|
37
|
|
|
|
|
159
|
my @data = $block->get_section($section_name); |
|
54
|
37
|
100
|
|
|
|
135
|
if (my $filter_names = $FILTER_MAP{$section_name}) { |
|
55
|
19
|
|
|
|
|
41
|
for my $filter_stuff (@$filter_names) { |
|
56
|
22
|
100
|
|
|
|
60
|
if (ref $filter_stuff eq 'CODE') { # filters { input => [\&code] }; |
|
57
|
4
|
|
|
|
|
109
|
@data = $filter_stuff->(@data); |
|
58
|
|
|
|
|
|
|
} else { # filters { input => [qw/eval/] }; |
|
59
|
18
|
|
|
|
|
35
|
my $filter = $FILTERS{$filter_stuff}; |
|
60
|
18
|
50
|
|
|
|
54
|
unless ($filter) { |
|
61
|
0
|
|
|
|
|
0
|
Carp::croak "Unknown filter name: $filter_stuff"; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
18
|
|
|
|
|
43
|
@data = $filter->(@data); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
} |
|
67
|
37
|
|
|
|
|
162
|
$block->set_section($section_name => @data); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
26
|
100
|
|
|
|
156
|
if ($block->has_section('ONLY')) { |
|
70
|
1
|
|
|
|
|
12
|
__PACKAGE__->builder->diag("I found ONLY: maybe you're debugging?"); |
|
71
|
1
|
|
|
|
|
339
|
return $block; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
25
|
100
|
|
|
|
139
|
if ($block->has_section('SKIP')) { |
|
74
|
1
|
|
|
|
|
3
|
next; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
24
|
|
|
|
|
54
|
push @retval, $block; |
|
77
|
24
|
100
|
|
|
|
79
|
if ($block->has_section('LAST')) { |
|
78
|
1
|
|
|
|
|
19
|
return @retval; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
} |
|
81
|
12
|
|
|
|
|
131
|
return @retval; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub run(&) { |
|
85
|
4
|
|
|
4
|
0
|
750
|
my $code = shift; |
|
86
|
|
|
|
|
|
|
|
|
87
|
4
|
|
|
|
|
34
|
for my $block (_get_blocks(scalar(caller(0)))) { |
|
88
|
|
|
|
|
|
|
__PACKAGE__->builder->subtest($block->name || 'L: ' . $block->get_lineno, sub { |
|
89
|
8
|
|
|
8
|
|
6687
|
$code->($block); |
|
90
|
8
|
|
66
|
|
|
5895
|
}); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub run_is($$) { |
|
95
|
2
|
|
|
2
|
0
|
18
|
my ($a, $b) = @_; |
|
96
|
|
|
|
|
|
|
|
|
97
|
2
|
|
|
|
|
15
|
for my $block (_get_blocks(scalar(caller(0)))) { |
|
98
|
3
|
|
66
|
|
|
1078
|
__PACKAGE__->builder->is_eq( |
|
99
|
|
|
|
|
|
|
$block->get_section($a), |
|
100
|
|
|
|
|
|
|
$block->get_section($b), |
|
101
|
|
|
|
|
|
|
$block->name || 'L: ' . $block->get_lineno |
|
102
|
|
|
|
|
|
|
); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub run_is_deeply($$) { |
|
107
|
1
|
|
|
1
|
0
|
8
|
my ($a, $b) = @_; |
|
108
|
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
7
|
for my $block (_get_blocks(scalar(caller(0)))) { |
|
110
|
1
|
|
|
|
|
4
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
|
111
|
1
|
|
33
|
|
|
6
|
Test::More::is_deeply( |
|
112
|
|
|
|
|
|
|
$block->get_section($a), |
|
113
|
|
|
|
|
|
|
$block->get_section($b), |
|
114
|
|
|
|
|
|
|
$block->name || 'L: ' . $block->get_lineno |
|
115
|
|
|
|
|
|
|
); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
package Test::Base::Less::Filter; |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Test::Base::Less::register_filter(eval => \&_eval); |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub _eval { |
|
124
|
12
|
|
|
12
|
|
21
|
my $src = shift; |
|
125
|
10
|
|
|
10
|
|
302
|
no warnings; |
|
|
10
|
|
|
|
|
27
|
|
|
|
10
|
|
|
|
|
4522
|
|
|
126
|
12
|
|
|
|
|
1348
|
my @return = CORE::eval $src; |
|
127
|
12
|
50
|
|
|
|
71
|
return $@ if $@; |
|
128
|
12
|
|
|
|
|
94
|
return @return; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Test::Base::Less::register_filter(chomp => \&_chomp); |
|
132
|
|
|
|
|
|
|
sub _chomp { |
|
133
|
0
|
|
|
0
|
|
0
|
map { CORE::chomp; $_ } @_; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Test::Base::Less::register_filter(uc => \&_uc); |
|
137
|
|
|
|
|
|
|
sub _uc { |
|
138
|
1
|
|
|
1
|
|
47
|
map { CORE::uc($_) } @_; |
|
|
1
|
|
|
|
|
16
|
|
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Test::Base::Less::register_filter(trim => \&_trim); |
|
142
|
|
|
|
|
|
|
sub _trim { |
|
143
|
5
|
|
|
|
|
23
|
map { |
|
144
|
5
|
|
|
5
|
|
8
|
s/\A([ \t]*\n)+//; |
|
145
|
5
|
|
|
|
|
35
|
s/(?<=\n)\s*\z//g; |
|
146
|
5
|
|
|
|
|
28
|
$_; |
|
147
|
|
|
|
|
|
|
} @_; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
1; |
|
151
|
|
|
|
|
|
|
__END__ |