line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
|
|
|
|
|
|
package Test::Builder; |
3
|
8
|
|
|
8
|
|
223
|
|
|
8
|
|
|
|
|
29
|
|
|
8
|
|
|
|
|
429
|
|
4
|
8
|
|
|
8
|
|
44
|
use 5.006; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
267
|
|
5
|
8
|
|
|
8
|
|
40
|
use strict; |
|
8
|
|
|
|
|
103
|
|
|
8
|
|
|
|
|
637
|
|
6
|
|
|
|
|
|
|
use warnings; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.98'; |
9
|
|
|
|
|
|
|
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) |
10
|
|
|
|
|
|
|
|
11
|
8
|
50
|
|
8
|
|
324
|
BEGIN { |
12
|
0
|
|
|
|
|
0
|
if( $] < 5.008 ) { |
13
|
|
|
|
|
|
|
require Test::Builder::IO::Scalar; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Make Test::Builder thread-safe for ithreads. |
19
|
8
|
|
|
8
|
|
44
|
BEGIN { |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
2958
|
|
20
|
|
|
|
|
|
|
use Config; |
21
|
|
|
|
|
|
|
# Load threads::shared when threads are turned on. |
22
|
8
|
50
|
33
|
8
|
|
257
|
# 5.8.0's threads are so busted we no longer support them. |
|
|
|
33
|
|
|
|
|
23
|
0
|
|
|
|
|
0
|
if( $] >= 5.008001 && $Config{useithreads} && $INC{'threads.pm'} ) { |
24
|
|
|
|
|
|
|
require threads::shared; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Hack around YET ANOTHER threads::shared bug. It would |
27
|
|
|
|
|
|
|
# occasionally forget the contents of the variable when sharing it. |
28
|
|
|
|
|
|
|
# So we first copy the data, then share, then put our copy back. |
29
|
0
|
|
|
|
|
0
|
*share = sub (\[$@%]) { |
30
|
0
|
|
|
|
|
0
|
my $type = ref $_[0]; |
31
|
|
|
|
|
|
|
my $data; |
32
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
if( $type eq 'HASH' ) { |
|
0
|
|
|
|
|
0
|
|
34
|
|
|
|
|
|
|
%$data = %{ $_[0] }; |
35
|
|
|
|
|
|
|
} |
36
|
0
|
|
|
|
|
0
|
elsif( $type eq 'ARRAY' ) { |
|
0
|
|
|
|
|
0
|
|
37
|
|
|
|
|
|
|
@$data = @{ $_[0] }; |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
0
|
elsif( $type eq 'SCALAR' ) { |
|
0
|
|
|
|
|
0
|
|
40
|
|
|
|
|
|
|
$$data = ${ $_[0] }; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
0
|
else { |
43
|
|
|
|
|
|
|
die( "Unknown type: " . $type ); |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
|
|
|
0
|
|
46
|
|
|
|
|
|
|
$_[0] = &threads::shared::share( $_[0] ); |
47
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
if( $type eq 'HASH' ) { |
|
0
|
|
|
|
|
0
|
|
49
|
|
|
|
|
|
|
%{ $_[0] } = %$data; |
50
|
|
|
|
|
|
|
} |
51
|
0
|
|
|
|
|
0
|
elsif( $type eq 'ARRAY' ) { |
|
0
|
|
|
|
|
0
|
|
52
|
|
|
|
|
|
|
@{ $_[0] } = @$data; |
53
|
|
|
|
|
|
|
} |
54
|
0
|
|
|
|
|
0
|
elsif( $type eq 'SCALAR' ) { |
|
0
|
|
|
|
|
0
|
|
55
|
|
|
|
|
|
|
${ $_[0] } = $$data; |
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
0
|
else { |
58
|
|
|
|
|
|
|
die( "Unknown type: " . $type ); |
59
|
|
|
|
|
|
|
} |
60
|
0
|
|
|
|
|
0
|
|
61
|
0
|
|
|
|
|
0
|
return $_[0]; |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
# 5.8.0's threads::shared is busted when threads are off |
65
|
|
|
|
|
|
|
# and earlier Perls just don't have that module at all. |
66
|
8
|
|
|
110
|
|
40
|
else { |
|
110
|
|
|
|
|
255
|
|
67
|
8
|
|
|
80
|
|
27337
|
*share = sub { return $_[0] }; |
|
80
|
|
|
|
|
107
|
|
68
|
|
|
|
|
|
|
*lock = sub { 0 }; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#line 117 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
our $Test = Test::Builder->new; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub new { |
77
|
|
|
|
|
|
|
my($class) = shift; |
78
|
|
|
|
|
|
|
$Test ||= $class->create; |
79
|
|
|
|
|
|
|
return $Test; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
#line 139 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub create { |
85
|
|
|
|
|
|
|
my $class = shift; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $self = bless {}, $class; |
88
|
|
|
|
|
|
|
$self->reset; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
return $self; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
#line 168 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub child { |
96
|
|
|
|
|
|
|
my( $self, $name ) = @_; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
if( $self->{Child_Name} ) { |
99
|
|
|
|
|
|
|
$self->croak("You already have a child named ($self->{Child_Name}) running"); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $parent_in_todo = $self->in_todo; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Clear $TODO for the child. |
105
|
|
|
|
|
|
|
my $orig_TODO = $self->find_TODO(undef, 1, undef); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my $child = bless {}, ref $self; |
108
|
|
|
|
|
|
|
$child->reset; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Add to our indentation |
111
|
|
|
|
|
|
|
$child->_indent( $self->_indent . ' ' ); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
$child->{$_} = $self->{$_} foreach qw{Out_FH Todo_FH Fail_FH}; |
114
|
|
|
|
|
|
|
if ($parent_in_todo) { |
115
|
|
|
|
|
|
|
$child->{Fail_FH} = $self->{Todo_FH}; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# This will be reset in finalize. We do this here lest one child failure |
119
|
|
|
|
|
|
|
# cause all children to fail. |
120
|
|
|
|
|
|
|
$child->{Child_Error} = $?; |
121
|
96
|
|
|
96
|
1
|
48000
|
$? = 0; |
122
|
96
|
|
66
|
|
|
409
|
$child->{Parent} = $self; |
123
|
96
|
|
|
|
|
294
|
$child->{Parent_TODO} = $orig_TODO; |
124
|
|
|
|
|
|
|
$child->{Name} = $name || "Child of " . $self->name; |
125
|
|
|
|
|
|
|
$self->{Child_Name} = $child->name; |
126
|
|
|
|
|
|
|
return $child; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
#line 211 |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub subtest { |
133
|
|
|
|
|
|
|
my $self = shift; |
134
|
|
|
|
|
|
|
my($name, $subtests) = @_; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
if ('CODE' ne ref $subtests) { |
137
|
|
|
|
|
|
|
$self->croak("subtest()'s second argument must be a code ref"); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# Turn the child into the parent so anyone who has stored a copy of |
141
|
8
|
|
|
8
|
1
|
20
|
# the Test::Builder singleton will get the child. |
142
|
|
|
|
|
|
|
my($error, $child, %parent); |
143
|
8
|
|
|
|
|
32
|
{ |
144
|
8
|
|
|
|
|
35
|
# child() calls reset() which sets $Level to 1, so we localize |
145
|
|
|
|
|
|
|
# $Level first to limit the scope of the reset to the subtest. |
146
|
8
|
|
|
|
|
52
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
$child = $self->child($name); |
149
|
|
|
|
|
|
|
%parent = %$self; |
150
|
|
|
|
|
|
|
%$self = %$child; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $run_the_subtests = sub { |
153
|
|
|
|
|
|
|
$subtests->(); |
154
|
|
|
|
|
|
|
$self->done_testing unless $self->_plan_handled; |
155
|
|
|
|
|
|
|
1; |
156
|
|
|
|
|
|
|
}; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
if( !eval { $run_the_subtests->() } ) { |
159
|
|
|
|
|
|
|
$error = $@; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# Restore the parent and the copied child. |
164
|
|
|
|
|
|
|
%$child = %$self; |
165
|
|
|
|
|
|
|
%$self = %parent; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# Restore the parent's $TODO |
168
|
|
|
|
|
|
|
$self->find_TODO(undef, 1, $child->{Parent_TODO}); |
169
|
|
|
|
|
|
|
|
170
|
4
|
|
|
4
|
1
|
7
|
# Die *after* we restore the parent. |
171
|
|
|
|
|
|
|
die $error if $error and !eval { $error->isa('Test::Builder::Exception') }; |
172
|
4
|
50
|
|
|
|
18
|
|
173
|
0
|
|
|
|
|
0
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
174
|
|
|
|
|
|
|
return $child->finalize; |
175
|
|
|
|
|
|
|
} |
176
|
4
|
|
|
|
|
13
|
|
177
|
|
|
|
|
|
|
#line 281 |
178
|
|
|
|
|
|
|
|
179
|
4
|
|
|
|
|
18
|
sub _plan_handled { |
180
|
|
|
|
|
|
|
my $self = shift; |
181
|
4
|
|
|
|
|
16
|
return $self->{Have_Plan} || $self->{No_Plan} || $self->{Skip_All}; |
182
|
4
|
|
|
|
|
18
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
4
|
|
|
|
|
13
|
#line 306 |
186
|
|
|
|
|
|
|
|
187
|
4
|
|
|
|
|
24
|
sub finalize { |
188
|
4
|
50
|
|
|
|
12
|
my $self = shift; |
189
|
0
|
|
|
|
|
0
|
|
190
|
|
|
|
|
|
|
return unless $self->parent; |
191
|
|
|
|
|
|
|
if( $self->{Child_Name} ) { |
192
|
|
|
|
|
|
|
$self->croak("Can't call finalize() with child ($self->{Child_Name}) active"); |
193
|
|
|
|
|
|
|
} |
194
|
4
|
|
|
|
|
13
|
|
195
|
4
|
|
|
|
|
7
|
local $? = 0; # don't fail if $subtests happened to set $? nonzero |
196
|
4
|
|
|
|
|
10
|
$self->_ending; |
197
|
4
|
|
|
|
|
8
|
|
198
|
4
|
|
33
|
|
|
17
|
# XXX This will only be necessary for TAP envelopes (we think) |
199
|
4
|
|
|
|
|
14
|
#$self->_print( $self->is_passing ? "PASS\n" : "FAIL\n" ); |
200
|
4
|
|
|
|
|
11
|
|
201
|
|
|
|
|
|
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
202
|
|
|
|
|
|
|
my $ok = 1; |
203
|
|
|
|
|
|
|
$self->parent->{Child_Name} = undef; |
204
|
|
|
|
|
|
|
if ( $self->{Skip_All} ) { |
205
|
|
|
|
|
|
|
$self->parent->skip($self->{Skip_All}); |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
elsif ( not @{ $self->{Test_Results} } ) { |
208
|
|
|
|
|
|
|
$self->parent->ok( 0, sprintf q[No tests run for subtest "%s"], $self->name ); |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
else { |
211
|
|
|
|
|
|
|
$self->parent->ok( $self->is_passing, $self->name ); |
212
|
|
|
|
|
|
|
} |
213
|
4
|
|
|
4
|
1
|
9
|
$? = $self->{Child_Error}; |
214
|
4
|
|
|
|
|
9
|
delete $self->{Parent}; |
215
|
|
|
|
|
|
|
|
216
|
4
|
50
|
|
|
|
21
|
return $self->is_passing; |
217
|
0
|
|
|
|
|
0
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub _indent { |
220
|
|
|
|
|
|
|
my $self = shift; |
221
|
|
|
|
|
|
|
|
222
|
4
|
|
|
|
|
7
|
if( @_ ) { |
223
|
|
|
|
|
|
|
$self->{Indent} = shift; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
4
|
|
|
|
|
6
|
return $self->{Indent}; |
|
4
|
|
|
|
|
10
|
|
227
|
|
|
|
|
|
|
} |
228
|
4
|
|
|
|
|
16
|
|
229
|
4
|
|
|
|
|
52
|
#line 359 |
230
|
4
|
|
|
|
|
82
|
|
231
|
|
|
|
|
|
|
sub parent { shift->{Parent} } |
232
|
|
|
|
|
|
|
|
233
|
4
|
|
|
4
|
|
12
|
#line 371 |
234
|
4
|
100
|
|
|
|
34
|
|
235
|
4
|
|
|
|
|
35
|
sub name { shift->{Name} } |
236
|
4
|
|
|
|
|
33
|
|
237
|
|
|
|
|
|
|
sub DESTROY { |
238
|
4
|
50
|
|
|
|
8
|
my $self = shift; |
|
4
|
|
|
|
|
9
|
|
239
|
0
|
|
|
|
|
0
|
if ( $self->parent and $$ == $self->{Original_Pid} ) { |
240
|
|
|
|
|
|
|
my $name = $self->name; |
241
|
|
|
|
|
|
|
$self->diag(<<"FAIL"); |
242
|
|
|
|
|
|
|
Child ($name) exited without calling finalize() |
243
|
|
|
|
|
|
|
FAIL |
244
|
4
|
|
|
|
|
138
|
$self->parent->{In_Destroy} = 1; |
245
|
4
|
|
|
|
|
95
|
$self->parent->ok(0, $name); |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
} |
248
|
4
|
|
|
|
|
34
|
|
249
|
|
|
|
|
|
|
#line 395 |
250
|
|
|
|
|
|
|
|
251
|
4
|
50
|
33
|
|
|
20
|
our $Level; |
|
0
|
|
|
|
|
0
|
|
252
|
|
|
|
|
|
|
|
253
|
4
|
|
|
|
|
9
|
sub reset { ## no critic (Subroutines::ProhibitBuiltinHomonyms) |
254
|
4
|
|
|
|
|
17
|
my($self) = @_; |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
# We leave this a global because it has to be localized and localizing |
257
|
|
|
|
|
|
|
# hash keys is just asking for pain. Also, it was documented. |
258
|
|
|
|
|
|
|
$Level = 1; |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
$self->{Name} = $0; |
261
|
|
|
|
|
|
|
$self->is_passing(1); |
262
|
|
|
|
|
|
|
$self->{Ending} = 0; |
263
|
|
|
|
|
|
|
$self->{Have_Plan} = 0; |
264
|
|
|
|
|
|
|
$self->{No_Plan} = 0; |
265
|
|
|
|
|
|
|
$self->{Have_Output_Plan} = 0; |
266
|
|
|
|
|
|
|
$self->{Done_Testing} = 0; |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
$self->{Original_Pid} = $$; |
269
|
|
|
|
|
|
|
$self->{Child_Name} = undef; |
270
|
|
|
|
|
|
|
$self->{Indent} ||= ''; |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
share( $self->{Curr_Test} ); |
273
|
|
|
|
|
|
|
$self->{Curr_Test} = 0; |
274
|
|
|
|
|
|
|
$self->{Test_Results} = &share( [] ); |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
$self->{Exported_To} = undef; |
277
|
|
|
|
|
|
|
$self->{Expected_Tests} = 0; |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
$self->{Skip_All} = 0; |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
$self->{Use_Nums} = 1; |
282
|
|
|
|
|
|
|
|
283
|
4
|
|
|
4
|
|
7
|
$self->{No_Header} = 0; |
284
|
4
|
|
66
|
|
|
35
|
$self->{No_Ending} = 0; |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
$self->{Todo} = undef; |
287
|
|
|
|
|
|
|
$self->{Todo_Stack} = []; |
288
|
|
|
|
|
|
|
$self->{Start_Todo} = 0; |
289
|
|
|
|
|
|
|
$self->{Opened_Testhandles} = 0; |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
$self->_dup_stdhandles; |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
return; |
294
|
|
|
|
|
|
|
} |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
#line 474 |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
my %plan_cmds = ( |
299
|
|
|
|
|
|
|
no_plan => \&no_plan, |
300
|
|
|
|
|
|
|
skip_all => \&skip_all, |
301
|
|
|
|
|
|
|
tests => \&_plan_tests, |
302
|
|
|
|
|
|
|
); |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
sub plan { |
305
|
|
|
|
|
|
|
my( $self, $cmd, $arg ) = @_; |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
return unless $cmd; |
308
|
4
|
|
|
4
|
1
|
7
|
|
309
|
|
|
|
|
|
|
local $Level = $Level + 1; |
310
|
4
|
50
|
|
|
|
13
|
|
311
|
4
|
50
|
|
|
|
16
|
$self->croak("You tried to plan twice") if $self->{Have_Plan}; |
312
|
0
|
|
|
|
|
0
|
|
313
|
|
|
|
|
|
|
if( my $method = $plan_cmds{$cmd} ) { |
314
|
|
|
|
|
|
|
local $Level = $Level + 1; |
315
|
4
|
|
|
|
|
18
|
$self->$method($arg); |
316
|
4
|
|
|
|
|
16
|
} |
317
|
|
|
|
|
|
|
else { |
318
|
|
|
|
|
|
|
my @args = grep { defined } ( $cmd, $arg ); |
319
|
|
|
|
|
|
|
$self->croak("plan() doesn't understand @args"); |
320
|
|
|
|
|
|
|
} |
321
|
4
|
|
|
|
|
8
|
|
322
|
4
|
|
|
|
|
6
|
return 1; |
323
|
4
|
|
|
|
|
18
|
} |
324
|
4
|
50
|
|
|
|
15
|
|
|
4
|
50
|
|
|
|
16
|
|
325
|
0
|
|
|
|
|
0
|
|
326
|
|
|
|
|
|
|
sub _plan_tests { |
327
|
|
|
|
|
|
|
my($self, $arg) = @_; |
328
|
0
|
|
|
|
|
0
|
|
329
|
|
|
|
|
|
|
if($arg) { |
330
|
|
|
|
|
|
|
local $Level = $Level + 1; |
331
|
4
|
|
|
|
|
11
|
return $self->expected_tests($arg); |
332
|
|
|
|
|
|
|
} |
333
|
4
|
|
|
|
|
11
|
elsif( !defined $arg ) { |
334
|
4
|
|
|
|
|
10
|
$self->croak("Got an undefined number of tests"); |
335
|
|
|
|
|
|
|
} |
336
|
4
|
|
|
|
|
18
|
else { |
337
|
|
|
|
|
|
|
$self->croak("You said to run 0 tests"); |
338
|
|
|
|
|
|
|
} |
339
|
|
|
|
|
|
|
|
340
|
147
|
|
|
147
|
|
215
|
return; |
341
|
|
|
|
|
|
|
} |
342
|
147
|
100
|
|
|
|
6355
|
|
343
|
4
|
|
|
|
|
8
|
#line 529 |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
sub expected_tests { |
346
|
147
|
|
|
|
|
381
|
my $self = shift; |
347
|
|
|
|
|
|
|
my($max) = @_; |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
if(@_) { |
350
|
|
|
|
|
|
|
$self->croak("Number of tests must be a positive integer. You gave it '$max'") |
351
|
|
|
|
|
|
|
unless $max =~ /^\+?\d+$/; |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
$self->{Expected_Tests} = $max; |
354
|
|
|
|
|
|
|
$self->{Have_Plan} = 1; |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
$self->_output_plan($max) unless $self->no_header; |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
return $self->{Expected_Tests}; |
359
|
|
|
|
|
|
|
} |
360
|
16
|
|
|
16
|
1
|
109
|
|
361
|
|
|
|
|
|
|
#line 553 |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
sub no_plan { |
364
|
|
|
|
|
|
|
my($self, $arg) = @_; |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
$self->carp("no_plan takes no arguments") if $arg; |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
$self->{No_Plan} = 1; |
369
|
|
|
|
|
|
|
$self->{Have_Plan} = 1; |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
return 1; |
372
|
8
|
|
|
8
|
1
|
26
|
} |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
#line 586 |
375
|
4
|
|
|
4
|
|
10
|
|
376
|
4
|
50
|
33
|
|
|
10
|
sub _output_plan { |
377
|
0
|
|
|
|
|
0
|
my($self, $max, $directive, $reason) = @_; |
378
|
0
|
|
|
|
|
0
|
|
379
|
|
|
|
|
|
|
$self->carp("The plan was already output") if $self->{Have_Output_Plan}; |
380
|
|
|
|
|
|
|
|
381
|
0
|
|
|
|
|
0
|
my $plan = "1..$max"; |
382
|
0
|
|
|
|
|
0
|
$plan .= " # $directive" if defined $directive; |
383
|
|
|
|
|
|
|
$plan .= " $reason" if defined $reason; |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
$self->_print("$plan\n"); |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
$self->{Have_Output_Plan} = 1; |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
return; |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
#line 638 |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
sub done_testing { |
396
|
|
|
|
|
|
|
my($self, $num_tests) = @_; |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
# If done_testing() specified the number of tests, shut off no_plan. |
399
|
12
|
|
|
12
|
1
|
27
|
if( defined $num_tests ) { |
400
|
|
|
|
|
|
|
$self->{No_Plan} = 0; |
401
|
|
|
|
|
|
|
} |
402
|
|
|
|
|
|
|
else { |
403
|
12
|
|
|
|
|
26
|
$num_tests = $self->current_test; |
404
|
|
|
|
|
|
|
} |
405
|
12
|
|
|
|
|
107
|
|
406
|
12
|
|
|
|
|
46
|
if( $self->{Done_Testing} ) { |
407
|
12
|
|
|
|
|
26
|
my($file, $line) = @{$self->{Done_Testing}}[1,2]; |
408
|
12
|
|
|
|
|
29
|
$self->ok(0, "done_testing() was already called at $file line $line"); |
409
|
12
|
|
|
|
|
27
|
return; |
410
|
12
|
|
|
|
|
49
|
} |
411
|
12
|
|
|
|
|
25
|
|
412
|
|
|
|
|
|
|
$self->{Done_Testing} = [caller]; |
413
|
12
|
|
|
|
|
128
|
|
414
|
12
|
|
|
|
|
31
|
if( $self->expected_tests && $num_tests != $self->expected_tests ) { |
415
|
12
|
|
50
|
|
|
86
|
$self->ok(0, "planned to run @{[ $self->expected_tests ]} ". |
416
|
|
|
|
|
|
|
"but done_testing() expects $num_tests"); |
417
|
12
|
|
|
|
|
61
|
} |
418
|
12
|
|
|
|
|
37
|
else { |
419
|
12
|
|
|
|
|
38
|
$self->{Expected_Tests} = $num_tests; |
420
|
|
|
|
|
|
|
} |
421
|
12
|
|
|
|
|
34
|
|
422
|
12
|
|
|
|
|
24
|
$self->_output_plan($num_tests) unless $self->{Have_Output_Plan}; |
423
|
|
|
|
|
|
|
|
424
|
12
|
|
|
|
|
26
|
$self->{Have_Plan} = 1; |
425
|
|
|
|
|
|
|
|
426
|
12
|
|
|
|
|
37
|
# The wrong number of tests were run |
427
|
|
|
|
|
|
|
$self->is_passing(0) if $self->{Expected_Tests} != $self->{Curr_Test}; |
428
|
12
|
|
|
|
|
28
|
|
429
|
12
|
|
|
|
|
29
|
# No tests were run |
430
|
|
|
|
|
|
|
$self->is_passing(0) if $self->{Curr_Test} == 0; |
431
|
12
|
|
|
|
|
26
|
|
432
|
12
|
|
|
|
|
29
|
return 1; |
433
|
12
|
|
|
|
|
26
|
} |
434
|
12
|
|
|
|
|
26
|
|
435
|
|
|
|
|
|
|
|
436
|
12
|
|
|
|
|
45
|
#line 689 |
437
|
|
|
|
|
|
|
|
438
|
12
|
|
|
|
|
17
|
sub has_plan { |
439
|
|
|
|
|
|
|
my $self = shift; |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
return( $self->{Expected_Tests} ) if $self->{Expected_Tests}; |
442
|
|
|
|
|
|
|
return('no_plan') if $self->{No_Plan}; |
443
|
|
|
|
|
|
|
return(undef); |
444
|
|
|
|
|
|
|
} |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
#line 706 |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
sub skip_all { |
449
|
|
|
|
|
|
|
my( $self, $reason ) = @_; |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
$self->{Skip_All} = $self->parent ? $reason : 1; |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
$self->_output_plan(0, "SKIP", $reason) unless $self->no_header; |
454
|
|
|
|
|
|
|
if ( $self->parent ) { |
455
|
|
|
|
|
|
|
die bless {} => 'Test::Builder::Exception'; |
456
|
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
exit(0); |
458
|
|
|
|
|
|
|
} |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
#line 731 |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
sub exported_to { |
463
|
|
|
|
|
|
|
my( $self, $pack ) = @_; |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
if( defined $pack ) { |
466
|
|
|
|
|
|
|
$self->{Exported_To} = $pack; |
467
|
|
|
|
|
|
|
} |
468
|
|
|
|
|
|
|
return $self->{Exported_To}; |
469
|
|
|
|
|
|
|
} |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
#line 761 |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
sub ok { |
474
|
|
|
|
|
|
|
my( $self, $test, $name ) = @_; |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
if ( $self->{Child_Name} and not $self->{In_Destroy} ) { |
477
|
|
|
|
|
|
|
$name = 'unnamed test' unless defined $name; |
478
|
|
|
|
|
|
|
$self->is_passing(0); |
479
|
|
|
|
|
|
|
$self->croak("Cannot run test ($name) with active children"); |
480
|
|
|
|
|
|
|
} |
481
|
|
|
|
|
|
|
# $test might contain an object which we don't want to accidentally |
482
|
10
|
|
|
10
|
1
|
4713
|
# store, so we turn it into a boolean. |
483
|
|
|
|
|
|
|
$test = $test ? 1 : 0; |
484
|
10
|
100
|
|
|
|
63
|
|
485
|
|
|
|
|
|
|
lock $self->{Curr_Test}; |
486
|
4
|
|
|
|
|
12
|
$self->{Curr_Test}++; |
487
|
|
|
|
|
|
|
|
488
|
4
|
50
|
|
|
|
22
|
# In case $name is a string overloaded object, force it to stringify. |
489
|
|
|
|
|
|
|
$self->_unoverload_str( \$name ); |
490
|
4
|
50
|
|
|
|
24
|
|
491
|
4
|
|
|
|
|
12
|
$self->diag(<<"ERR") if defined $name and $name =~ /^[\d\s]+$/; |
492
|
4
|
|
|
|
|
23
|
You named your test '$name'. You shouldn't use numbers for your test names. |
493
|
|
|
|
|
|
|
Very confusing. |
494
|
|
|
|
|
|
|
ERR |
495
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
496
|
0
|
|
|
|
|
0
|
# Capture the value of $TODO for the rest of this ok() call |
497
|
|
|
|
|
|
|
# so it can more easily be found by other routines. |
498
|
|
|
|
|
|
|
my $todo = $self->todo(); |
499
|
4
|
|
|
|
|
14
|
my $in_todo = $self->in_todo; |
500
|
|
|
|
|
|
|
local $self->{Todo} = $todo if $in_todo; |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
$self->_unoverload_str( \$todo ); |
503
|
|
|
|
|
|
|
|
504
|
6
|
|
|
6
|
|
14
|
my $out; |
505
|
|
|
|
|
|
|
my $result = &share( {} ); |
506
|
6
|
50
|
|
|
|
20
|
|
|
|
0
|
|
|
|
|
|
507
|
6
|
|
|
|
|
16
|
unless($test) { |
508
|
6
|
|
|
|
|
26
|
$out .= "not "; |
509
|
|
|
|
|
|
|
@$result{ 'ok', 'actual_ok' } = ( ( $self->in_todo ? 1 : 0 ), 0 ); |
510
|
|
|
|
|
|
|
} |
511
|
0
|
|
|
|
|
0
|
else { |
512
|
|
|
|
|
|
|
@$result{ 'ok', 'actual_ok' } = ( 1, $test ); |
513
|
|
|
|
|
|
|
} |
514
|
0
|
|
|
|
|
0
|
|
515
|
|
|
|
|
|
|
$out .= "ok"; |
516
|
|
|
|
|
|
|
$out .= " $self->{Curr_Test}" if $self->use_numbers; |
517
|
0
|
|
|
|
|
0
|
|
518
|
|
|
|
|
|
|
if( defined $name ) { |
519
|
|
|
|
|
|
|
$name =~ s|#|\\#|g; # # in a name can confuse Test::Harness. |
520
|
|
|
|
|
|
|
$out .= " - $name"; |
521
|
|
|
|
|
|
|
$result->{name} = $name; |
522
|
|
|
|
|
|
|
} |
523
|
|
|
|
|
|
|
else { |
524
|
|
|
|
|
|
|
$result->{name} = ''; |
525
|
|
|
|
|
|
|
} |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
if( $self->in_todo ) { |
528
|
|
|
|
|
|
|
$out .= " # TODO $todo"; |
529
|
|
|
|
|
|
|
$result->{reason} = $todo; |
530
|
|
|
|
|
|
|
$result->{type} = 'todo'; |
531
|
12
|
|
|
12
|
1
|
24
|
} |
532
|
12
|
|
|
|
|
23
|
else { |
533
|
|
|
|
|
|
|
$result->{reason} = ''; |
534
|
12
|
100
|
|
|
|
44
|
$result->{type} = ''; |
535
|
6
|
50
|
|
|
|
43
|
} |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
$self->{Test_Results}[ $self->{Curr_Test} - 1 ] = $result; |
538
|
6
|
|
|
|
|
20
|
$out .= "\n"; |
539
|
6
|
|
|
|
|
13
|
|
540
|
|
|
|
|
|
|
$self->_print($out); |
541
|
6
|
50
|
|
|
|
41
|
|
542
|
|
|
|
|
|
|
unless($test) { |
543
|
12
|
|
|
|
|
52
|
my $msg = $self->in_todo ? "Failed (TODO)" : "Failed"; |
544
|
|
|
|
|
|
|
$self->_print_to_fh( $self->_diag_fh, "\n" ) if $ENV{HARNESS_ACTIVE}; |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
my( undef, $file, $line ) = $self->caller; |
547
|
|
|
|
|
|
|
if( defined $name ) { |
548
|
|
|
|
|
|
|
$self->diag(qq[ $msg test '$name'\n]); |
549
|
|
|
|
|
|
|
$self->diag(qq[ at $file line $line.\n]); |
550
|
|
|
|
|
|
|
} |
551
|
|
|
|
|
|
|
else { |
552
|
|
|
|
|
|
|
$self->diag(qq[ $msg test at $file line $line.\n]); |
553
|
|
|
|
|
|
|
} |
554
|
|
|
|
|
|
|
} |
555
|
0
|
|
|
0
|
1
|
0
|
|
556
|
|
|
|
|
|
|
$self->is_passing(0) unless $test || $self->in_todo; |
557
|
0
|
0
|
|
|
|
0
|
|
558
|
|
|
|
|
|
|
# Check that we haven't violated the plan |
559
|
0
|
|
|
|
|
0
|
$self->_check_is_passing_plan(); |
560
|
0
|
|
|
|
|
0
|
|
561
|
|
|
|
|
|
|
return $test ? 1 : 0; |
562
|
0
|
|
|
|
|
0
|
} |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
# Check that we haven't yet violated the plan and set |
566
|
|
|
|
|
|
|
# is_passing() accordingly |
567
|
|
|
|
|
|
|
sub _check_is_passing_plan { |
568
|
|
|
|
|
|
|
my $self = shift; |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
my $plan = $self->has_plan; |
571
|
|
|
|
|
|
|
return unless defined $plan; # no plan yet defined |
572
|
|
|
|
|
|
|
return unless $plan !~ /\D/; # no numeric plan |
573
|
|
|
|
|
|
|
$self->is_passing(0) if $plan < $self->{Curr_Test}; |
574
|
|
|
|
|
|
|
} |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
sub _unoverload { |
578
|
|
|
|
|
|
|
my $self = shift; |
579
|
|
|
|
|
|
|
my $type = shift; |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
$self->_try(sub { require overload; }, die_on_fail => 1); |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
foreach my $thing (@_) { |
584
|
|
|
|
|
|
|
if( $self->_is_object($$thing) ) { |
585
|
|
|
|
|
|
|
if( my $string_meth = overload::Method( $$thing, $type ) ) { |
586
|
|
|
|
|
|
|
$$thing = $$thing->$string_meth(); |
587
|
|
|
|
|
|
|
} |
588
|
12
|
|
|
12
|
|
34
|
} |
589
|
|
|
|
|
|
|
} |
590
|
12
|
50
|
|
|
|
51
|
|
591
|
|
|
|
|
|
|
return; |
592
|
12
|
|
|
|
|
31
|
} |
593
|
12
|
50
|
|
|
|
47
|
|
594
|
12
|
50
|
|
|
|
49
|
sub _is_object { |
595
|
|
|
|
|
|
|
my( $self, $thing ) = @_; |
596
|
12
|
|
|
|
|
62
|
|
597
|
|
|
|
|
|
|
return $self->_try( sub { ref $thing && $thing->isa('UNIVERSAL') } ) ? 1 : 0; |
598
|
12
|
|
|
|
|
36
|
} |
599
|
|
|
|
|
|
|
|
600
|
12
|
|
|
|
|
30
|
sub _unoverload_str { |
601
|
|
|
|
|
|
|
my $self = shift; |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
return $self->_unoverload( q[""], @_ ); |
604
|
|
|
|
|
|
|
} |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
sub _unoverload_num { |
607
|
|
|
|
|
|
|
my $self = shift; |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
$self->_unoverload( '0+', @_ ); |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
for my $val (@_) { |
612
|
|
|
|
|
|
|
next unless $self->_is_dualvar($$val); |
613
|
|
|
|
|
|
|
$$val = $$val + 0; |
614
|
|
|
|
|
|
|
} |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
return; |
617
|
|
|
|
|
|
|
} |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
# This is a hack to detect a dualvar such as $! |
620
|
|
|
|
|
|
|
sub _is_dualvar { |
621
|
|
|
|
|
|
|
my( $self, $val ) = @_; |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
# Objects are not dualvars. |
624
|
|
|
|
|
|
|
return 0 if ref $val; |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
no warnings 'numeric'; |
627
|
|
|
|
|
|
|
my $numval = $val + 0; |
628
|
|
|
|
|
|
|
return $numval != 0 and $numval ne $val ? 1 : 0; |
629
|
|
|
|
|
|
|
} |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
#line 939 |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
sub is_eq { |
634
|
|
|
|
|
|
|
my( $self, $got, $expect, $name ) = @_; |
635
|
|
|
|
|
|
|
local $Level = $Level + 1; |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
if( !defined $got || !defined $expect ) { |
638
|
|
|
|
|
|
|
# undef only matches undef and nothing else |
639
|
|
|
|
|
|
|
my $test = !defined $got && !defined $expect; |
640
|
6
|
|
|
6
|
1
|
10
|
|
641
|
|
|
|
|
|
|
$self->ok( $test, $name ); |
642
|
|
|
|
|
|
|
$self->_is_diag( $got, 'eq', $expect ) unless $test; |
643
|
6
|
50
|
|
|
|
20
|
return $test; |
644
|
0
|
|
|
|
|
0
|
} |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
return $self->cmp_ok( $got, 'eq', $expect, $name ); |
647
|
6
|
|
|
|
|
22
|
} |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
sub is_num { |
650
|
6
|
50
|
|
|
|
25
|
my( $self, $got, $expect, $name ) = @_; |
651
|
0
|
|
|
|
|
0
|
local $Level = $Level + 1; |
|
0
|
|
|
|
|
0
|
|
652
|
0
|
|
|
|
|
0
|
|
653
|
0
|
|
|
|
|
0
|
if( !defined $got || !defined $expect ) { |
654
|
|
|
|
|
|
|
# undef only matches undef and nothing else |
655
|
|
|
|
|
|
|
my $test = !defined $got && !defined $expect; |
656
|
6
|
|
|
|
|
28
|
|
657
|
|
|
|
|
|
|
$self->ok( $test, $name ); |
658
|
6
|
50
|
33
|
|
|
25
|
$self->_is_diag( $got, '==', $expect ) unless $test; |
659
|
0
|
|
|
|
|
0
|
return $test; |
|
0
|
|
|
|
|
0
|
|
660
|
|
|
|
|
|
|
} |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
return $self->cmp_ok( $got, '==', $expect, $name ); |
663
|
6
|
|
|
|
|
16
|
} |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
sub _diag_fmt { |
666
|
6
|
50
|
|
|
|
33
|
my( $self, $type, $val ) = @_; |
667
|
|
|
|
|
|
|
|
668
|
6
|
|
|
|
|
16
|
if( defined $$val ) { |
669
|
|
|
|
|
|
|
if( $type eq 'eq' or $type eq 'ne' ) { |
670
|
|
|
|
|
|
|
# quote and force string context |
671
|
6
|
50
|
|
|
|
25
|
$$val = "'$$val'"; |
672
|
|
|
|
|
|
|
} |
673
|
|
|
|
|
|
|
else { |
674
|
6
|
50
|
|
|
|
18
|
# force numeric context |
675
|
|
|
|
|
|
|
$self->_unoverload_num($val); |
676
|
6
|
|
|
|
|
210
|
} |
677
|
|
|
|
|
|
|
} |
678
|
|
|
|
|
|
|
else { |
679
|
|
|
|
|
|
|
$$val = 'undef'; |
680
|
|
|
|
|
|
|
} |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
return; |
683
|
|
|
|
|
|
|
} |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
sub _is_diag { |
686
|
|
|
|
|
|
|
my( $self, $got, $type, $expect ) = @_; |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
$self->_diag_fmt( $type, $_ ) for \$got, \$expect; |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
local $Level = $Level + 1; |
691
|
74
|
|
|
74
|
1
|
96
|
return $self->diag(<<"DIAGNOSTIC"); |
692
|
|
|
|
|
|
|
got: $got |
693
|
74
|
100
|
|
|
|
266
|
expected: $expect |
694
|
32
|
50
|
|
|
|
82
|
DIAGNOSTIC |
695
|
32
|
|
|
|
|
143
|
|
696
|
|
|
|
|
|
|
} |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
sub _isnt_diag { |
699
|
|
|
|
|
|
|
my( $self, $got, $type ) = @_; |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
$self->_diag_fmt( $type, \$got ); |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
local $Level = $Level + 1; |
704
|
|
|
|
|
|
|
return $self->diag(<<"DIAGNOSTIC"); |
705
|
|
|
|
|
|
|
got: $got |
706
|
|
|
|
|
|
|
expected: anything else |
707
|
|
|
|
|
|
|
DIAGNOSTIC |
708
|
0
|
|
|
0
|
1
|
0
|
} |
709
|
|
|
|
|
|
|
|
710
|
0
|
0
|
|
|
|
0
|
#line 1032 |
711
|
|
|
|
|
|
|
|
712
|
0
|
0
|
|
|
|
0
|
sub isnt_eq { |
713
|
0
|
0
|
|
|
|
0
|
my( $self, $got, $dont_expect, $name ) = @_; |
714
|
0
|
|
|
|
|
0
|
local $Level = $Level + 1; |
715
|
|
|
|
|
|
|
|
716
|
0
|
|
|
|
|
0
|
if( !defined $got || !defined $dont_expect ) { |
717
|
|
|
|
|
|
|
# undef only matches undef and nothing else |
718
|
|
|
|
|
|
|
my $test = defined $got || defined $dont_expect; |
719
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
$self->ok( $test, $name ); |
721
|
|
|
|
|
|
|
$self->_isnt_diag( $got, 'ne' ) unless $test; |
722
|
|
|
|
|
|
|
return $test; |
723
|
|
|
|
|
|
|
} |
724
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
return $self->cmp_ok( $got, 'ne', $dont_expect, $name ); |
726
|
|
|
|
|
|
|
} |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
sub isnt_num { |
729
|
|
|
|
|
|
|
my( $self, $got, $dont_expect, $name ) = @_; |
730
|
|
|
|
|
|
|
local $Level = $Level + 1; |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
if( !defined $got || !defined $dont_expect ) { |
733
|
10
|
|
|
10
|
1
|
295
|
# undef only matches undef and nothing else |
734
|
|
|
|
|
|
|
my $test = defined $got || defined $dont_expect; |
735
|
10
|
50
|
|
|
|
85
|
|
736
|
10
|
|
|
|
|
39
|
$self->ok( $test, $name ); |
737
|
|
|
|
|
|
|
$self->_isnt_diag( $got, '!=' ) unless $test; |
738
|
10
|
|
|
|
|
34
|
return $test; |
739
|
|
|
|
|
|
|
} |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
return $self->cmp_ok( $got, '!=', $dont_expect, $name ); |
742
|
|
|
|
|
|
|
} |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
#line 1081 |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
sub like { |
747
|
|
|
|
|
|
|
my( $self, $this, $regex, $name ) = @_; |
748
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
local $Level = $Level + 1; |
750
|
|
|
|
|
|
|
return $self->_regex_ok( $this, $regex, '=~', $name ); |
751
|
|
|
|
|
|
|
} |
752
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
sub unlike { |
754
|
|
|
|
|
|
|
my( $self, $this, $regex, $name ) = @_; |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
local $Level = $Level + 1; |
757
|
|
|
|
|
|
|
return $self->_regex_ok( $this, $regex, '!~', $name ); |
758
|
|
|
|
|
|
|
} |
759
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
#line 1105 |
761
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
my %numeric_cmps = map { ( $_, 1 ) } ( "<", "<=", ">", ">=", "==", "!=", "<=>" ); |
763
|
74
|
|
|
74
|
1
|
121171
|
|
764
|
|
|
|
|
|
|
sub cmp_ok { |
765
|
74
|
50
|
33
|
|
|
301
|
my( $self, $got, $type, $expect, $name ) = @_; |
766
|
0
|
0
|
|
|
|
0
|
|
767
|
0
|
|
|
|
|
0
|
my $test; |
768
|
0
|
|
|
|
|
0
|
my $error; |
769
|
|
|
|
|
|
|
{ |
770
|
|
|
|
|
|
|
## no critic (BuiltinFunctions::ProhibitStringyEval) |
771
|
|
|
|
|
|
|
|
772
|
74
|
100
|
|
|
|
167
|
local( $@, $!, $SIG{__DIE__} ); # isolate eval |
773
|
|
|
|
|
|
|
|
774
|
74
|
|
|
|
|
1330
|
my($pack, $file, $line) = $self->caller(); |
775
|
74
|
|
|
|
|
123
|
|
776
|
|
|
|
|
|
|
# This is so that warnings come out at the caller's level |
777
|
|
|
|
|
|
|
$test = eval qq[ |
778
|
74
|
|
|
|
|
221
|
#line $line "(eval in cmp_ok) $file" |
779
|
|
|
|
|
|
|
\$got $type \$expect; |
780
|
74
|
50
|
66
|
|
|
564
|
]; |
781
|
|
|
|
|
|
|
$error = $@; |
782
|
|
|
|
|
|
|
} |
783
|
|
|
|
|
|
|
local $Level = $Level + 1; |
784
|
|
|
|
|
|
|
my $ok = $self->ok( $test, $name ); |
785
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
# Treat overloaded objects as numbers if we're asked to do a |
787
|
74
|
|
|
|
|
229
|
# numeric comparison. |
788
|
74
|
|
|
|
|
192
|
my $unoverload |
789
|
74
|
50
|
|
|
|
186
|
= $numeric_cmps{$type} |
790
|
|
|
|
|
|
|
? '_unoverload_num' |
791
|
74
|
|
|
|
|
194
|
: '_unoverload_str'; |
792
|
|
|
|
|
|
|
|
793
|
74
|
|
|
|
|
107
|
$self->diag(<<"END") if $error; |
794
|
74
|
|
|
|
|
210
|
An error occurred while using $type: |
795
|
|
|
|
|
|
|
------------------------------------ |
796
|
74
|
100
|
|
|
|
166
|
$error |
797
|
13
|
|
|
|
|
21
|
------------------------------------ |
798
|
13
|
50
|
|
|
|
35
|
END |
799
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
unless($ok) { |
801
|
61
|
|
|
|
|
221
|
$self->$unoverload( \$got, \$expect ); |
802
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
if( $type =~ /^(eq|==)$/ ) { |
804
|
74
|
|
|
|
|
134
|
$self->_is_diag( $got, $type, $expect ); |
805
|
74
|
50
|
|
|
|
189
|
} |
806
|
|
|
|
|
|
|
elsif( $type =~ /^(ne|!=)$/ ) { |
807
|
74
|
100
|
|
|
|
157
|
$self->_isnt_diag( $got, $type ); |
808
|
71
|
|
|
|
|
143
|
} |
809
|
71
|
|
|
|
|
142
|
else { |
810
|
71
|
|
|
|
|
167
|
$self->_cmp_diag( $got, $type, $expect ); |
811
|
|
|
|
|
|
|
} |
812
|
|
|
|
|
|
|
} |
813
|
3
|
|
|
|
|
8
|
return $ok; |
814
|
|
|
|
|
|
|
} |
815
|
|
|
|
|
|
|
|
816
|
74
|
50
|
|
|
|
160
|
sub _cmp_diag { |
817
|
0
|
|
|
|
|
0
|
my( $self, $got, $type, $expect ) = @_; |
818
|
0
|
|
|
|
|
0
|
|
819
|
0
|
|
|
|
|
0
|
$got = defined $got ? "'$got'" : 'undef'; |
820
|
|
|
|
|
|
|
$expect = defined $expect ? "'$expect'" : 'undef'; |
821
|
|
|
|
|
|
|
|
822
|
74
|
|
|
|
|
174
|
local $Level = $Level + 1; |
823
|
74
|
|
|
|
|
153
|
return $self->diag(<<"DIAGNOSTIC"); |
824
|
|
|
|
|
|
|
$got |
825
|
|
|
|
|
|
|
$type |
826
|
74
|
|
|
|
|
245
|
$expect |
827
|
74
|
|
|
|
|
113
|
DIAGNOSTIC |
828
|
|
|
|
|
|
|
} |
829
|
74
|
|
|
|
|
207
|
|
830
|
|
|
|
|
|
|
sub _caller_context { |
831
|
74
|
100
|
|
|
|
274
|
my $self = shift; |
832
|
13
|
50
|
|
|
|
56
|
|
833
|
13
|
50
|
|
|
|
76
|
my( $pack, $file, $line ) = $self->caller(1); |
834
|
|
|
|
|
|
|
|
835
|
13
|
|
|
|
|
41
|
my $code = ''; |
836
|
13
|
50
|
|
|
|
35
|
$code .= "#line $line $file\n" if defined $file and defined $line; |
837
|
13
|
|
|
|
|
57
|
|
838
|
13
|
|
|
|
|
61
|
return $code; |
839
|
|
|
|
|
|
|
} |
840
|
|
|
|
|
|
|
|
841
|
0
|
|
|
|
|
0
|
#line 1205 |
842
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
sub BAIL_OUT { |
844
|
|
|
|
|
|
|
my( $self, $reason ) = @_; |
845
|
74
|
100
|
66
|
|
|
235
|
|
846
|
|
|
|
|
|
|
$self->{Bailed_Out} = 1; |
847
|
|
|
|
|
|
|
$self->_print("Bail out! $reason"); |
848
|
74
|
|
|
|
|
242
|
exit 255; |
849
|
|
|
|
|
|
|
} |
850
|
74
|
100
|
|
|
|
382
|
|
851
|
|
|
|
|
|
|
#line 1218 |
852
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
{ |
854
|
|
|
|
|
|
|
no warnings 'once'; |
855
|
|
|
|
|
|
|
*BAILOUT = \&BAIL_OUT; |
856
|
|
|
|
|
|
|
} |
857
|
74
|
|
|
74
|
|
115
|
|
858
|
|
|
|
|
|
|
#line 1232 |
859
|
74
|
|
|
|
|
204
|
|
860
|
74
|
100
|
|
|
|
214
|
sub skip { |
861
|
42
|
50
|
|
|
|
127
|
my( $self, $why ) = @_; |
862
|
42
|
50
|
|
|
|
125
|
$why ||= ''; |
863
|
|
|
|
|
|
|
$self->_unoverload_str( \$why ); |
864
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
lock( $self->{Curr_Test} ); |
866
|
|
|
|
|
|
|
$self->{Curr_Test}++; |
867
|
184
|
|
|
184
|
|
207
|
|
868
|
184
|
|
|
|
|
390
|
$self->{Test_Results}[ $self->{Curr_Test} - 1 ] = &share( |
869
|
|
|
|
|
|
|
{ |
870
|
184
|
|
|
184
|
|
876
|
'ok' => 1, |
|
184
|
|
|
|
|
1209
|
|
871
|
|
|
|
|
|
|
actual_ok => 1, |
872
|
184
|
|
|
|
|
782
|
name => '', |
873
|
220
|
100
|
|
|
|
502
|
type => 'skip', |
874
|
36
|
50
|
|
|
|
136
|
reason => $why, |
875
|
36
|
|
|
|
|
6775
|
} |
876
|
|
|
|
|
|
|
); |
877
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
my $out = "ok"; |
879
|
|
|
|
|
|
|
$out .= " $self->{Curr_Test}" if $self->use_numbers; |
880
|
184
|
|
|
|
|
2023
|
$out .= " # skip"; |
881
|
|
|
|
|
|
|
$out .= " $why" if length $why; |
882
|
|
|
|
|
|
|
$out .= "\n"; |
883
|
|
|
|
|
|
|
|
884
|
220
|
|
|
220
|
|
407
|
$self->_print($out); |
885
|
|
|
|
|
|
|
|
886
|
220
|
100
|
|
220
|
|
853
|
return 1; |
|
220
|
100
|
|
|
|
911
|
|
887
|
|
|
|
|
|
|
} |
888
|
|
|
|
|
|
|
|
889
|
|
|
|
|
|
|
#line 1273 |
890
|
184
|
|
|
184
|
|
235
|
|
891
|
|
|
|
|
|
|
sub todo_skip { |
892
|
184
|
|
|
|
|
447
|
my( $self, $why ) = @_; |
893
|
|
|
|
|
|
|
$why ||= ''; |
894
|
|
|
|
|
|
|
|
895
|
|
|
|
|
|
|
lock( $self->{Curr_Test} ); |
896
|
0
|
|
|
0
|
|
0
|
$self->{Curr_Test}++; |
897
|
|
|
|
|
|
|
|
898
|
0
|
|
|
|
|
0
|
$self->{Test_Results}[ $self->{Curr_Test} - 1 ] = &share( |
899
|
|
|
|
|
|
|
{ |
900
|
0
|
|
|
|
|
0
|
'ok' => 1, |
901
|
0
|
0
|
|
|
|
0
|
actual_ok => 0, |
902
|
0
|
|
|
|
|
0
|
name => '', |
903
|
|
|
|
|
|
|
type => 'todo_skip', |
904
|
|
|
|
|
|
|
reason => $why, |
905
|
0
|
|
|
|
|
0
|
} |
906
|
|
|
|
|
|
|
); |
907
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
my $out = "not ok"; |
909
|
|
|
|
|
|
|
$out .= " $self->{Curr_Test}" if $self->use_numbers; |
910
|
0
|
|
|
0
|
|
0
|
$out .= " # TODO & SKIP $why\n"; |
911
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
$self->_print($out); |
913
|
0
|
0
|
|
|
|
0
|
|
914
|
|
|
|
|
|
|
return 1; |
915
|
8
|
|
|
8
|
|
71
|
} |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
21916
|
|
916
|
0
|
|
|
|
|
0
|
|
917
|
0
|
0
|
|
|
|
0
|
#line 1353 |
|
|
0
|
|
|
|
|
|
918
|
|
|
|
|
|
|
|
919
|
|
|
|
|
|
|
sub maybe_regex { |
920
|
|
|
|
|
|
|
my( $self, $regex ) = @_; |
921
|
|
|
|
|
|
|
my $usable_regex = undef; |
922
|
|
|
|
|
|
|
|
923
|
|
|
|
|
|
|
return $usable_regex unless defined $regex; |
924
|
|
|
|
|
|
|
|
925
|
|
|
|
|
|
|
my( $re, $opts ); |
926
|
|
|
|
|
|
|
|
927
|
|
|
|
|
|
|
# Check for qr/foo/ |
928
|
|
|
|
|
|
|
if( _is_qr($regex) ) { |
929
|
|
|
|
|
|
|
$usable_regex = $regex; |
930
|
|
|
|
|
|
|
} |
931
|
|
|
|
|
|
|
# Check for '/foo/' or 'm,foo,' |
932
|
|
|
|
|
|
|
elsif(( $re, $opts ) = $regex =~ m{^ /(.*)/ (\w*) $ }sx or |
933
|
|
|
|
|
|
|
( undef, $re, $opts ) = $regex =~ m,^ m([^\w\s]) (.+) \1 (\w*) $,sx |
934
|
|
|
|
|
|
|
) |
935
|
|
|
|
|
|
|
{ |
936
|
|
|
|
|
|
|
$usable_regex = length $opts ? "(?$opts)$re" : $re; |
937
|
|
|
|
|
|
|
} |
938
|
|
|
|
|
|
|
|
939
|
|
|
|
|
|
|
return $usable_regex; |
940
|
|
|
|
|
|
|
} |
941
|
37
|
|
|
37
|
1
|
72
|
|
942
|
37
|
|
|
|
|
116
|
sub _is_qr { |
943
|
|
|
|
|
|
|
my $regex = shift; |
944
|
37
|
100
|
66
|
|
|
146
|
|
945
|
|
|
|
|
|
|
# is_regexp() checks for regexes in a robust manner, say if they're |
946
|
1
|
|
33
|
|
|
8
|
# blessed. |
947
|
|
|
|
|
|
|
return re::is_regexp($regex) if defined &re::is_regexp; |
948
|
1
|
|
|
|
|
5
|
return ref $regex eq 'Regexp'; |
949
|
1
|
50
|
|
|
|
5
|
} |
950
|
1
|
|
|
|
|
5
|
|
951
|
|
|
|
|
|
|
sub _regex_ok { |
952
|
|
|
|
|
|
|
my( $self, $this, $regex, $cmp, $name ) = @_; |
953
|
36
|
|
|
|
|
100
|
|
954
|
|
|
|
|
|
|
my $ok = 0; |
955
|
|
|
|
|
|
|
my $usable_regex = $self->maybe_regex($regex); |
956
|
|
|
|
|
|
|
unless( defined $usable_regex ) { |
957
|
0
|
|
|
0
|
1
|
0
|
local $Level = $Level + 1; |
958
|
0
|
|
|
|
|
0
|
$ok = $self->ok( 0, $name ); |
959
|
|
|
|
|
|
|
$self->diag(" '$regex' doesn't look much like a regex to me."); |
960
|
0
|
0
|
0
|
|
|
0
|
return $ok; |
961
|
|
|
|
|
|
|
} |
962
|
0
|
|
0
|
|
|
0
|
|
963
|
|
|
|
|
|
|
{ |
964
|
0
|
|
|
|
|
0
|
## no critic (BuiltinFunctions::ProhibitStringyEval) |
965
|
0
|
0
|
|
|
|
0
|
|
966
|
0
|
|
|
|
|
0
|
my $test; |
967
|
|
|
|
|
|
|
my $context = $self->_caller_context; |
968
|
|
|
|
|
|
|
|
969
|
0
|
|
|
|
|
0
|
local( $@, $!, $SIG{__DIE__} ); # isolate eval |
970
|
|
|
|
|
|
|
|
971
|
|
|
|
|
|
|
$test = eval $context . q{$test = $this =~ /$usable_regex/ ? 1 : 0}; |
972
|
|
|
|
|
|
|
|
973
|
0
|
|
|
0
|
|
0
|
$test = !$test if $cmp eq '!~'; |
974
|
|
|
|
|
|
|
|
975
|
0
|
0
|
|
|
|
0
|
local $Level = $Level + 1; |
976
|
0
|
0
|
0
|
|
|
0
|
$ok = $self->ok( $test, $name ); |
977
|
|
|
|
|
|
|
} |
978
|
0
|
|
|
|
|
0
|
|
979
|
|
|
|
|
|
|
unless($ok) { |
980
|
|
|
|
|
|
|
$this = defined $this ? "'$this'" : 'undef'; |
981
|
|
|
|
|
|
|
my $match = $cmp eq '=~' ? "doesn't match" : "matches"; |
982
|
0
|
|
|
|
|
0
|
|
983
|
|
|
|
|
|
|
local $Level = $Level + 1; |
984
|
|
|
|
|
|
|
$self->diag( sprintf <<'DIAGNOSTIC', $this, $match, $regex ); |
985
|
|
|
|
|
|
|
%s |
986
|
0
|
|
|
|
|
0
|
%13s '%s' |
987
|
|
|
|
|
|
|
DIAGNOSTIC |
988
|
|
|
|
|
|
|
|
989
|
0
|
|
|
|
|
0
|
} |
990
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
return $ok; |
992
|
|
|
|
|
|
|
} |
993
|
0
|
|
|
0
|
|
0
|
|
994
|
|
|
|
|
|
|
# I'm not ready to publish this. It doesn't deal with array return |
995
|
0
|
|
|
|
|
0
|
# values from the code or context. |
996
|
|
|
|
|
|
|
|
997
|
0
|
|
|
|
|
0
|
#line 1449 |
998
|
0
|
|
|
|
|
0
|
|
999
|
|
|
|
|
|
|
sub _try { |
1000
|
|
|
|
|
|
|
my( $self, $code, %opts ) = @_; |
1001
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
my $error; |
1003
|
|
|
|
|
|
|
my $return; |
1004
|
|
|
|
|
|
|
{ |
1005
|
|
|
|
|
|
|
local $!; # eval can mess up $! |
1006
|
0
|
|
|
0
|
|
0
|
local $@; # don't set $@ in the test |
1007
|
|
|
|
|
|
|
local $SIG{__DIE__}; # don't trip an outside DIE handler. |
1008
|
0
|
|
|
|
|
0
|
$return = eval { $code->() }; |
1009
|
|
|
|
|
|
|
$error = $@; |
1010
|
0
|
|
|
|
|
0
|
} |
1011
|
0
|
|
|
|
|
0
|
|
1012
|
|
|
|
|
|
|
die $error if $error and $opts{die_on_fail}; |
1013
|
|
|
|
|
|
|
|
1014
|
|
|
|
|
|
|
return wantarray ? ( $return, $error ) : $return; |
1015
|
|
|
|
|
|
|
} |
1016
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
#line 1478 |
1018
|
|
|
|
|
|
|
|
1019
|
|
|
|
|
|
|
sub is_fh { |
1020
|
|
|
|
|
|
|
my $self = shift; |
1021
|
|
|
|
|
|
|
my $maybe_fh = shift; |
1022
|
|
|
|
|
|
|
return 0 unless defined $maybe_fh; |
1023
|
|
|
|
|
|
|
|
1024
|
|
|
|
|
|
|
return 1 if ref $maybe_fh eq 'GLOB'; # its a glob ref |
1025
|
|
|
|
|
|
|
return 1 if ref \$maybe_fh eq 'GLOB'; # its a glob |
1026
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
return eval { $maybe_fh->isa("IO::Handle") } || |
1028
|
|
|
|
|
|
|
eval { tied($maybe_fh)->can('TIEHANDLE') }; |
1029
|
|
|
|
|
|
|
} |
1030
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
#line 1521 |
1032
|
|
|
|
|
|
|
|
1033
|
|
|
|
|
|
|
sub level { |
1034
|
0
|
|
|
0
|
1
|
0
|
my( $self, $level ) = @_; |
1035
|
0
|
|
|
|
|
0
|
|
1036
|
|
|
|
|
|
|
if( defined $level ) { |
1037
|
0
|
0
|
0
|
|
|
0
|
$Level = $level; |
1038
|
|
|
|
|
|
|
} |
1039
|
0
|
|
0
|
|
|
0
|
return $Level; |
1040
|
|
|
|
|
|
|
} |
1041
|
0
|
|
|
|
|
0
|
|
1042
|
0
|
0
|
|
|
|
0
|
#line 1553 |
1043
|
0
|
|
|
|
|
0
|
|
1044
|
|
|
|
|
|
|
sub use_numbers { |
1045
|
|
|
|
|
|
|
my( $self, $use_nums ) = @_; |
1046
|
0
|
|
|
|
|
0
|
|
1047
|
|
|
|
|
|
|
if( defined $use_nums ) { |
1048
|
|
|
|
|
|
|
$self->{Use_Nums} = $use_nums; |
1049
|
|
|
|
|
|
|
} |
1050
|
0
|
|
|
0
|
1
|
0
|
return $self->{Use_Nums}; |
1051
|
0
|
|
|
|
|
0
|
} |
1052
|
|
|
|
|
|
|
|
1053
|
0
|
0
|
0
|
|
|
0
|
#line 1586 |
1054
|
|
|
|
|
|
|
|
1055
|
0
|
|
0
|
|
|
0
|
foreach my $attribute (qw(No_Header No_Ending No_Diag)) { |
1056
|
|
|
|
|
|
|
my $method = lc $attribute; |
1057
|
0
|
|
|
|
|
0
|
|
1058
|
0
|
0
|
|
|
|
0
|
my $code = sub { |
1059
|
0
|
|
|
|
|
0
|
my( $self, $no ) = @_; |
1060
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
if( defined $no ) { |
1062
|
0
|
|
|
|
|
0
|
$self->{$attribute} = $no; |
1063
|
|
|
|
|
|
|
} |
1064
|
|
|
|
|
|
|
return $self->{$attribute}; |
1065
|
|
|
|
|
|
|
}; |
1066
|
|
|
|
|
|
|
|
1067
|
|
|
|
|
|
|
no strict 'refs'; ## no critic |
1068
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $method } = $code; |
1069
|
|
|
|
|
|
|
} |
1070
|
|
|
|
|
|
|
|
1071
|
|
|
|
|
|
|
#line 1639 |
1072
|
|
|
|
|
|
|
|
1073
|
|
|
|
|
|
|
sub diag { |
1074
|
|
|
|
|
|
|
my $self = shift; |
1075
|
|
|
|
|
|
|
|
1076
|
|
|
|
|
|
|
$self->_print_comment( $self->_diag_fh, @_ ); |
1077
|
|
|
|
|
|
|
} |
1078
|
|
|
|
|
|
|
|
1079
|
|
|
|
|
|
|
#line 1654 |
1080
|
|
|
|
|
|
|
|
1081
|
|
|
|
|
|
|
sub note { |
1082
|
|
|
|
|
|
|
my $self = shift; |
1083
|
17
|
|
|
17
|
1
|
41
|
|
1084
|
|
|
|
|
|
|
$self->_print_comment( $self->output, @_ ); |
1085
|
17
|
|
|
|
|
42
|
} |
1086
|
17
|
|
|
|
|
146
|
|
1087
|
|
|
|
|
|
|
sub _diag_fh { |
1088
|
|
|
|
|
|
|
my $self = shift; |
1089
|
|
|
|
|
|
|
|
1090
|
0
|
|
|
0
|
1
|
0
|
local $Level = $Level + 1; |
1091
|
|
|
|
|
|
|
return $self->in_todo ? $self->todo_output : $self->failure_output; |
1092
|
0
|
|
|
|
|
0
|
} |
1093
|
0
|
|
|
|
|
0
|
|
1094
|
|
|
|
|
|
|
sub _print_comment { |
1095
|
|
|
|
|
|
|
my( $self, $fh, @msgs ) = @_; |
1096
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
return if $self->no_diag; |
1098
|
|
|
|
|
|
|
return unless @msgs; |
1099
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
# Prevent printing headers when compiling (i.e. -c) |
1101
|
|
|
|
|
|
|
return if $^C; |
1102
|
|
|
|
|
|
|
|
1103
|
|
|
|
|
|
|
# Smash args together like print does. |
1104
|
|
|
|
|
|
|
# Convert undef to 'undef' so its readable. |
1105
|
|
|
|
|
|
|
my $msg = join '', map { defined($_) ? $_ : 'undef' } @msgs; |
1106
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
# Escape the beginning, _print will take care of the rest. |
1108
|
|
|
|
|
|
|
$msg =~ s/^/# /; |
1109
|
36
|
|
|
36
|
1
|
63
|
|
1110
|
|
|
|
|
|
|
local $Level = $Level + 1; |
1111
|
36
|
|
|
|
|
39
|
$self->_print_to_fh( $fh, $msg ); |
1112
|
|
|
|
|
|
|
|
1113
|
|
|
|
|
|
|
return 0; |
1114
|
|
|
|
|
|
|
} |
1115
|
|
|
|
|
|
|
|
1116
|
36
|
|
|
|
|
37
|
#line 1704 |
|
36
|
|
|
|
|
161
|
|
1117
|
|
|
|
|
|
|
|
1118
|
36
|
|
|
|
|
122
|
sub explain { |
1119
|
|
|
|
|
|
|
my $self = shift; |
1120
|
|
|
|
|
|
|
|
1121
|
36
|
|
|
|
|
1930
|
return map { |
1122
|
|
|
|
|
|
|
ref $_ |
1123
|
|
|
|
|
|
|
? do { |
1124
|
|
|
|
|
|
|
$self->_try(sub { require Data::Dumper }, die_on_fail => 1); |
1125
|
36
|
|
|
|
|
476
|
|
1126
|
|
|
|
|
|
|
my $dumper = Data::Dumper->new( [$_] ); |
1127
|
36
|
|
|
|
|
60
|
$dumper->Indent(1)->Terse(1); |
1128
|
36
|
|
|
|
|
98
|
$dumper->Sortkeys(1) if $dumper->can("Sortkeys"); |
1129
|
|
|
|
|
|
|
$dumper->Dump; |
1130
|
|
|
|
|
|
|
} |
1131
|
|
|
|
|
|
|
: $_ |
1132
|
36
|
50
|
|
|
|
97
|
} @_; |
1133
|
|
|
|
|
|
|
} |
1134
|
|
|
|
|
|
|
|
1135
|
|
|
|
|
|
|
#line 1733 |
1136
|
|
|
|
|
|
|
|
1137
|
36
|
50
|
|
|
|
71
|
sub _print { |
1138
|
|
|
|
|
|
|
my $self = shift; |
1139
|
|
|
|
|
|
|
return $self->_print_to_fh( $self->output, @_ ); |
1140
|
|
|
|
|
|
|
} |
1141
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
sub _print_to_fh { |
1143
|
|
|
|
|
|
|
my( $self, $fh, @msgs ) = @_; |
1144
|
36
|
50
|
|
|
|
80
|
|
1145
|
0
|
|
|
|
|
0
|
# Prevent printing headers when only compiling. Mostly for when |
1146
|
|
|
|
|
|
|
# tests are deparsed with B::Deparse |
1147
|
0
|
0
|
|
|
|
0
|
return if $^C; |
|
|
0
|
|
|
|
|
|
1148
|
0
|
|
|
|
|
0
|
|
1149
|
|
|
|
|
|
|
my $msg = join '', @msgs; |
1150
|
|
|
|
|
|
|
my $indent = $self->_indent; |
1151
|
0
|
|
|
|
|
0
|
|
1152
|
|
|
|
|
|
|
local( $\, $", $, ) = ( undef, ' ', '' ); |
1153
|
|
|
|
|
|
|
|
1154
|
0
|
|
|
|
|
0
|
# Escape each line after the first with a # so we don't |
1155
|
|
|
|
|
|
|
# confuse Test::Harness. |
1156
|
|
|
|
|
|
|
$msg =~ s{\n(?!\z)}{\n$indent# }sg; |
1157
|
36
|
|
|
|
|
163
|
|
1158
|
|
|
|
|
|
|
# Stick a newline on the end if it needs it. |
1159
|
|
|
|
|
|
|
$msg .= "\n" unless $msg =~ /\n\z/; |
1160
|
|
|
|
|
|
|
|
1161
|
0
|
|
|
0
|
|
0
|
return print $fh $indent, $msg; |
1162
|
|
|
|
|
|
|
} |
1163
|
0
|
0
|
|
|
|
0
|
|
1164
|
0
|
0
|
|
|
|
0
|
#line 1793 |
1165
|
|
|
|
|
|
|
|
1166
|
0
|
|
|
|
|
0
|
sub output { |
1167
|
0
|
|
|
|
|
0
|
my( $self, $fh ) = @_; |
1168
|
|
|
|
|
|
|
|
1169
|
|
|
|
|
|
|
if( defined $fh ) { |
1170
|
|
|
|
|
|
|
$self->{Out_FH} = $self->_new_fh($fh); |
1171
|
|
|
|
|
|
|
} |
1172
|
|
|
|
|
|
|
return $self->{Out_FH}; |
1173
|
|
|
|
|
|
|
} |
1174
|
|
|
|
|
|
|
|
1175
|
17
|
|
|
17
|
|
30
|
sub failure_output { |
1176
|
|
|
|
|
|
|
my( $self, $fh ) = @_; |
1177
|
17
|
|
|
|
|
53
|
|
1178
|
|
|
|
|
|
|
if( defined $fh ) { |
1179
|
17
|
|
|
|
|
44
|
$self->{Fail_FH} = $self->_new_fh($fh); |
1180
|
17
|
50
|
33
|
|
|
244
|
} |
1181
|
|
|
|
|
|
|
return $self->{Fail_FH}; |
1182
|
17
|
|
|
|
|
43
|
} |
1183
|
|
|
|
|
|
|
|
1184
|
|
|
|
|
|
|
sub todo_output { |
1185
|
|
|
|
|
|
|
my( $self, $fh ) = @_; |
1186
|
|
|
|
|
|
|
|
1187
|
|
|
|
|
|
|
if( defined $fh ) { |
1188
|
|
|
|
|
|
|
$self->{Todo_FH} = $self->_new_fh($fh); |
1189
|
|
|
|
|
|
|
} |
1190
|
|
|
|
|
|
|
return $self->{Todo_FH}; |
1191
|
|
|
|
|
|
|
} |
1192
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
sub _new_fh { |
1194
|
|
|
|
|
|
|
my $self = shift; |
1195
|
|
|
|
|
|
|
my($file_or_fh) = shift; |
1196
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
my $fh; |
1198
|
|
|
|
|
|
|
if( $self->is_fh($file_or_fh) ) { |
1199
|
|
|
|
|
|
|
$fh = $file_or_fh; |
1200
|
|
|
|
|
|
|
} |
1201
|
|
|
|
|
|
|
elsif( ref $file_or_fh eq 'SCALAR' ) { |
1202
|
|
|
|
|
|
|
# Scalar refs as filehandles was added in 5.8. |
1203
|
|
|
|
|
|
|
if( $] >= 5.008 ) { |
1204
|
|
|
|
|
|
|
open $fh, ">>", $file_or_fh |
1205
|
|
|
|
|
|
|
or $self->croak("Can't open scalar ref $file_or_fh: $!"); |
1206
|
|
|
|
|
|
|
} |
1207
|
0
|
|
|
0
|
1
|
0
|
# Emulate scalar ref filehandles with a tie. |
1208
|
|
|
|
|
|
|
else { |
1209
|
0
|
|
|
|
|
0
|
$fh = Test::Builder::IO::Scalar->new($file_or_fh) |
1210
|
0
|
|
|
|
|
0
|
or $self->croak("Can't tie scalar ref $file_or_fh"); |
1211
|
0
|
|
|
|
|
0
|
} |
1212
|
|
|
|
|
|
|
} |
1213
|
|
|
|
|
|
|
else { |
1214
|
|
|
|
|
|
|
open $fh, ">", $file_or_fh |
1215
|
|
|
|
|
|
|
or $self->croak("Can't open test output log $file_or_fh: $!"); |
1216
|
|
|
|
|
|
|
_autoflush($fh); |
1217
|
|
|
|
|
|
|
} |
1218
|
|
|
|
|
|
|
|
1219
|
|
|
|
|
|
|
return $fh; |
1220
|
8
|
|
|
8
|
|
65
|
} |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
9764
|
|
1221
|
|
|
|
|
|
|
|
1222
|
|
|
|
|
|
|
sub _autoflush { |
1223
|
|
|
|
|
|
|
my($fh) = shift; |
1224
|
|
|
|
|
|
|
my $old_fh = select $fh; |
1225
|
|
|
|
|
|
|
$| = 1; |
1226
|
|
|
|
|
|
|
select $old_fh; |
1227
|
|
|
|
|
|
|
|
1228
|
|
|
|
|
|
|
return; |
1229
|
|
|
|
|
|
|
} |
1230
|
|
|
|
|
|
|
|
1231
|
|
|
|
|
|
|
my( $Testout, $Testerr ); |
1232
|
|
|
|
|
|
|
|
1233
|
|
|
|
|
|
|
sub _dup_stdhandles { |
1234
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
1235
|
0
|
|
0
|
|
|
0
|
|
1236
|
0
|
|
|
|
|
0
|
$self->_open_testhandles; |
1237
|
|
|
|
|
|
|
|
1238
|
0
|
|
|
|
|
0
|
# Set everything to unbuffered else plain prints to STDOUT will |
1239
|
0
|
|
|
|
|
0
|
# come out in the wrong order from our own prints. |
1240
|
|
|
|
|
|
|
_autoflush($Testout); |
1241
|
0
|
|
|
|
|
0
|
_autoflush( \*STDOUT ); |
1242
|
|
|
|
|
|
|
_autoflush($Testerr); |
1243
|
|
|
|
|
|
|
_autoflush( \*STDERR ); |
1244
|
|
|
|
|
|
|
|
1245
|
|
|
|
|
|
|
$self->reset_outputs; |
1246
|
|
|
|
|
|
|
|
1247
|
|
|
|
|
|
|
return; |
1248
|
|
|
|
|
|
|
} |
1249
|
|
|
|
|
|
|
|
1250
|
|
|
|
|
|
|
sub _open_testhandles { |
1251
|
0
|
|
|
|
|
0
|
my $self = shift; |
1252
|
0
|
0
|
|
|
|
0
|
|
1253
|
0
|
|
|
|
|
0
|
return if $self->{Opened_Testhandles}; |
1254
|
0
|
0
|
|
|
|
0
|
|
1255
|
0
|
|
|
|
|
0
|
# We dup STDOUT and STDERR so people can change them in their |
1256
|
|
|
|
|
|
|
# test suites while still getting normal test output. |
1257
|
0
|
|
|
|
|
0
|
open( $Testout, ">&STDOUT" ) or die "Can't dup STDOUT: $!"; |
1258
|
|
|
|
|
|
|
open( $Testerr, ">&STDERR" ) or die "Can't dup STDERR: $!"; |
1259
|
0
|
|
|
|
|
0
|
|
1260
|
|
|
|
|
|
|
$self->_copy_io_layers( \*STDOUT, $Testout ); |
1261
|
|
|
|
|
|
|
$self->_copy_io_layers( \*STDERR, $Testerr ); |
1262
|
|
|
|
|
|
|
|
1263
|
|
|
|
|
|
|
$self->{Opened_Testhandles} = 1; |
1264
|
|
|
|
|
|
|
|
1265
|
|
|
|
|
|
|
return; |
1266
|
|
|
|
|
|
|
} |
1267
|
|
|
|
|
|
|
|
1268
|
|
|
|
|
|
|
sub _copy_io_layers { |
1269
|
|
|
|
|
|
|
my( $self, $src, $dst ) = @_; |
1270
|
|
|
|
|
|
|
|
1271
|
|
|
|
|
|
|
$self->_try( |
1272
|
|
|
|
|
|
|
sub { |
1273
|
|
|
|
|
|
|
require PerlIO; |
1274
|
|
|
|
|
|
|
my @src_layers = PerlIO::get_layers($src); |
1275
|
0
|
|
|
0
|
1
|
0
|
|
1276
|
0
|
|
0
|
|
|
0
|
_apply_layers($dst, @src_layers) if @src_layers; |
1277
|
|
|
|
|
|
|
} |
1278
|
0
|
|
|
|
|
0
|
); |
1279
|
0
|
|
|
|
|
0
|
|
1280
|
|
|
|
|
|
|
return; |
1281
|
0
|
|
|
|
|
0
|
} |
1282
|
|
|
|
|
|
|
|
1283
|
|
|
|
|
|
|
sub _apply_layers { |
1284
|
|
|
|
|
|
|
my ($fh, @layers) = @_; |
1285
|
|
|
|
|
|
|
my %seen; |
1286
|
|
|
|
|
|
|
my @unique = grep { $_ ne 'unix' and !$seen{$_}++ } @layers; |
1287
|
|
|
|
|
|
|
binmode($fh, join(":", "", "raw", @unique)); |
1288
|
|
|
|
|
|
|
} |
1289
|
|
|
|
|
|
|
|
1290
|
|
|
|
|
|
|
|
1291
|
0
|
|
|
|
|
0
|
#line 1926 |
1292
|
0
|
0
|
|
|
|
0
|
|
1293
|
0
|
|
|
|
|
0
|
sub reset_outputs { |
1294
|
|
|
|
|
|
|
my $self = shift; |
1295
|
0
|
|
|
|
|
0
|
|
1296
|
|
|
|
|
|
|
$self->output ($Testout); |
1297
|
0
|
|
|
|
|
0
|
$self->failure_output($Testerr); |
1298
|
|
|
|
|
|
|
$self->todo_output ($Testout); |
1299
|
|
|
|
|
|
|
|
1300
|
|
|
|
|
|
|
return; |
1301
|
|
|
|
|
|
|
} |
1302
|
|
|
|
|
|
|
|
1303
|
|
|
|
|
|
|
#line 1952 |
1304
|
|
|
|
|
|
|
|
1305
|
|
|
|
|
|
|
sub _message_at_caller { |
1306
|
|
|
|
|
|
|
my $self = shift; |
1307
|
|
|
|
|
|
|
|
1308
|
|
|
|
|
|
|
local $Level = $Level + 1; |
1309
|
|
|
|
|
|
|
my( $pack, $file, $line ) = $self->caller; |
1310
|
|
|
|
|
|
|
return join( "", @_ ) . " at $file line $line.\n"; |
1311
|
|
|
|
|
|
|
} |
1312
|
|
|
|
|
|
|
|
1313
|
|
|
|
|
|
|
sub carp { |
1314
|
|
|
|
|
|
|
my $self = shift; |
1315
|
|
|
|
|
|
|
return warn $self->_message_at_caller(@_); |
1316
|
|
|
|
|
|
|
} |
1317
|
|
|
|
|
|
|
|
1318
|
|
|
|
|
|
|
sub croak { |
1319
|
|
|
|
|
|
|
my $self = shift; |
1320
|
|
|
|
|
|
|
return die $self->_message_at_caller(@_); |
1321
|
|
|
|
|
|
|
} |
1322
|
|
|
|
|
|
|
|
1323
|
|
|
|
|
|
|
|
1324
|
|
|
|
|
|
|
#line 1992 |
1325
|
|
|
|
|
|
|
|
1326
|
|
|
|
|
|
|
sub current_test { |
1327
|
|
|
|
|
|
|
my( $self, $num ) = @_; |
1328
|
|
|
|
|
|
|
|
1329
|
|
|
|
|
|
|
lock( $self->{Curr_Test} ); |
1330
|
|
|
|
|
|
|
if( defined $num ) { |
1331
|
|
|
|
|
|
|
$self->{Curr_Test} = $num; |
1332
|
|
|
|
|
|
|
|
1333
|
|
|
|
|
|
|
# If the test counter is being pushed forward fill in the details. |
1334
|
|
|
|
|
|
|
my $test_results = $self->{Test_Results}; |
1335
|
|
|
|
|
|
|
if( $num > @$test_results ) { |
1336
|
|
|
|
|
|
|
my $start = @$test_results ? @$test_results : 0; |
1337
|
|
|
|
|
|
|
for( $start .. $num - 1 ) { |
1338
|
|
|
|
|
|
|
$test_results->[$_] = &share( |
1339
|
|
|
|
|
|
|
{ |
1340
|
|
|
|
|
|
|
'ok' => 1, |
1341
|
|
|
|
|
|
|
actual_ok => undef, |
1342
|
|
|
|
|
|
|
reason => 'incrementing test number', |
1343
|
|
|
|
|
|
|
type => 'unknown', |
1344
|
|
|
|
|
|
|
name => undef |
1345
|
|
|
|
|
|
|
} |
1346
|
|
|
|
|
|
|
); |
1347
|
|
|
|
|
|
|
} |
1348
|
|
|
|
|
|
|
} |
1349
|
|
|
|
|
|
|
# If backward, wipe history. Its their funeral. |
1350
|
|
|
|
|
|
|
elsif( $num < @$test_results ) { |
1351
|
|
|
|
|
|
|
$#{$test_results} = $num - 1; |
1352
|
|
|
|
|
|
|
} |
1353
|
|
|
|
|
|
|
} |
1354
|
|
|
|
|
|
|
return $self->{Curr_Test}; |
1355
|
17
|
|
|
17
|
1
|
26
|
} |
1356
|
17
|
|
|
|
|
31
|
|
1357
|
|
|
|
|
|
|
#line 2040 |
1358
|
17
|
50
|
|
|
|
48
|
|
1359
|
|
|
|
|
|
|
sub is_passing { |
1360
|
17
|
|
|
|
|
101
|
my $self = shift; |
1361
|
|
|
|
|
|
|
|
1362
|
|
|
|
|
|
|
if( @_ ) { |
1363
|
17
|
50
|
0
|
|
|
49
|
$self->{Is_Passing} = shift; |
|
|
0
|
|
|
|
|
|
1364
|
17
|
|
|
|
|
32
|
} |
1365
|
|
|
|
|
|
|
|
1366
|
|
|
|
|
|
|
return $self->{Is_Passing}; |
1367
|
|
|
|
|
|
|
} |
1368
|
|
|
|
|
|
|
|
1369
|
|
|
|
|
|
|
|
1370
|
|
|
|
|
|
|
#line 2062 |
1371
|
0
|
0
|
|
|
|
0
|
|
1372
|
|
|
|
|
|
|
sub summary { |
1373
|
|
|
|
|
|
|
my($self) = shift; |
1374
|
17
|
|
|
|
|
44
|
|
1375
|
|
|
|
|
|
|
return map { $_->{'ok'} } @{ $self->{Test_Results} }; |
1376
|
|
|
|
|
|
|
} |
1377
|
|
|
|
|
|
|
|
1378
|
17
|
|
|
17
|
|
31
|
#line 2117 |
1379
|
|
|
|
|
|
|
|
1380
|
|
|
|
|
|
|
sub details { |
1381
|
|
|
|
|
|
|
my $self = shift; |
1382
|
17
|
50
|
|
|
|
202
|
return @{ $self->{Test_Results} }; |
1383
|
0
|
|
|
|
|
0
|
} |
1384
|
|
|
|
|
|
|
|
1385
|
|
|
|
|
|
|
#line 2146 |
1386
|
|
|
|
|
|
|
|
1387
|
17
|
|
|
17
|
|
39
|
sub todo { |
1388
|
|
|
|
|
|
|
my( $self, $pack ) = @_; |
1389
|
17
|
|
|
|
|
30
|
|
1390
|
17
|
|
|
|
|
61
|
return $self->{Todo} if defined $self->{Todo}; |
1391
|
17
|
50
|
|
|
|
42
|
|
1392
|
0
|
|
|
|
|
0
|
local $Level = $Level + 1; |
1393
|
0
|
|
|
|
|
0
|
my $todo = $self->find_TODO($pack); |
1394
|
0
|
|
|
|
|
0
|
return $todo if defined $todo; |
1395
|
0
|
|
|
|
|
0
|
|
1396
|
|
|
|
|
|
|
return ''; |
1397
|
|
|
|
|
|
|
} |
1398
|
|
|
|
|
|
|
|
1399
|
|
|
|
|
|
|
#line 2173 |
1400
|
|
|
|
|
|
|
|
1401
|
17
|
|
|
|
|
20
|
sub find_TODO { |
|
17
|
|
|
|
|
84
|
|
1402
|
17
|
|
|
|
|
64
|
my( $self, $pack, $set, $new_value ) = @_; |
1403
|
|
|
|
|
|
|
|
1404
|
17
|
|
|
|
|
121
|
$pack = $pack || $self->caller(1) || $self->exported_to; |
1405
|
|
|
|
|
|
|
return unless $pack; |
1406
|
17
|
|
|
|
|
1483
|
|
1407
|
|
|
|
|
|
|
no strict 'refs'; ## no critic |
1408
|
17
|
50
|
|
|
|
446
|
my $old_value = ${ $pack . '::TODO' }; |
1409
|
|
|
|
|
|
|
$set and ${ $pack . '::TODO' } = $new_value; |
1410
|
17
|
|
|
|
|
35
|
return $old_value; |
1411
|
17
|
|
|
|
|
65
|
} |
1412
|
|
|
|
|
|
|
|
1413
|
|
|
|
|
|
|
#line 2193 |
1414
|
17
|
100
|
|
|
|
51
|
|
1415
|
12
|
50
|
|
|
|
45
|
sub in_todo { |
1416
|
12
|
50
|
|
|
|
35
|
my $self = shift; |
1417
|
|
|
|
|
|
|
|
1418
|
12
|
|
|
|
|
22
|
local $Level = $Level + 1; |
1419
|
12
|
|
|
|
|
88
|
return( defined $self->{Todo} || $self->find_TODO ) ? 1 : 0; |
1420
|
|
|
|
|
|
|
} |
1421
|
|
|
|
|
|
|
|
1422
|
|
|
|
|
|
|
#line 2243 |
1423
|
|
|
|
|
|
|
|
1424
|
|
|
|
|
|
|
sub todo_start { |
1425
|
|
|
|
|
|
|
my $self = shift; |
1426
|
17
|
|
|
|
|
191
|
my $message = @_ ? shift : ''; |
1427
|
|
|
|
|
|
|
|
1428
|
|
|
|
|
|
|
$self->{Start_Todo}++; |
1429
|
|
|
|
|
|
|
if( $self->in_todo ) { |
1430
|
|
|
|
|
|
|
push @{ $self->{Todo_Stack} } => $self->todo; |
1431
|
|
|
|
|
|
|
} |
1432
|
|
|
|
|
|
|
$self->{Todo} = $message; |
1433
|
|
|
|
|
|
|
|
1434
|
|
|
|
|
|
|
return; |
1435
|
|
|
|
|
|
|
} |
1436
|
|
|
|
|
|
|
|
1437
|
|
|
|
|
|
|
#line 2265 |
1438
|
|
|
|
|
|
|
|
1439
|
|
|
|
|
|
|
sub todo_end { |
1440
|
|
|
|
|
|
|
my $self = shift; |
1441
|
|
|
|
|
|
|
|
1442
|
|
|
|
|
|
|
if( !$self->{Start_Todo} ) { |
1443
|
|
|
|
|
|
|
$self->croak('todo_end() called without todo_start()'); |
1444
|
|
|
|
|
|
|
} |
1445
|
|
|
|
|
|
|
|
1446
|
|
|
|
|
|
|
$self->{Start_Todo}--; |
1447
|
|
|
|
|
|
|
|
1448
|
|
|
|
|
|
|
if( $self->{Start_Todo} && @{ $self->{Todo_Stack} } ) { |
1449
|
|
|
|
|
|
|
$self->{Todo} = pop @{ $self->{Todo_Stack} }; |
1450
|
|
|
|
|
|
|
} |
1451
|
428
|
|
|
428
|
|
991
|
else { |
1452
|
|
|
|
|
|
|
delete $self->{Todo}; |
1453
|
428
|
|
|
|
|
463
|
} |
1454
|
|
|
|
|
|
|
|
1455
|
|
|
|
|
|
|
return; |
1456
|
428
|
|
|
|
|
580
|
} |
|
428
|
|
|
|
|
1283
|
|
1457
|
428
|
|
|
|
|
477
|
|
1458
|
428
|
|
|
|
|
1287
|
#line 2298 |
1459
|
428
|
|
|
|
|
619
|
|
|
428
|
|
|
|
|
712
|
|
1460
|
428
|
|
|
|
|
1540
|
sub caller { ## no critic (Subroutines::ProhibitBuiltinHomonyms) |
1461
|
|
|
|
|
|
|
my( $self, $height ) = @_; |
1462
|
|
|
|
|
|
|
$height ||= 0; |
1463
|
428
|
50
|
33
|
|
|
1030
|
|
1464
|
|
|
|
|
|
|
my $level = $self->level + $height + 1; |
1465
|
428
|
50
|
|
|
|
2193
|
my @caller; |
1466
|
|
|
|
|
|
|
do { |
1467
|
|
|
|
|
|
|
@caller = CORE::caller( $level ); |
1468
|
|
|
|
|
|
|
$level--; |
1469
|
|
|
|
|
|
|
} until @caller; |
1470
|
|
|
|
|
|
|
return wantarray ? @caller : $caller[0]; |
1471
|
|
|
|
|
|
|
} |
1472
|
|
|
|
|
|
|
|
1473
|
|
|
|
|
|
|
#line 2315 |
1474
|
|
|
|
|
|
|
|
1475
|
|
|
|
|
|
|
#line 2329 |
1476
|
|
|
|
|
|
|
|
1477
|
|
|
|
|
|
|
#'# |
1478
|
|
|
|
|
|
|
sub _sanity_check { |
1479
|
|
|
|
|
|
|
my $self = shift; |
1480
|
36
|
|
|
36
|
1
|
50
|
|
1481
|
36
|
|
|
|
|
44
|
$self->_whoa( $self->{Curr_Test} < 0, 'Says here you ran a negative number of tests!' ); |
1482
|
36
|
50
|
|
|
|
82
|
$self->_whoa( $self->{Curr_Test} != @{ $self->{Test_Results} }, |
1483
|
|
|
|
|
|
|
'Somehow you got a different number of results than tests ran!' ); |
1484
|
36
|
50
|
|
|
|
148
|
|
1485
|
0
|
0
|
|
|
|
0
|
return; |
1486
|
|
|
|
|
|
|
} |
1487
|
|
|
|
|
|
|
|
1488
|
0
|
|
0
|
|
|
0
|
#line 2350 |
1489
|
|
|
|
|
|
|
|
1490
|
|
|
|
|
|
|
sub _whoa { |
1491
|
|
|
|
|
|
|
my( $self, $check, $desc ) = @_; |
1492
|
|
|
|
|
|
|
if($check) { |
1493
|
|
|
|
|
|
|
local $Level = $Level + 1; |
1494
|
|
|
|
|
|
|
$self->croak(<<"WHOA"); |
1495
|
|
|
|
|
|
|
WHOA! $desc |
1496
|
|
|
|
|
|
|
This should never happen! Please contact the author immediately! |
1497
|
|
|
|
|
|
|
WHOA |
1498
|
|
|
|
|
|
|
} |
1499
|
|
|
|
|
|
|
|
1500
|
|
|
|
|
|
|
return; |
1501
|
|
|
|
|
|
|
} |
1502
|
|
|
|
|
|
|
|
1503
|
|
|
|
|
|
|
#line 2374 |
1504
|
|
|
|
|
|
|
|
1505
|
|
|
|
|
|
|
sub _my_exit { |
1506
|
|
|
|
|
|
|
$? = $_[0]; ## no critic (Variables::RequireLocalizedPunctuationVars) |
1507
|
|
|
|
|
|
|
|
1508
|
|
|
|
|
|
|
return 1; |
1509
|
|
|
|
|
|
|
} |
1510
|
|
|
|
|
|
|
|
1511
|
|
|
|
|
|
|
#line 2386 |
1512
|
|
|
|
|
|
|
|
1513
|
|
|
|
|
|
|
sub _ending { |
1514
|
|
|
|
|
|
|
my $self = shift; |
1515
|
|
|
|
|
|
|
return if $self->no_ending; |
1516
|
|
|
|
|
|
|
return if $self->{Ending}++; |
1517
|
|
|
|
|
|
|
|
1518
|
|
|
|
|
|
|
my $real_exit_code = $?; |
1519
|
|
|
|
|
|
|
|
1520
|
|
|
|
|
|
|
# Don't bother with an ending if this is a forked copy. Only the parent |
1521
|
|
|
|
|
|
|
# should do the ending. |
1522
|
|
|
|
|
|
|
if( $self->{Original_Pid} != $$ ) { |
1523
|
392
|
|
|
392
|
1
|
581
|
return; |
1524
|
|
|
|
|
|
|
} |
1525
|
392
|
50
|
|
|
|
835
|
|
1526
|
0
|
|
|
|
|
0
|
# Ran tests but never declared a plan or hit done_testing |
1527
|
|
|
|
|
|
|
if( !$self->{Have_Plan} and $self->{Curr_Test} ) { |
1528
|
392
|
|
|
|
|
749
|
$self->is_passing(0); |
1529
|
|
|
|
|
|
|
$self->diag("Tests were run but no plan was declared and done_testing() was not seen."); |
1530
|
|
|
|
|
|
|
} |
1531
|
|
|
|
|
|
|
|
1532
|
|
|
|
|
|
|
# Exit if plan() was never called. This is so "require Test::Simple" |
1533
|
|
|
|
|
|
|
# doesn't puke. |
1534
|
|
|
|
|
|
|
if( !$self->{Have_Plan} ) { |
1535
|
|
|
|
|
|
|
return; |
1536
|
|
|
|
|
|
|
} |
1537
|
|
|
|
|
|
|
|
1538
|
|
|
|
|
|
|
# Don't do an ending if we bailed out. |
1539
|
|
|
|
|
|
|
if( $self->{Bailed_Out} ) { |
1540
|
|
|
|
|
|
|
$self->is_passing(0); |
1541
|
|
|
|
|
|
|
return; |
1542
|
|
|
|
|
|
|
} |
1543
|
|
|
|
|
|
|
# Figure out if we passed or failed and print helpful messages. |
1544
|
|
|
|
|
|
|
my $test_results = $self->{Test_Results}; |
1545
|
|
|
|
|
|
|
if(@$test_results) { |
1546
|
|
|
|
|
|
|
# The plan? We have no plan. |
1547
|
|
|
|
|
|
|
if( $self->{No_Plan} ) { |
1548
|
|
|
|
|
|
|
$self->_output_plan($self->{Curr_Test}) unless $self->no_header; |
1549
|
|
|
|
|
|
|
$self->{Expected_Tests} = $self->{Curr_Test}; |
1550
|
|
|
|
|
|
|
} |
1551
|
|
|
|
|
|
|
|
1552
|
|
|
|
|
|
|
# Auto-extended arrays and elements which aren't explicitly |
1553
|
|
|
|
|
|
|
# filled in with a shared reference will puke under 5.8.0 |
1554
|
|
|
|
|
|
|
# ithreads. So we have to fill them in by hand. :( |
1555
|
74
|
|
|
74
|
1
|
109
|
my $empty_result = &share( {} ); |
1556
|
|
|
|
|
|
|
for my $idx ( 0 .. $self->{Expected_Tests} - 1 ) { |
1557
|
74
|
50
|
|
|
|
210
|
$test_results->[$idx] = $empty_result |
1558
|
0
|
|
|
|
|
0
|
unless defined $test_results->[$idx]; |
1559
|
|
|
|
|
|
|
} |
1560
|
74
|
|
|
|
|
300
|
|
1561
|
|
|
|
|
|
|
my $num_failed = grep !$_->{'ok'}, @{$test_results}[ 0 .. $self->{Curr_Test} - 1 ]; |
1562
|
|
|
|
|
|
|
|
1563
|
|
|
|
|
|
|
my $num_extra = $self->{Curr_Test} - $self->{Expected_Tests}; |
1564
|
|
|
|
|
|
|
|
1565
|
|
|
|
|
|
|
if( $num_extra != 0 ) { |
1566
|
|
|
|
|
|
|
my $s = $self->{Expected_Tests} == 1 ? '' : 's'; |
1567
|
|
|
|
|
|
|
$self->diag(<<"FAIL"); |
1568
|
|
|
|
|
|
|
Looks like you planned $self->{Expected_Tests} test$s but ran $self->{Curr_Test}. |
1569
|
|
|
|
|
|
|
FAIL |
1570
|
|
|
|
|
|
|
$self->is_passing(0); |
1571
|
|
|
|
|
|
|
} |
1572
|
|
|
|
|
|
|
|
1573
|
|
|
|
|
|
|
if($num_failed) { |
1574
|
|
|
|
|
|
|
my $num_tests = $self->{Curr_Test}; |
1575
|
|
|
|
|
|
|
my $s = $num_failed == 1 ? '' : 's'; |
1576
|
|
|
|
|
|
|
|
1577
|
|
|
|
|
|
|
my $qualifier = $num_extra == 0 ? '' : ' run'; |
1578
|
|
|
|
|
|
|
|
1579
|
|
|
|
|
|
|
$self->diag(<<"FAIL"); |
1580
|
|
|
|
|
|
|
Looks like you failed $num_failed test$s of $num_tests$qualifier. |
1581
|
|
|
|
|
|
|
FAIL |
1582
|
|
|
|
|
|
|
$self->is_passing(0); |
1583
|
|
|
|
|
|
|
} |
1584
|
|
|
|
|
|
|
|
1585
|
|
|
|
|
|
|
if($real_exit_code) { |
1586
|
|
|
|
|
|
|
$self->diag(<<"FAIL"); |
1587
|
|
|
|
|
|
|
Looks like your test exited with $real_exit_code just after $self->{Curr_Test}. |
1588
|
|
|
|
|
|
|
FAIL |
1589
|
|
|
|
|
|
|
$self->is_passing(0); |
1590
|
|
|
|
|
|
|
_my_exit($real_exit_code) && return; |
1591
|
58
|
|
|
58
|
|
82
|
} |
1592
|
|
|
|
|
|
|
|
1593
|
58
|
50
|
|
|
|
142
|
my $exit_code; |
1594
|
0
|
|
|
|
|
0
|
if($num_failed) { |
1595
|
|
|
|
|
|
|
$exit_code = $num_failed <= 254 ? $num_failed : 254; |
1596
|
58
|
|
|
|
|
213
|
} |
1597
|
|
|
|
|
|
|
elsif( $num_extra != 0 ) { |
1598
|
|
|
|
|
|
|
$exit_code = 255; |
1599
|
8
|
|
|
8
|
|
55
|
} |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
17862
|
|
1600
|
|
|
|
|
|
|
else { |
1601
|
|
|
|
|
|
|
$exit_code = 0; |
1602
|
|
|
|
|
|
|
} |
1603
|
|
|
|
|
|
|
|
1604
|
|
|
|
|
|
|
_my_exit($exit_code) && return; |
1605
|
|
|
|
|
|
|
} |
1606
|
|
|
|
|
|
|
elsif( $self->{Skip_All} ) { |
1607
|
|
|
|
|
|
|
_my_exit(0) && return; |
1608
|
|
|
|
|
|
|
} |
1609
|
|
|
|
|
|
|
elsif($real_exit_code) { |
1610
|
|
|
|
|
|
|
$self->diag(<<"FAIL"); |
1611
|
|
|
|
|
|
|
Looks like your test exited with $real_exit_code before it could output anything. |
1612
|
|
|
|
|
|
|
FAIL |
1613
|
|
|
|
|
|
|
$self->is_passing(0); |
1614
|
|
|
|
|
|
|
_my_exit($real_exit_code) && return; |
1615
|
|
|
|
|
|
|
} |
1616
|
|
|
|
|
|
|
else { |
1617
|
|
|
|
|
|
|
$self->diag("No tests run!\n"); |
1618
|
|
|
|
|
|
|
$self->is_passing(0); |
1619
|
|
|
|
|
|
|
_my_exit(255) && return; |
1620
|
|
|
|
|
|
|
} |
1621
|
|
|
|
|
|
|
|
1622
|
|
|
|
|
|
|
$self->is_passing(0); |
1623
|
|
|
|
|
|
|
$self->_whoa( 1, "We fell off the end of _ending()" ); |
1624
|
|
|
|
|
|
|
} |
1625
|
|
|
|
|
|
|
|
1626
|
|
|
|
|
|
|
END { |
1627
|
|
|
|
|
|
|
$Test->_ending if defined $Test; |
1628
|
|
|
|
|
|
|
} |
1629
|
|
|
|
|
|
|
|
1630
|
|
|
|
|
|
|
#line 2574 |
1631
|
|
|
|
|
|
|
|
1632
|
|
|
|
|
|
|
1; |
1633
|
|
|
|
|
|
|
|