| 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
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
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | my $detail = $self->detail; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | ▶ | return $base unless defined $detail && !ref $detail && length $detail; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $detail and not ref $detail and length $detail
defined $detail and not ref $detail
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||