line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
$Test::Spy::Object::VERSION = '0.005'; |
2
|
|
|
|
|
|
|
use v5.10; |
3
|
7
|
|
|
7
|
|
77
|
use strict; |
|
7
|
|
|
|
|
21
|
|
4
|
7
|
|
|
7
|
|
30
|
use warnings; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
121
|
|
5
|
7
|
|
|
7
|
|
24
|
|
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
211
|
|
6
|
|
|
|
|
|
|
use Carp qw(croak carp); |
7
|
7
|
|
|
7
|
|
30
|
|
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
4832
|
|
8
|
|
|
|
|
|
|
our $AUTOLOAD; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
{ |
11
|
|
|
|
|
|
|
my ($self, $name) = @_; |
12
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
0
|
141
|
my $could = $self->SUPER::can($name); |
14
|
|
|
|
|
|
|
return $could if $could; |
15
|
6
|
|
|
|
|
37
|
|
16
|
6
|
50
|
|
|
|
21
|
return undef |
17
|
|
|
|
|
|
|
unless $self->{__spy}->_mocked_subs->{$name} |
18
|
|
|
|
|
|
|
|| ($self->{__base} && $self->{__base}->can($name)); |
19
|
|
|
|
|
|
|
|
20
|
6
|
100
|
100
|
|
|
87
|
return sub { shift->$name(@_) }; |
|
|
|
100
|
|
|
|
|
21
|
|
|
|
|
|
|
} |
22
|
3
|
|
|
0
|
|
15
|
|
|
0
|
|
|
|
|
0
|
|
23
|
|
|
|
|
|
|
{ |
24
|
|
|
|
|
|
|
my ($self, $name) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
return !!1 |
27
|
5
|
|
|
5
|
0
|
785
|
if $self->SUPER::isa($name); |
28
|
|
|
|
|
|
|
|
29
|
5
|
50
|
|
|
|
31
|
return !!1 |
30
|
|
|
|
|
|
|
if $self->{__base} && $self->{__base}->isa($name); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return $self->__imitates($name); |
33
|
5
|
100
|
100
|
|
|
32
|
} |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
|
|
10
|
{ |
36
|
|
|
|
|
|
|
my ($self, $name) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return !!1 |
39
|
|
|
|
|
|
|
if $self->{__base} && $self->{__base}->does($name); |
40
|
3
|
|
|
3
|
0
|
1055
|
|
41
|
|
|
|
|
|
|
return $self->__imitates($name); |
42
|
|
|
|
|
|
|
} |
43
|
3
|
50
|
33
|
|
|
9
|
|
44
|
|
|
|
|
|
|
{ |
45
|
3
|
|
|
|
|
6
|
my ($self, $name) = @_; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
return !!1 |
48
|
|
|
|
|
|
|
if $self->{__base} && $self->{__base}->DOES($name); |
49
|
|
|
|
|
|
|
|
50
|
5
|
|
|
5
|
0
|
11
|
return $self->__imitates($name); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
5
|
100
|
100
|
|
|
22
|
{ |
54
|
|
|
|
|
|
|
my ($self, @args) = @_; |
55
|
4
|
|
|
|
|
46
|
|
56
|
|
|
|
|
|
|
my $method = $AUTOLOAD; |
57
|
|
|
|
|
|
|
$method =~ s/.*://; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
if (my $method = $self->{__spy}->_mocked_subs->{$method}) { |
60
|
45
|
|
|
45
|
|
3720
|
# note: immediate return not to force any context |
61
|
|
|
|
|
|
|
if ($method->isa('Test::Spy::Method')) { |
62
|
45
|
|
|
|
|
66
|
return $method->_called($self, @args); |
63
|
45
|
|
|
|
|
153
|
} |
64
|
|
|
|
|
|
|
else { |
65
|
45
|
100
|
|
|
|
165
|
$method->_called($self, @args); |
66
|
|
|
|
|
|
|
} |
67
|
37
|
100
|
|
|
|
121
|
} |
68
|
35
|
|
|
|
|
99
|
|
69
|
|
|
|
|
|
|
if ($self->{__base} && (my $sref = $self->{__base}->can($method))) { |
70
|
|
|
|
|
|
|
return $sref->($self, @args); |
71
|
2
|
|
|
|
|
8
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $interface = $self->{__spy}->interface; |
74
|
|
|
|
|
|
|
|
75
|
10
|
100
|
66
|
|
|
50
|
croak "No such method $method on Test::Spy->object" |
76
|
7
|
|
|
|
|
23
|
if $interface eq 'strict'; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
carp "method '$1' was called on Test::Spy->object" |
79
|
3
|
|
|
|
|
7
|
if $interface eq 'warn'; |
80
|
|
|
|
|
|
|
|
81
|
3
|
100
|
|
|
|
133
|
return undef; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
2
|
100
|
|
|
|
31
|
{ |
85
|
|
|
|
|
|
|
my ($self, $name) = @_; |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
17
|
if ($self->{__spy}->has_imitates) { |
88
|
|
|
|
|
|
|
my @imitates = $self->{__spy}->imitates; |
89
|
|
|
|
|
|
|
@imitates = @{$imitates[0]} |
90
|
|
|
|
|
|
|
if ref $imitates[0] eq 'ARRAY'; |
91
|
|
|
|
|
|
|
|
92
|
11
|
|
|
11
|
|
18
|
foreach my $type (@imitates) { |
93
|
|
|
|
|
|
|
return !!1 if $type eq $name; |
94
|
11
|
100
|
|
|
|
34
|
} |
95
|
9
|
|
|
|
|
18
|
} |
96
|
9
|
100
|
|
|
|
23
|
|
|
6
|
|
|
|
|
13
|
|
97
|
|
|
|
|
|
|
return !!0; |
98
|
|
|
|
|
|
|
} |
99
|
9
|
|
|
|
|
12
|
|
100
|
12
|
100
|
|
|
|
48
|
{ |
101
|
|
|
|
|
|
|
my ($class, %params) = @_; |
102
|
|
|
|
|
|
|
my $self = \%params; |
103
|
|
|
|
|
|
|
|
104
|
2
|
|
|
|
|
8
|
return bless $self, $class; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
{ |
108
|
|
|
|
|
|
|
} |
109
|
25
|
|
|
25
|
|
86
|
|
110
|
25
|
|
|
|
|
45
|
1; |
111
|
|
|
|
|
|
|
|