Backgammon/Error.pm

filter: Statementstmt 95.2% 20 / 21 Branchbran 100% 2 / 2 Conditioncond 55.5% 5 / 9 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 80.0% 4 / 5 Podpod 100% 2 / 2 totaltotal 77.2% 34 / 44 CC 5 SCAR 12.6
CC
5
Cov
84%
message
5.3
stringify
2.0
BEGIN
1.0
CRAP 3.5
« Backgammon/Turn.pm ↑ Summary Backgammon/Board.pm »
1 package Game::Backgammon::Error;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Object::Proto::Sugar -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 our $VERSION = '0.04';
9  
10 3 my %MESSAGE = (
11 game_over => 'the game is over',
12 not_legal => 'the rules do not offer that turn',
13 not_notation => 'that is not backgammon notation',
14 no_seed => 'a game needs a seed',
15 );
16  
17 has code => (
18 is => 'ro',
19 isa => Str
20 3 );
21  
22 has detail => (
23 is => 'ro',
24 isa => Any
25 3 );
26  
27 3 ▶sub message {
Subroutine message: called CC=5 SCAR=16.7
Pod documented
28 3 my ($self) = @_;
29 3 ▶ my $base = $MESSAGE{ $self->code } // $self->code;
Condition33%1/3
$MESSAGE{$self->code} // $self->code
l!l&&r!l&&!r
300
MC/DC0%0/2
$MESSAGE{$self->code} // $self->code
$MESSAGE{$self->code} $self->code
Truth table33%1/3
A // B
A= $MESSAGE{$self->code}B= $self->code
ABresult
1X1
011
000
30 3 my $detail = $self->detail;
31 3 ▶ return $base unless defined $detail && !ref $detail && length $detail;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $detail and not ref $detail and length $detail 2 1 3
Condition66%4/6
defined $detail and not ref $detail and length $detail
!ll&&!rl&&r
201
defined $detail and not ref $detail
!ll&&!rl&&r
201
MC/DC33%1/3
defined $detail and not ref $detail and length $detail
defined $detail not ref $detail length $detail
Truth table50%2/4
A and not(B) and C
A= defined $detailB= not ref $detailC= length $detail
ABCresult
0XX0
10X0
1100
1111
32 1 $detail =~ s/\s+\z//;
33 1 return "$base: $detail";
34 }
35  
36 0 ▶sub stringify { return $_[0]->code . ': ' . $_[0]->message }
Subroutine stringify: not called CC=1 SCAR=6.9
Pod documented
37  
38 3 1;
39  
40 __END__
« Backgammon/Turn.pm ↑ Summary Backgammon/Board.pm »