line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Carp; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
98883
|
use strict; |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
133
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
720
|
|
5
|
3
|
|
|
3
|
|
40
|
use Carp; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
1643
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$Test::Carp::VERSION = '0.2'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Prototype mismatch: sub Test::Carp::_ok: none vs ($;$) at .../Test/Carp.pm line ... |
10
|
|
|
|
|
|
|
# perl -MTest::More -e 'print prototype("Test::More::ok");' |
11
|
|
|
|
|
|
|
# sub _ok($;$) { |
12
|
|
|
|
|
|
|
sub _ok { |
13
|
22
|
|
|
22
|
|
123
|
require Test::More; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# no warnings 'redefine'; |
16
|
|
|
|
|
|
|
# *_ok = \&Test::More::ok; # make subsequent calls not do all of this ferdiddling |
17
|
22
|
|
|
|
|
70
|
goto &Test::More::ok; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub import { |
21
|
6
|
|
|
6
|
|
33182
|
my $caller = caller(); |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
3
|
|
18057
|
use Data::Dumper; |
|
3
|
|
|
|
|
78568
|
|
|
3
|
|
|
|
|
1461
|
|
24
|
6
|
100
|
|
|
|
35
|
if ( ref( $_[1] ) eq 'CODE' ) { |
25
|
3
|
|
|
3
|
|
29
|
no warnings 'redefine'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
184
|
|
26
|
2
|
|
|
|
|
13
|
*_ok = $_[1]; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
3
|
|
15
|
no strict 'refs'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
472
|
|
30
|
6
|
|
|
|
|
17
|
for my $func (qw( |
31
|
|
|
|
|
|
|
does_carp does_cluck |
32
|
|
|
|
|
|
|
does_croak does_confess |
33
|
|
|
|
|
|
|
does_carp_that_matches does_cluck_that_matches |
34
|
|
|
|
|
|
|
does_croak_that_matches does_confess_that_matches |
35
|
|
|
|
|
|
|
)) { |
36
|
48
|
|
|
|
|
53
|
*{ $caller . "::$func" } = *{$func}; |
|
48
|
|
|
|
|
271
|
|
|
48
|
|
|
|
|
176
|
|
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _does { |
41
|
6
|
|
|
6
|
|
15
|
my $caller = caller(); |
42
|
6
|
|
|
|
|
11
|
my $func = shift; |
43
|
6
|
|
|
|
|
14
|
my $code = shift; |
44
|
|
|
|
|
|
|
|
45
|
3
|
|
|
3
|
|
15
|
no strict 'refs'; |
|
3
|
|
|
|
|
28
|
|
|
3
|
|
|
|
|
206
|
|
46
|
6
|
|
|
|
|
10
|
my ( $carp_orig, $caller_orig ) = ( \&{"Carp::$func"}, \&{"${caller}::$func"} ); |
|
6
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
23
|
|
47
|
|
|
|
|
|
|
|
48
|
3
|
|
|
3
|
|
15
|
no warnings 'redefine'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
2420
|
|
49
|
6
|
|
|
|
|
11
|
my $called = 0; |
50
|
|
|
|
|
|
|
|
51
|
6
|
|
|
|
|
21
|
*{"Carp::$func"} = sub { |
52
|
4
|
50
|
|
4
|
|
35
|
return if $called++; |
53
|
4
|
|
|
|
|
25
|
_ok( 1, "$func() was called (@_)" ); |
54
|
4
|
100
|
66
|
|
|
1837
|
if ( $func eq 'croak' || $func eq 'confess' ) { |
55
|
2
|
|
|
|
|
5
|
local $Carp::CarpLevel = $Carp::CarpLevel + 2; |
56
|
2
|
|
|
|
|
386
|
$carp_orig->( $_[0] ); |
57
|
|
|
|
|
|
|
} |
58
|
6
|
|
|
|
|
29
|
}; |
59
|
6
|
|
|
|
|
11
|
*{"${caller}::$func"} = \&{"Carp::$func"}; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
17
|
|
60
|
|
|
|
|
|
|
|
61
|
6
|
100
|
66
|
|
|
49
|
( $func eq 'croak' || $func eq 'confess' ) ? eval { $code->(@_) } : $code->(@_); |
|
2
|
|
|
|
|
8
|
|
62
|
6
|
100
|
|
|
|
53
|
_ok( 0, "$func() was called" ) if !$called; |
63
|
|
|
|
|
|
|
|
64
|
6
|
|
|
|
|
925
|
*{"Carp::$func"} = $carp_orig; |
|
6
|
|
|
|
|
37
|
|
65
|
6
|
|
|
|
|
7
|
*{"${caller}::$func"} = $caller_orig; |
|
6
|
|
|
|
|
50
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub does_carp { |
69
|
4
|
|
|
4
|
1
|
356
|
unshift @_, 'carp'; |
70
|
4
|
|
|
|
|
18
|
goto &_does; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub does_cluck { |
74
|
0
|
|
|
0
|
1
|
0
|
unshift @_, 'cluck'; |
75
|
0
|
|
|
|
|
0
|
goto &_does; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub does_croak { |
79
|
2
|
|
|
2
|
1
|
21
|
unshift @_, 'croak'; |
80
|
2
|
|
|
|
|
10
|
goto &_does; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub does_confess { |
84
|
0
|
|
|
0
|
1
|
0
|
unshift @_, 'confess'; |
85
|
0
|
|
|
|
|
0
|
goto &_does; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _does_and_matches { |
89
|
27
|
|
|
27
|
|
76
|
my $caller = caller(); |
90
|
|
|
|
|
|
|
|
91
|
27
|
|
|
|
|
39
|
my $func = shift; |
92
|
27
|
|
|
|
|
36
|
my $code = shift; |
93
|
27
|
|
|
|
|
45
|
my $match = pop; |
94
|
|
|
|
|
|
|
|
95
|
3
|
|
|
3
|
|
19
|
no strict 'refs'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
235
|
|
96
|
27
|
|
|
|
|
32
|
my ( $carp_orig, $caller_orig ) = ( \&{"Carp::$func"}, \&{"${caller}::$func"} ); |
|
27
|
|
|
|
|
63
|
|
|
27
|
|
|
|
|
63
|
|
97
|
|
|
|
|
|
|
|
98
|
3
|
|
|
3
|
|
30
|
no warnings 'redefine'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
4239
|
|
99
|
27
|
|
|
|
|
40
|
my $called = 0; |
100
|
|
|
|
|
|
|
|
101
|
27
|
100
|
|
|
|
83
|
if ( !defined $match ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
102
|
9
|
|
|
|
|
11
|
$match = 'undef()'; # so you don't get "Use of uninitialized value" when used in the test name during |
103
|
|
|
|
|
|
|
# t/02.functions.t oddity (look for 'to test that these are working we need to reverse ok()') |
104
|
9
|
|
|
|
|
24
|
*{"Carp::$func"} = sub { |
105
|
6
|
50
|
66
|
6
|
|
33
|
return if @_ && grep { defined $_ } @_; |
|
4
|
|
|
|
|
33
|
|
106
|
6
|
50
|
|
|
|
13
|
return if $called++; |
107
|
6
|
|
|
|
|
22
|
_ok( 1, "$func() was called w/ undefined argument" ); |
108
|
6
|
100
|
66
|
|
|
2161
|
if ( $func eq 'croak' || $func eq 'confess' ) { |
109
|
3
|
|
|
|
|
7
|
local $Carp::CarpLevel = $Carp::CarpLevel + 2; |
110
|
3
|
|
|
|
|
477
|
$carp_orig->(); # do not pass @_ or you get: Use of uninitialized value in join or string at .../Carp/Heavy.pm at line ... |
111
|
|
|
|
|
|
|
} |
112
|
9
|
|
|
|
|
34
|
}; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
elsif ( $match eq '' ) { |
115
|
6
|
|
|
|
|
17
|
*{"Carp::$func"} = sub { |
116
|
4
|
50
|
|
4
|
|
56
|
return if "@_" ne ''; |
117
|
4
|
50
|
|
|
|
12
|
return if $called++; |
118
|
4
|
|
|
|
|
15
|
_ok( 1, "$func() was called w/ empty string argument" ); |
119
|
4
|
100
|
66
|
|
|
1417
|
if ( $func eq 'croak' || $func eq 'confess' ) { |
120
|
2
|
|
|
|
|
4
|
local $Carp::CarpLevel = $Carp::CarpLevel + 2; |
121
|
2
|
|
|
|
|
311
|
$carp_orig->(@_); |
122
|
|
|
|
|
|
|
} |
123
|
6
|
|
|
|
|
25
|
}; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
elsif ( ref($match) eq 'Regexp' ) { |
126
|
6
|
|
|
|
|
19
|
*{"Carp::$func"} = sub { |
127
|
4
|
50
|
|
4
|
|
56
|
return if "@_" !~ $match; |
128
|
4
|
50
|
|
|
|
22
|
return if $called++; |
129
|
4
|
|
|
|
|
25
|
_ok( 1, "$func() was called (w/ '@_') and matches '$match'" ); |
130
|
4
|
100
|
66
|
|
|
1484
|
if ( $func eq 'croak' || $func eq 'confess' ) { |
131
|
2
|
|
|
|
|
4
|
local $Carp::CarpLevel = $Carp::CarpLevel + 2; |
132
|
2
|
|
|
|
|
290
|
$carp_orig->(@_); |
133
|
|
|
|
|
|
|
} |
134
|
6
|
|
|
|
|
27
|
}; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
else { |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# On some odd setups qr() is not available |
139
|
6
|
50
|
|
|
|
10
|
if ( eval { $match = qr/$match/; ref($match) eq 'Regexp' ? 1 : 0 } ) { |
|
6
|
50
|
|
|
|
114
|
|
|
6
|
|
|
|
|
36
|
|
140
|
6
|
|
|
|
|
23
|
*{"Carp::$func"} = sub { |
141
|
4
|
50
|
|
4
|
|
47
|
return if "@_" !~ $match; |
142
|
4
|
50
|
|
|
|
11
|
return if $called++; |
143
|
4
|
|
|
|
|
29
|
_ok( 1, "$func() was called (w/ '@_') and matches '$match'" ); |
144
|
4
|
100
|
66
|
|
|
1788
|
if ( $func eq 'croak' || $func eq 'confess' ) { |
145
|
2
|
|
|
|
|
5
|
local $Carp::CarpLevel = $Carp::CarpLevel + 2; |
146
|
2
|
|
|
|
|
291
|
$carp_orig->(@_); |
147
|
|
|
|
|
|
|
} |
148
|
6
|
|
|
|
|
56
|
}; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
else { |
151
|
0
|
|
|
|
|
0
|
$match = quotemeta($match); # use this instead of \Q\E so that it will be escaped in the test label |
152
|
0
|
|
|
|
|
0
|
*{"Carp::$func"} = sub { |
153
|
0
|
0
|
|
0
|
|
0
|
return if "@_" !~ m/$match/; |
154
|
0
|
0
|
|
|
|
0
|
return if $called++; |
155
|
0
|
|
|
|
|
0
|
_ok( 1, "$func() was called (w/ '@_') and matches '$match'" ); |
156
|
0
|
0
|
0
|
|
|
0
|
if ( $func eq 'croak' || $func eq 'confess' ) { |
157
|
0
|
|
|
|
|
0
|
local $Carp::CarpLevel = $Carp::CarpLevel + 2; |
158
|
0
|
|
|
|
|
0
|
$carp_orig->(@_); |
159
|
|
|
|
|
|
|
} |
160
|
0
|
|
|
|
|
0
|
}; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
} |
163
|
27
|
|
|
|
|
32
|
*{"${caller}::$func"} = *{"Carp::$func"}; |
|
27
|
|
|
|
|
89
|
|
|
27
|
|
|
|
|
55
|
|
164
|
|
|
|
|
|
|
|
165
|
27
|
100
|
66
|
|
|
143
|
( $func eq 'croak' || $func eq 'confess' ) ? eval { $code->(@_) } : $code->(@_); |
|
9
|
|
|
|
|
27
|
|
166
|
27
|
100
|
|
|
|
252
|
_ok( 0, "$func() was called and matches '$match'" ) if !$called; |
167
|
|
|
|
|
|
|
|
168
|
27
|
|
|
|
|
6155
|
*{"Carp::$func"} = $carp_orig; |
|
27
|
|
|
|
|
234
|
|
169
|
27
|
|
|
|
|
29
|
*{"${caller}::$func"} = $caller_orig; |
|
27
|
|
|
|
|
265
|
|
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub does_carp_that_matches { |
173
|
18
|
|
|
18
|
1
|
159
|
unshift @_, 'carp'; |
174
|
18
|
|
|
|
|
54
|
goto &_does_and_matches; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub does_cluck_that_matches { |
178
|
0
|
|
|
0
|
1
|
0
|
unshift @_, 'cluck'; |
179
|
0
|
|
|
|
|
0
|
goto &_does_and_matches; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub does_croak_that_matches { |
183
|
9
|
|
|
9
|
1
|
64
|
unshift @_, 'croak'; |
184
|
9
|
|
|
|
|
24
|
goto &_does_and_matches; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub does_confess_that_matches { |
188
|
0
|
|
|
0
|
1
|
|
unshift @_, 'confess'; |
189
|
0
|
|
|
|
|
|
goto &_does_and_matches; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
1; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
__END__ |