line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Unit::Assertion::CodeRef; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
71
|
|
4
|
2
|
|
|
2
|
|
9
|
use base qw/Test::Unit::Assertion/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1420
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
126
|
|
7
|
2
|
|
|
2
|
|
11
|
use Test::Unit::Debug qw(debug); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
851
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $deparser; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
31
|
|
|
31
|
1
|
118
|
my $class = shift; |
13
|
31
|
|
|
|
|
43
|
my $code = shift; |
14
|
31
|
50
|
|
|
|
91
|
croak "$class\::new needs a CODEREF" unless ref($code) eq 'CODE'; |
15
|
31
|
|
|
|
|
140
|
bless \$code => $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub do_assertion { |
19
|
195
|
|
|
195
|
1
|
380
|
my $self = shift; |
20
|
195
|
|
|
|
|
401
|
my $possible_object = $_[0]; |
21
|
195
|
|
100
|
|
|
1461
|
debug("Called do_assertion(" . ($possible_object || 'undef') . ")\n"); |
22
|
195
|
100
|
100
|
|
|
1002
|
if (ref($possible_object) and |
|
|
|
100
|
|
|
|
|
23
|
|
|
|
|
|
|
ref($possible_object) ne 'Regexp' and |
24
|
8
|
|
|
|
|
90
|
eval { $possible_object->isa('UNIVERSAL') }) |
25
|
|
|
|
|
|
|
{ |
26
|
2
|
|
|
|
|
12
|
debug(" [$possible_object] isa [" . ref($possible_object) . "]\n"); |
27
|
2
|
|
|
|
|
13
|
$possible_object->$$self(@_[1..$#_]); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
400
|
100
|
|
|
|
3635
|
debug(" asserting [$self]" |
31
|
193
|
100
|
|
|
|
1213
|
. (@_ ? " on args " . join(', ', map { $_ || '' } @_) : '') |
32
|
|
|
|
|
|
|
. "\n"); |
33
|
193
|
|
|
|
|
1898
|
$$self->(@_); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub to_string { |
38
|
199
|
|
|
199
|
0
|
365
|
my $self = shift; |
39
|
199
|
50
|
|
|
|
29404
|
if (eval "require B::Deparse") { |
40
|
199
|
|
66
|
|
|
775
|
$deparser ||= B::Deparse->new("-p"); |
41
|
199
|
|
|
|
|
1520446
|
return join '', "sub ", $deparser->coderef2text($$self); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else { |
44
|
0
|
|
|
|
|
|
return "sub { |
45
|
|
|
|
|
|
|
# If you had a working B::Deparse, you'd know what was in |
46
|
|
|
|
|
|
|
# this subroutine. |
47
|
|
|
|
|
|
|
}"; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
__END__ |