| 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
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table33%1/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||||||||||
| 18 | 5 | my ($rt, $numDims, $weight) = @_; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 5 | ▶ | my %state = (weight => $weight || 1, | ||||||||||||||||||||||||||
|
Condition50%1/2
$weight || 1
MC/DC0%0/1
$weight || 1
$weight
Truth table50%1/2
A
A= $weight
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 34 | 10 | ▶ | if (scalar(@{$opts{coords}}) != $self->{rt}->{numDims}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | croak("Expected $self->{numDims} coordinates, but ".scalar(@{$opts{coords}})." given"); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 10 | ▶ | if (defined($self->{lastTime}) && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"lastTime"} and $time < $self->{"lastTime"}
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"}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||