RunningTotal/Item.pm

filter: Statementstmt 88.2% 30 / 34 Branchbran 62.5% 5 / 8 Conditioncond 37.5% 3 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 69.8% 44 / 63 CC 8 SCAR 15.1
CC
8
Cov
76%
moveTo
7.5
new
3.2
BEGIN
1.0
CRAP 4.5
« RunningTotal.pm ↑ Summary
1 package Data::RunningTotal::Item;
2  
3 1 ▶use 5.005;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 require Exporter;
9  
10 1 our @ISA = qw(Exporter);
11  
12 1 our $VERSION = '0.03';
13  
14  
15 5 ▶sub new {
Subroutine new: called CC=3 SCAR=11.8
Pod undocumented
16 5 my $that = shift;
17 5 ▶ my $class = ref($that) || $that;
Condition33%1/3
ref $that || $that
l!l&&r!l&&!r
050
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table33%1/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
18 5 my ($rt, $numDims, $weight) = @_;
19  
20 5 ▶ my %state = (weight => $weight || 1,
Condition50%1/2
$weight || 1
l!l
50
MC/DC0%0/1
$weight || 1
$weight
Truth table50%1/2
A
A= $weight
Aresult
11
00
21 numDims => $numDims,
22 rt => $rt
23 );
24  
25 5 return bless(\%state);
26  
27 }
28  
29  
30 10 ▶sub moveTo {
Subroutine moveTo: called CC=6 SCAR=20.1
Pod undocumented
31 10 my ($self, $time, %opts) = @_;
32  
33 10 ▶ croak("Expected an array ref for parameter 'coords'") if (ref($opts{coords}) ne "ARRAY");
Branch: 1 branch
BranchTrueFalseTotal
if ref $opts{"coords"} ne "ARRAY" 0 10 10
34 10 ▶ if (scalar(@{$opts{coords}}) != $self->{rt}->{numDims}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$opts{"coords"};} != $self->{"rt"}{"numDims"}) 0 10 10
35 0 croak("Expected $self->{numDims} coordinates, but ".scalar(@{$opts{coords}})." given");
36 }
37  
38 10 ▶ if (defined($self->{lastTime}) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"lastTime"} and $time < $self->{"lastTime"}) 0 10 10
Condition33%1/3
defined $self->{"lastTime"} and $time < $self->{"lastTime"}
!ll&&!rl&&r
1000
MC/DC0%0/2
defined $self->{"lastTime"} and $time < $self->{"lastTime"}
defined $self->{"lastTime"} $time < $self->{"lastTime"}
Truth table33%1/3
A and B
A= defined $self->{"lastTime"}B= $time < $self->{"lastTime"}
ABresult
0X0
100
111
39 $time < $self->{lastTime}) {
40 0 carp("Item can't be moved to time in the past. Previous time moved: $self->{lastTime}. Current movement time: $time");
41 0 return;
42 }
43  
44 10 ▶ if (defined($self->{lastCoords})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"lastCoords"}) 5 5 10
45 5 $self->{rt}->dec($time, weight => $self->{weight}, coords => $self->{lastCoords});
46 }
47  
48 10 @{$self->{lastCoords}} = @{$opts{coords}};
49  
50 10 $self->{rt}->inc($time, weight => $self->{weight}, coords => $self->{lastCoords});
51  
52 }
53  
54 __END__
« RunningTotal.pm ↑ Summary