Backgammon/Move.pm

filter: Statementstmt 95.6% 22 / 23 Branchbran 100% 10 / 10 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 3 / 3 Subroutinesub 87.5% 7 / 8 Podpod 100% 5 / 5 totaltotal 96.3% 53 / 55 CC 8 SCAR 10.3
CC
8
Cov
97%
same_as
5.0
is_bar
2.0
is_off
2.0
CRAP 2.8
« Backgammon/Board.pm ↑ Summary Backgammon/Shots.pm »
1 package Game::Backgammon::Move;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 ▶use Object::Proto::Sugar -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 our $VERSION = '0.04';
9  
10 has player => (
11 is => 'ro',
12 isa => Str
13 11 );
14  
15 has [qw/from to/] => (
16 is => 'ro',
17 isa => Str
18 11 );
19  
20 has die => (
21 is => 'ro',
22 isa => Int
23 11 );
24  
25 has hit => (
26 is => 'ro',
27 isa => Bool,
28 default => 0
29 11 );
30  
31 2246122 ▶sub is_bar { $_[0]->from eq 'bar' ? 1 : 0 }
Subroutine is_bar: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->from eq 'bar' ? : 97836 2148286 2246122
32 2246123 ▶sub is_off { $_[0]->to eq 'off' ? 1 : 0 }
Subroutine is_off: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->to eq 'off' ? : 9251 2236872 2246123
33  
34 8058213 ▶sub notation {
Subroutine notation: called CC=2 SCAR=6.9
Pod documented
35 8058213 my ($self) = @_;
36 8058213 ▶ return $self->from . '/' . $self->to . ($self->hit ? '*' : '');
Branch: 1 branch
BranchTrueFalseTotal
$self->hit ? : 683935 7374278 8058213
37 }
38  
39 107457 ▶sub same_as {
Subroutine same_as: called CC=5 SCAR=16.1
Pod documented
40 107457 my ($self, $other) = @_;
41 107457 ▶ return 0 unless $other;
Branch: 1 branch
BranchTrueFalseTotal
unless $other 46584 60873 107457
42 60873 ▶ return ($self->from eq $other->from
Branch: 1 branch
BranchTrueFalseTotal
$self->from eq $other->from && $self->to eq $other->to && $self->hit == $other->hit ? : 1320 59553 60873
Condition100%6/6
$self->from eq $other->from and $self->to eq $other->to and $self->hit == $other->hit
!ll&&!rl&&r
594531001320
$self->from eq $other->from and $self->to eq $other->to
!ll&&!rl&&r
5691625371420
MC/DC100%3/3
$self->from eq $other->from and $self->to eq $other->to and $self->hit == $other->hit
$self->from eq $other->from $self->to eq $other->to $self->hit == $other->hit
Truth table100%4/4
A and B and C
A= $self->from eq $other->fromB= $self->to eq $other->toC= $self->hit == $other->hit
ABCresult
0XX0
10X0
1100
1111
43 && $self->to eq $other->to
44 && $self->hit == $other->hit) ? 1 : 0;
45 }
46  
47 0 ▶sub stringify {
Subroutine stringify: not called CC=1 SCAR=6.9
Pod documented
48 0 return $_[0]->notation;
49 }
50  
51 11 1;
52  
53 __END__
« Backgammon/Board.pm ↑ Summary Backgammon/Shots.pm »