blib/lib/Game/Senet/Error.pm

filter: Statementstmt 89.2% 25 / 28 Branchbran 50.0% 1 / 2 Conditioncond 14.2% 1 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 77.7% 7 / 9 Podpod 100% 3 / 3 totaltotal 69.8% 37 / 53 CC 5 SCAR 12.2
CC
5
Cov
73%
message_for
6.0
of
6.0
codes
2.0
CRAP 3.4
« blib/lib/Game/Senet/Engine.pm ↑ Summary blib/arch/Game/Senet/Install/Files.pm »
1 package Game::Senet::Error;
2  
3 62 ▶use 5.010;
Subroutine __ANON__: called CC=1 SCAR=0.0
4 62 ▶use strict;
Subroutine __ANON__: called CC=1 SCAR=0.0
5 62 ▶use warnings;
Subroutine __ANON__: called CC=1 SCAR=0.0
6  
7 62 ▶use Carp ();
Subroutine __ANON__: called CC=1 SCAR=0.0
8 62 ▶use Object::Proto::Sugar;
Subroutine __ANON__: called CC=1 SCAR=0.0
9  
10 62 our $VERSION = '0.02';
11  
12 62 my (@CODES, %MESSAGE);
13 62 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
14 62 @CODES = qw(
15 game_over bad_move no_roll no_piece not_your_piece bound_piece
16 wrong_distance forward_first no_back must_land_26 no_exit
17 blockade own_piece safe_house protected
18 bad_record bad_position
19 );
20 62 %MESSAGE = (
21 game_over => 'the game is already over',
22 bad_move => 'that is not a move',
23 no_roll => 'there is no throw to play: the record this game was read from ends here',
24 no_piece => 'there is no piece on that house',
25 not_your_piece => 'that piece is not yours',
26 bound_piece => 'this throw belongs to the piece that has just reached the House of Happiness',
27 wrong_distance => 'a piece moves exactly as many houses as the throw is worth',
28 forward_first => 'a piece moves back only when no piece can move forward',
29 no_back => 'that piece cannot move back',
30 must_land_26 => 'every piece must stop on the House of Happiness before it goes further',
31 no_exit => 'a piece on that house cannot move with this throw',
32 blockade => 'a row of the other side\'s pieces blocks the way, and cannot be passed',
33 own_piece => 'one of your own pieces is already on that house',
34 safe_house => 'a piece on that house is safe and cannot be swapped',
35 protected => 'that piece is protected by the piece beside it',
36 bad_record => 'the record does not agree with the game it describes',
37 bad_position => 'that position is not one this game can start from',
38 );
39 }
40  
41 62 has code => (is => 'ro', default => 'bad_move');
42  
43 62 has message => (is => 'ro');
44  
45 62 has detail => (is => 'ro');
46  
47 0 ▶sub codes { @CODES }
Subroutine codes: not called CC=1 SCAR=6.9
Pod documented
48  
49 0 ▶sub message_for {
Subroutine message_for: not called CC=2 SCAR=17.9
Pod documented
50 0 my ($class, $code) = @_;
51 0 ▶ return $MESSAGE{ $code // '' };
Condition0%0/2
$code // ""
l!l
00
MC/DC0%0/1
$code // ""
$code
Truth table0%0/2
A
A= $code
Aresult
11
00
52 }
53  
54 85681 ▶sub of {
Subroutine of: called CC=4 SCAR=17.9
Pod documented
55 85681 my ($class, $code, %detail) = @_;
56 Carp::croak("Game::Senet::Error: no such refusal as '" . ($code // 'undef') . "'")
57 85681 ▶ unless defined $code && exists $MESSAGE{$code};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code and exists $MESSAGE{$code} 0 85681 85681
Condition20%1/5
defined $code and exists $MESSAGE{$code}
!ll&&!rl&&r
0085681
$code // "undef"
l!l
00
MC/DC0%0/2
defined $code and exists $MESSAGE{$code}
defined $code exists $MESSAGE{$code}
MC/DC0%0/1
$code // "undef"
$code
Truth table33%1/3
A and B
A= defined $codeB= exists $MESSAGE{$code}
ABresult
0X0
100
111
Truth table0%0/2
A
A= $code
Aresult
11
00
58 85681 return $class->new(code => $code, message => $MESSAGE{$code}, detail => { %detail });
59 }
60  
61 62 1;
62  
63 __END__
« blib/lib/Game/Senet/Engine.pm ↑ Summary blib/arch/Game/Senet/Install/Files.pm »