Component/Table/Item.pm

filter: Statementstmt 100% 44 / 44 Branchbran 90.0% 9 / 10 Conditioncond 44.4% 4 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 10 / 10 Podpod 100% 7 / 7 totaltotal 87.0% 74 / 85 CC 10 SCAR 13.6
CC
10
Cov
90%
new
7.1
as_string
4.2
BEGIN
1.0
CRAP 3.9
« Component/Table/Cell.pm ↑ Summary Component/Table/Permission.pm »
1 package Games::Sudoku::Component::Table::Item;
2 {
3 6 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶ use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 6 our $VERSION = '0.01';
8
9 442 ▶ sub new {
Subroutine new: called CC=7 SCAR=19.6
Pod documented
10 442 my $class = shift;
11 442 ▶ my $this = bless {}, (ref $class || $class);
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
04420
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
12
13 442 ▶ my %options = ref $_[0] ? %{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 311 131 442
14
15 442 ▶ croak "Row is undefined" unless defined $options{row};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options{"row"} 2 440 442
16 440 ▶ croak "Col is undefined" unless defined $options{col};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options{"col"} 1 439 440
17 439 ▶ croak "Allowed is undefined" unless defined $options{allowed};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options{"allowed"} 1 438 439
18 croak "Allowed should be array_ref"
19 438 ▶ if ref $options{allowed} ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $options{"allowed"} ne "ARRAY" 0 438 438
20
21 438 $this->{row} = $options{row};
22 438 $this->{col} = $options{col};
23 438 $this->{allowed} = $options{allowed};
24 438 $this->{value} = $options{value};
25
26 438 $this;
27 }
28
29 418 ▶ sub row { $_[0]->{row} }
Subroutine row: called CC=1 SCAR=0.0
Pod documented
30 418 ▶ sub col { $_[0]->{col} }
Subroutine col: called CC=1 SCAR=0.0
Pod documented
31 83 ▶ sub value { $_[0]->{value} }
Subroutine value: called CC=1 SCAR=0.0
Pod documented
32 3 ▶ sub allowed { @{ $_[0]->{allowed} } }
Subroutine allowed: called CC=1 SCAR=0.0
Pod documented
33
34 311 ▶ sub random_value {
Subroutine random_value: called CC=1 SCAR=0.0
Pod documented
35 311 my $this = shift;
36
37 311 my @allowed = @{ $this->{allowed} };
38 311 my $value = splice(@allowed, int(rand(@allowed)), 1);
39
40 311 $this->{allowed} = \@allowed;
41 311 $this->{value} = $value;
42
43 311 $value;
44 }
45
46 1 ▶ sub as_string {
Subroutine as_string: called CC=4 SCAR=14.3
Pod documented
47 1 my $this = shift;
48
49 1 ▶ my $row = $this->{row} || 0;
Condition50%1/2
$this->{'row'} || 0
l!l
10
MC/DC0%0/1
$this->{'row'} || 0
$this->{'row'}
Truth table50%1/2
A
A= $this->{'row'}
Aresult
11
00
50 1 ▶ my $col = $this->{col} || 0;
Condition50%1/2
$this->{'col'} || 0
l!l
10
MC/DC0%0/1
$this->{'col'} || 0
$this->{'col'}
Truth table50%1/2
A
A= $this->{'col'}
Aresult
11
00
51 1 ▶ my $value = $this->{value} || 0;
Condition50%1/2
$this->{'value'} || 0
l!l
10
MC/DC0%0/1
$this->{'value'} || 0
$this->{'value'}
Truth table50%1/2
A
A= $this->{'value'}
Aresult
11
00
52 1 my @allowed = @{ $this->{allowed} };
53
54 1 sprintf('(%d, %d): %d (allowed: %s)',
55 $row, $col, $value, join(', ', @allowed),
56 );
57 }
58 }
59
60 6 1;
61 __END__
« Component/Table/Cell.pm ↑ Summary Component/Table/Permission.pm »