line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sub::Spy::Result; |
2
|
5
|
|
|
5
|
|
25
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
157
|
|
3
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
149
|
|
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
4544
|
use List::MoreUtils qw/any/; |
|
5
|
|
|
|
|
7029
|
|
|
5
|
|
|
|
|
3410
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
22
|
|
|
22
|
0
|
65
|
my ($class, $param) = @_; |
10
|
22
|
|
|
|
|
125
|
return bless $param, $class; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub get_call { |
14
|
0
|
|
|
0
|
0
|
0
|
my ($self, $n) = @_; |
15
|
0
|
|
|
|
|
0
|
$self->{calls}->[$n]; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# count |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub call_count { |
22
|
11
|
|
|
11
|
0
|
15
|
return scalar @{shift->{calls}}; |
|
11
|
|
|
|
|
72
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub called { |
26
|
1
|
50
|
|
1
|
0
|
3
|
return (shift->call_count > 0) ? 1 : 0; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub called_times { |
30
|
8
|
|
|
8
|
0
|
12
|
my ($self, $times) = @_; |
31
|
8
|
100
|
|
|
|
28
|
return ($self->call_count == $times) ? 1 : 0; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub called_once { |
35
|
2
|
|
|
2
|
0
|
6
|
return shift->called_times(1); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub called_twice { |
39
|
2
|
|
|
2
|
0
|
6
|
return shift->called_times(2); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub called_thrice { |
43
|
2
|
|
|
2
|
0
|
6
|
return shift->called_times(3); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# args |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub args { |
50
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
51
|
0
|
|
|
|
|
0
|
return [map { $_->args } @{$self->{calls}}]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub get_args { |
55
|
0
|
|
|
0
|
0
|
0
|
my ($self, $n) = @_; |
56
|
0
|
0
|
|
|
|
0
|
die "try to get arguments of not-yet-called call." if $n >= scalar @{$self->{calls}}; |
|
0
|
|
|
|
|
0
|
|
57
|
0
|
|
|
|
|
0
|
return $self->args->[$n]; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# exception |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub exceptions { |
64
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
65
|
0
|
|
|
|
|
0
|
return [map { $_->exception } @{$self->{calls}}]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub get_exception { |
69
|
0
|
|
|
0
|
0
|
0
|
my ($self, $n) = @_; |
70
|
0
|
0
|
|
|
|
0
|
die "try to get exception of not-yet-called call." if $n >= scalar @{$self->{calls}}; |
|
0
|
|
|
|
|
0
|
|
71
|
0
|
|
|
|
|
0
|
return $self->exceptions->[$n]; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub threw { |
75
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
76
|
0
|
0
|
|
0
|
|
0
|
return ( any { defined($_) } @{$self->exceptions} ) ? 1 : 0; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# return |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub return_values { |
83
|
11
|
|
|
11
|
0
|
12
|
my $self = shift; |
84
|
11
|
|
|
|
|
13
|
return [map { $_->return_value } @{$self->{calls}}]; |
|
13
|
|
|
|
|
54
|
|
|
11
|
|
|
|
|
25
|
|
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub get_return_value { |
88
|
5
|
|
|
5
|
0
|
10
|
my ($self, $n) = @_; |
89
|
5
|
50
|
|
|
|
7
|
die "try to get return value of not-yet-called call." if $n >= scalar @{$self->{calls}}; |
|
5
|
|
|
|
|
20
|
|
90
|
5
|
|
|
|
|
11
|
return $self->return_values->[$n]; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |