Backgammon/Error.pm

filter: Statementstmt 85.7% 18 / 21 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 80.0% 4 / 5 Podpod 100% 2 / 2 totaltotal 63.6% 28 / 44 CC 5 SCAR 16.9
CC
5
Cov
69%
message
8.7
stringify
2.0
BEGIN
1.0
CRAP 5.4
« Backgammon/Turn.pm ↑ Summary Backgammon/Bot.pm »
1 package Game::Backgammon::Error;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Object::Proto::Sugar -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = '0.03';
9  
10 2 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 2 );
21  
22 has detail => (
23 is => 'ro',
24 isa => Any
25 2 );
26  
27 1 ▶sub message {
Subroutine message: called CC=5 SCAR=21.6
Pod documented
28 1 my ($self) = @_;
29 1 ▶ my $base = $MESSAGE{ $self->code } // $self->code;
Condition33%1/3
$MESSAGE{$self->code} // $self->code
l!l&&r!l&&!r
100
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 1 my $detail = $self->detail;
31 1 ▶ return $base unless defined $detail && !ref $detail && length $detail;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $detail and not ref $detail and length $detail 1 0 1
Condition33%2/6
defined $detail and not ref $detail and length $detail
!ll&&!rl&&r
100
defined $detail and not ref $detail
!ll&&!rl&&r
100
MC/DC0%0/3
defined $detail and not ref $detail and length $detail
defined $detail not ref $detail length $detail
Truth table25%1/4
A and not(B) and C
A= defined $detailB= not ref $detailC= length $detail
ABCresult
0XX0
10X0
1100
1111
32 0 $detail =~ s/\s+\z//;
33 0 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 2 1;
39  
40 __END__
« Backgammon/Turn.pm ↑ Summary Backgammon/Bot.pm »