Spy/Interface.pm

filter: Statementstmt 100% 48 / 48 Branchbran 100% 4 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 16 / 16 Podpod 0.0% 0 / 9 totaltotal 86.2% 69 / 80 CC 4 SCAR 2.8
CC
4
Cov
98%
_increment_call_iterator
2.0
next_called_with
2.0
was_called
2.0
CRAP 1.3
« Spy/Method.pm ↑ Summary Spy/Observer.pm »
1 package Test::Spy::Interface;
2 7 $Test::Spy::Interface::VERSION = '0.005';
3 7 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 7 ▶use Mooish::AttributeBuilder -standard;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 7 requires qw(
11 call_history
12 _clear_call_history
13 );
14  
15 has field '_call_iterator' => (
16 writer => 1,
17 clearer => 1,
18 predicate => 1,
19 5 ▶ lazy => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
20 7 );
21  
22 sub _increment_call_iterator
23 7 ▶{
Subroutine _increment_call_iterator: called CC=2 SCAR=7.0
24 7 my ($self, $count) = @_;
25 7 ▶ $count //= 1;
Condition50%1/2
$count //= 1
l!l
07
MC/DC0%0/1
$count //= 1
$count
Truth table50%1/2
A
A= $count
Aresult
11
00
26  
27 7 $self->_set_call_iterator($self->_call_iterator + $count);
28  
29 7 return;
30 }
31  
32 sub called_times
33 26 ▶{
Subroutine called_times: called CC=1 SCAR=0.0
Pod undocumented
34 26 my ($self) = @_;
35  
36 26 return scalar @{$self->call_history};
37 }
38  
39 sub called_with
40 16 ▶{
Subroutine called_with: called CC=1 SCAR=0.0
Pod undocumented
41 16 my ($self) = @_;
42  
43 16 return $self->call_history->[$self->_call_iterator];
44 }
45  
46 sub first_called_with
47 1 ▶{
Subroutine first_called_with: called CC=1 SCAR=0.0
Pod undocumented
48 1 my ($self) = @_;
49  
50 1 $self->_set_call_iterator(0);
51 1 return $self->called_with;
52 }
53  
54 sub next_called_with
55 9 ▶{
Subroutine next_called_with: called CC=2 SCAR=6.9
Pod undocumented
56 9 my ($self) = @_;
57  
58 9 ▶ $self->_increment_call_iterator
Branch: 1 branch
BranchTrueFalseTotal
if $self->_has_call_iterator 7 2 9
59 if $self->_has_call_iterator;
60  
61 9 return $self->called_with;
62 }
63  
64 sub last_called_with
65 2 ▶{
Subroutine last_called_with: called CC=1 SCAR=0.0
Pod undocumented
66 2 my ($self) = @_;
67  
68 2 $self->_set_call_iterator($self->called_times - 1);
69 2 return $self->called_with;
70 }
71  
72 sub was_called
73 22 ▶{
Subroutine was_called: called CC=2 SCAR=6.9
Pod undocumented
74 22 my ($self, $times) = @_;
75  
76 22 ▶ return $self->called_times == $times if defined $times;
Branch: 1 branch
BranchTrueFalseTotal
if defined $times 19 3 22
77 3 return $self->called_times > 0;
78 }
79  
80 sub wasnt_called
81 3 ▶{
Subroutine wasnt_called: called CC=1 SCAR=0.0
Pod undocumented
82 3 my ($self) = @_;
83  
84 3 return $self->was_called(0);
85 }
86  
87 sub was_called_once
88 5 ▶{
Subroutine was_called_once: called CC=1 SCAR=0.0
Pod undocumented
89 5 my ($self) = @_;
90  
91 5 return $self->was_called(1);
92 }
93  
94 sub clear
95 14 ▶{
Subroutine clear: called CC=1 SCAR=0.0
Pod undocumented
96 14 my ($self) = @_;
97  
98 14 $self->_clear_call_history;
99 14 $self->_clear_call_iterator;
100  
101 14 return $self;
102 }
103  
104 7 1;
105  
« Spy/Method.pm ↑ Summary Spy/Observer.pm »