line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
|
|
|
|
|
|
#=============================================================================== |
3
|
|
|
|
|
|
|
# This is the default class for handling Test::Base data filtering. |
4
|
|
|
|
|
|
|
#=============================================================================== |
5
|
2
|
|
|
2
|
|
13
|
use Spiffy -Base; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
6
|
2
|
|
|
2
|
|
18
|
use Spiffy ':XXX'; |
|
2
|
|
|
2
|
|
6
|
|
|
2
|
|
|
2
|
|
50
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
field 'current_block'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $arguments; |
11
|
0
|
|
|
0
|
0
|
0
|
return undef unless defined $arguments; |
12
|
0
|
0
|
|
|
|
0
|
my $args = $arguments; |
13
|
0
|
|
|
|
|
0
|
$args =~ s/(\\s)/ /g; |
14
|
0
|
|
|
|
|
0
|
$args =~ s/(\\[a-z])/'"' . $1 . '"'/gee; |
15
|
0
|
|
|
|
|
0
|
return $args; |
|
0
|
|
|
|
|
0
|
|
16
|
0
|
|
|
|
|
0
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
return if @_ == 1; |
19
|
17
|
|
|
17
|
0
|
20
|
require Carp; |
20
|
17
|
50
|
|
|
|
39
|
my $filter = (caller(1))[3]; |
21
|
0
|
|
|
|
|
0
|
$filter =~ s/.*:://; |
22
|
0
|
|
|
|
|
0
|
Carp::croak "Input to the '$filter' filter must be a scalar, not a list"; |
23
|
0
|
|
|
|
|
0
|
} |
24
|
0
|
|
|
|
|
0
|
|
25
|
|
|
|
|
|
|
my $method = shift; |
26
|
|
|
|
|
|
|
return () unless @_; |
27
|
0
|
|
|
0
|
|
0
|
if (ref $_[0] eq 'ARRAY') { |
28
|
0
|
|
|
|
|
0
|
for my $aref (@_) { |
29
|
0
|
0
|
|
|
|
0
|
@$aref = $self->_apply_deepest($method, @$aref); |
30
|
0
|
0
|
|
|
|
0
|
} |
31
|
0
|
|
|
|
|
0
|
return @_; |
32
|
0
|
|
|
|
|
0
|
} |
33
|
|
|
|
|
|
|
$self->$method(@_); |
34
|
0
|
|
|
|
|
0
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
map { |
37
|
|
|
|
|
|
|
[$self->split($_)]; |
38
|
|
|
|
|
|
|
} @_; |
39
|
0
|
|
|
0
|
|
0
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
0
|
return () unless @_; |
|
0
|
|
|
|
|
0
|
|
42
|
|
|
|
|
|
|
if (ref $_[0] eq 'ARRAY') { |
43
|
|
|
|
|
|
|
if (ref $_[0]->[0] eq 'ARRAY') { |
44
|
|
|
|
|
|
|
for my $aref (@_) { |
45
|
0
|
|
|
0
|
|
0
|
@$aref = $self->_peel_deepest(@$aref); |
46
|
0
|
0
|
|
|
|
0
|
} |
47
|
0
|
0
|
|
|
|
0
|
return @_; |
48
|
0
|
0
|
|
|
|
0
|
} |
49
|
0
|
|
|
|
|
0
|
return map { $_->[0] } @_; |
50
|
0
|
|
|
|
|
0
|
} |
51
|
|
|
|
|
|
|
return @_; |
52
|
0
|
|
|
|
|
0
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
0
|
#=============================================================================== |
|
0
|
|
|
|
|
0
|
|
55
|
|
|
|
|
|
|
# these filters work on the leaves of nested arrays |
56
|
0
|
|
|
|
|
0
|
#=============================================================================== |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $suffix = $self->current_arguments; |
60
|
|
|
|
|
|
|
map { $_ . $suffix } @_; |
61
|
|
|
|
|
|
|
} |
62
|
0
|
|
|
0
|
0
|
0
|
|
|
0
|
|
|
|
|
0
|
|
63
|
0
|
|
|
0
|
0
|
0
|
return [@_]; |
|
0
|
|
|
|
|
0
|
|
64
|
0
|
|
|
0
|
0
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
65
|
0
|
|
|
0
|
0
|
0
|
|
|
0
|
|
|
|
|
0
|
|
66
|
|
|
|
|
|
|
$self->assert_scalar(@_); |
67
|
|
|
|
|
|
|
require MIME::Base64; |
68
|
0
|
|
|
0
|
0
|
0
|
MIME::Base64::decode_base64(shift); |
69
|
0
|
|
|
|
|
0
|
} |
70
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
71
|
|
|
|
|
|
|
$self->assert_scalar(@_); |
72
|
|
|
|
|
|
|
require MIME::Base64; |
73
|
0
|
|
|
0
|
0
|
0
|
MIME::Base64::encode_base64(shift); |
74
|
0
|
|
|
|
|
0
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
map { CORE::chomp; $_ } @_; |
77
|
0
|
|
|
0
|
0
|
0
|
} |
78
|
0
|
|
|
|
|
0
|
|
79
|
0
|
|
|
|
|
0
|
map { CORE::chop; $_ } @_; |
80
|
0
|
|
|
|
|
0
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
no warnings 'once'; |
83
|
0
|
|
|
0
|
0
|
0
|
require Data::Dumper; |
84
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Sortkeys = 1; |
85
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Indent = 1; |
86
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Terse = 1; |
87
|
|
|
|
|
|
|
Data::Dumper::Dumper(@_); |
88
|
|
|
|
|
|
|
} |
89
|
0
|
|
|
0
|
0
|
0
|
|
90
|
0
|
|
|
|
|
0
|
$self->assert_scalar(@_); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
91
|
|
|
|
|
|
|
my $text = shift; |
92
|
|
|
|
|
|
|
$text =~ s/(\\.)/eval "qq{$1}"/ge; |
93
|
0
|
|
|
0
|
0
|
0
|
return $text; |
94
|
0
|
|
|
|
|
0
|
} |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
$self->assert_scalar(@_); |
97
|
0
|
|
|
0
|
0
|
0
|
my @return = CORE::eval(shift); |
98
|
2
|
|
|
2
|
|
17
|
return $@ if $@; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
532
|
|
99
|
0
|
|
|
|
|
0
|
return @return; |
100
|
0
|
|
|
|
|
0
|
} |
101
|
0
|
|
|
|
|
0
|
|
102
|
0
|
|
|
|
|
0
|
$self->assert_scalar(@_); |
103
|
0
|
|
|
|
|
0
|
my $out = ''; |
104
|
|
|
|
|
|
|
my $err = ''; |
105
|
|
|
|
|
|
|
Test::Base::tie_output(*STDOUT, $out); |
106
|
0
|
|
|
0
|
0
|
0
|
Test::Base::tie_output(*STDERR, $err); |
107
|
0
|
|
|
|
|
0
|
my $return = CORE::eval(shift); |
108
|
0
|
|
|
|
|
0
|
no warnings; |
109
|
0
|
|
|
|
|
0
|
untie *STDOUT; |
|
0
|
|
|
|
|
0
|
|
110
|
0
|
|
|
|
|
0
|
untie *STDERR; |
111
|
|
|
|
|
|
|
return $return, $@, $out, $err; |
112
|
|
|
|
|
|
|
} |
113
|
6
|
|
|
6
|
0
|
9
|
|
114
|
6
|
|
|
|
|
16
|
$self->assert_scalar(@_); |
115
|
6
|
|
|
|
|
303
|
my $output = ''; |
116
|
6
|
50
|
|
|
|
1723
|
Test::Base::tie_output(*STDERR, $output); |
117
|
6
|
|
|
|
|
23
|
CORE::eval(shift); |
118
|
|
|
|
|
|
|
no warnings; |
119
|
|
|
|
|
|
|
untie *STDERR; |
120
|
0
|
|
|
0
|
0
|
0
|
return $output; |
121
|
0
|
|
|
|
|
0
|
} |
122
|
0
|
|
|
|
|
0
|
|
123
|
0
|
|
|
|
|
0
|
$self->assert_scalar(@_); |
124
|
0
|
|
|
|
|
0
|
my $output = ''; |
125
|
0
|
|
|
|
|
0
|
Test::Base::tie_output(*STDOUT, $output); |
126
|
0
|
|
|
|
|
0
|
CORE::eval(shift); |
127
|
2
|
|
|
2
|
|
15
|
no warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
196
|
|
128
|
0
|
|
|
|
|
0
|
untie *STDOUT; |
129
|
0
|
|
|
|
|
0
|
return $output; |
130
|
0
|
|
|
|
|
0
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
my $tmpfile = "/tmp/test-blocks-$$"; |
133
|
0
|
|
|
0
|
0
|
0
|
$self->_write_to($tmpfile, @_); |
134
|
0
|
|
|
|
|
0
|
open my $execution, "$^X $tmpfile 2>&1 |" |
135
|
0
|
|
|
|
|
0
|
or die "Couldn't open subprocess: $!\n"; |
136
|
0
|
|
|
|
|
0
|
local $/; |
137
|
0
|
|
|
|
|
0
|
my $output = <$execution>; |
138
|
2
|
|
|
2
|
|
135
|
close $execution; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
162
|
|
139
|
0
|
|
|
|
|
0
|
unlink($tmpfile) |
140
|
0
|
|
|
|
|
0
|
or die "Couldn't unlink $tmpfile: $!\n"; |
141
|
|
|
|
|
|
|
return $output; |
142
|
|
|
|
|
|
|
} |
143
|
0
|
|
|
0
|
0
|
0
|
|
144
|
0
|
|
|
|
|
0
|
$self->assert_scalar(@_); |
145
|
0
|
|
|
|
|
0
|
my $ref = shift; |
146
|
0
|
|
|
|
|
0
|
if (ref($ref) eq 'HASH') { |
147
|
0
|
|
|
|
|
0
|
return map { |
148
|
2
|
|
|
2
|
|
12
|
($_, $ref->{$_}); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2891
|
|
149
|
0
|
|
|
|
|
0
|
} sort keys %$ref; |
150
|
0
|
|
|
|
|
0
|
} |
151
|
|
|
|
|
|
|
if (ref($ref) eq 'ARRAY') { |
152
|
|
|
|
|
|
|
return @$ref; |
153
|
0
|
|
|
0
|
0
|
0
|
} |
154
|
0
|
|
|
|
|
0
|
die "Can only flatten a hash or array ref"; |
155
|
0
|
|
|
|
|
0
|
} |
156
|
0
|
0
|
|
|
|
0
|
|
157
|
|
|
|
|
|
|
$self->assert_scalar(@_); |
158
|
0
|
|
|
|
|
0
|
my $url = shift; |
159
|
0
|
|
|
|
|
0
|
CORE::chomp($url); |
160
|
0
|
|
|
|
|
0
|
require LWP::Simple; |
161
|
0
|
0
|
|
|
|
0
|
LWP::Simple::get($url); |
162
|
|
|
|
|
|
|
} |
163
|
0
|
|
|
|
|
0
|
|
164
|
|
|
|
|
|
|
return +{ @_ }; |
165
|
|
|
|
|
|
|
} |
166
|
0
|
|
|
0
|
0
|
0
|
|
167
|
0
|
|
|
|
|
0
|
my $size = $self->current_arguments || 1; |
168
|
0
|
|
|
|
|
0
|
return splice(@_, 0, $size); |
169
|
0
|
0
|
|
|
|
0
|
} |
170
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
0
|
my $string = $self->current_arguments; |
|
0
|
|
|
|
|
0
|
|
172
|
|
|
|
|
|
|
$string = '' unless defined $string; |
173
|
|
|
|
|
|
|
CORE::join $string, @_; |
174
|
0
|
0
|
|
|
|
0
|
} |
175
|
0
|
|
|
|
|
0
|
|
176
|
|
|
|
|
|
|
$self->assert_scalar(@_); |
177
|
0
|
|
|
|
|
0
|
my $text = shift; |
178
|
|
|
|
|
|
|
return () unless length $text; |
179
|
|
|
|
|
|
|
my @lines = ($text =~ /^(.*\n?)/gm); |
180
|
0
|
|
|
0
|
0
|
0
|
return @lines; |
181
|
0
|
|
|
|
|
0
|
} |
182
|
0
|
|
|
|
|
0
|
|
183
|
0
|
|
|
|
|
0
|
$self->assert_scalar(@_); |
184
|
0
|
|
|
|
|
0
|
my $text = shift; |
185
|
0
|
|
|
|
|
0
|
$text = '' unless defined $text; |
186
|
|
|
|
|
|
|
$text =~ s/\015\012/\n/g; |
187
|
|
|
|
|
|
|
$text =~ s/\r/\n/g; |
188
|
0
|
|
|
0
|
0
|
0
|
return $text; |
189
|
0
|
|
|
|
|
0
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
my $prefix = $self->current_arguments; |
192
|
0
|
|
|
0
|
0
|
0
|
map { $prefix . $_ } @_; |
193
|
0
|
|
0
|
|
|
0
|
} |
194
|
0
|
|
|
|
|
0
|
|
195
|
|
|
|
|
|
|
$self->assert_scalar(@_); |
196
|
|
|
|
|
|
|
my $file = shift; |
197
|
0
|
|
|
0
|
0
|
0
|
CORE::chomp $file; |
198
|
0
|
|
|
|
|
0
|
open my $fh, $file |
199
|
0
|
0
|
|
|
|
0
|
or die "Can't open '$file' for input:\n$!"; |
200
|
0
|
|
|
|
|
0
|
CORE::join '', <$fh>; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
0
|
|
|
0
|
0
|
0
|
$self->assert_scalar(@_); |
204
|
0
|
|
|
|
|
0
|
my $text = shift; |
205
|
0
|
|
|
|
|
0
|
my $flags = $self->current_arguments; |
206
|
0
|
0
|
|
|
|
0
|
if ($text =~ /\n.*?\n/s) { |
207
|
0
|
|
|
|
|
0
|
$flags = 'xism' |
208
|
0
|
|
|
|
|
0
|
unless defined $flags; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
else { |
211
|
11
|
|
|
11
|
0
|
16
|
CORE::chomp($text); |
212
|
11
|
|
|
|
|
25
|
} |
213
|
11
|
|
|
|
|
12
|
$flags ||= ''; |
214
|
11
|
50
|
|
|
|
27
|
my $regexp = eval "qr{$text}$flags"; |
215
|
11
|
|
|
|
|
15
|
die $@ if $@; |
216
|
11
|
|
|
|
|
17
|
return $regexp; |
217
|
11
|
|
|
|
|
44
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
CORE::reverse(@_); |
220
|
0
|
|
|
0
|
0
|
0
|
} |
221
|
0
|
|
|
|
|
0
|
|
222
|
0
|
|
|
|
|
0
|
die "Invalid args for slice" |
|
0
|
|
|
|
|
0
|
|
223
|
|
|
|
|
|
|
unless $self->current_arguments =~ /^(\d+)(?:,(\d))?$/; |
224
|
|
|
|
|
|
|
my ($x, $y) = ($1, $2); |
225
|
0
|
|
|
0
|
0
|
0
|
$y = $x if not defined $y; |
226
|
0
|
|
|
|
|
0
|
die "Invalid args for slice" |
227
|
0
|
|
|
|
|
0
|
if $x > $y; |
228
|
0
|
|
|
|
|
0
|
return splice(@_, $x, 1 + $y - $x); |
229
|
0
|
0
|
|
|
|
0
|
} |
230
|
|
|
|
|
|
|
|
231
|
0
|
|
|
|
|
0
|
CORE::sort(@_); |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
0
|
|
|
0
|
0
|
0
|
$self->assert_scalar(@_); |
235
|
0
|
|
|
|
|
0
|
my $separator = $self->current_arguments; |
236
|
0
|
|
|
|
|
0
|
if (defined $separator and $separator =~ s{^/(.*)/$}{$1}) { |
237
|
0
|
|
|
|
|
0
|
my $regexp = $1; |
238
|
0
|
0
|
|
|
|
0
|
$separator = qr{$regexp}; |
239
|
0
|
0
|
|
|
|
0
|
} |
240
|
|
|
|
|
|
|
$separator = qr/\s+/ unless $separator; |
241
|
|
|
|
|
|
|
CORE::split $separator, shift; |
242
|
|
|
|
|
|
|
} |
243
|
0
|
|
|
|
|
0
|
|
244
|
|
|
|
|
|
|
$self->assert_scalar(@_); |
245
|
0
|
|
0
|
|
|
0
|
<<'...' . shift; |
246
|
0
|
|
|
|
|
0
|
use strict; |
247
|
0
|
0
|
|
|
|
0
|
use warnings; |
248
|
0
|
|
|
|
|
0
|
... |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
0
|
|
|
0
|
0
|
0
|
my $size = $self->current_arguments || 1; |
252
|
0
|
|
|
|
|
0
|
return splice(@_, @_ - $size, $size); |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
0
|
|
|
0
|
0
|
0
|
map { |
256
|
0
|
0
|
|
|
|
0
|
s/\A([ \t]*\n)+//; |
257
|
|
|
|
|
|
|
s/(?<=\n)\s*\z//g; |
258
|
0
|
|
|
|
|
0
|
$_; |
259
|
0
|
0
|
|
|
|
0
|
} @_; |
260
|
0
|
0
|
|
|
|
0
|
} |
261
|
|
|
|
|
|
|
|
262
|
0
|
|
|
|
|
0
|
map { $_ . "\n" } @_; |
263
|
|
|
|
|
|
|
} |
264
|
|
|
|
|
|
|
|
265
|
0
|
|
|
0
|
0
|
0
|
my $file = $self->current_arguments |
266
|
0
|
|
|
|
|
0
|
or die "No file specified for write_file filter"; |
267
|
|
|
|
|
|
|
if ($file =~ /(.*)[\\\/]/) { |
268
|
|
|
|
|
|
|
my $dir = $1; |
269
|
0
|
|
|
0
|
0
|
0
|
if (not -e $dir) { |
270
|
0
|
|
|
|
|
0
|
require File::Path; |
271
|
0
|
|
|
|
|
0
|
File::Path::mkpath($dir) |
272
|
0
|
0
|
0
|
|
|
0
|
or die "Can't create $dir"; |
273
|
0
|
|
|
|
|
0
|
} |
274
|
0
|
|
|
|
|
0
|
} |
275
|
|
|
|
|
|
|
open my $fh, ">$file" |
276
|
0
|
0
|
|
|
|
0
|
or die "Can't open '$file' for output\n:$!"; |
277
|
0
|
|
|
|
|
0
|
print $fh @_; |
278
|
|
|
|
|
|
|
close $fh; |
279
|
|
|
|
|
|
|
return $file; |
280
|
0
|
|
|
0
|
0
|
0
|
} |
281
|
0
|
|
|
|
|
0
|
|
282
|
0
|
|
|
|
|
0
|
$self->assert_scalar(@_); |
283
|
|
|
|
|
|
|
require YAML; |
284
|
|
|
|
|
|
|
return YAML::Load(shift); |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
my $filename = shift; |
288
|
0
|
|
|
0
|
0
|
0
|
open my $script, ">$filename" |
289
|
0
|
|
0
|
|
|
0
|
or die "Couldn't open $filename: $!\n"; |
290
|
0
|
|
|
|
|
0
|
print $script @_; |
291
|
|
|
|
|
|
|
close $script |
292
|
|
|
|
|
|
|
or die "Couldn't close $filename: $!\n"; |
293
|
11
|
|
|
11
|
0
|
20
|
} |
294
|
|
|
|
|
|
|
|
295
|
11
|
|
|
|
|
15
|
1; |
|
11
|
|
|
|
|
30
|
|