| 1 | package Games::Sudoku::Component::Base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 7 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1159 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=18 SCAR=29.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1159 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1159 | ▶ | my $this = bless {}, (ref $class || $class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | my %options = ref $_[0] ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1159 | ▶ | my $size = $options{size} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options{'size'} || 0
MC/DC100%1/1
$options{'size'} || 0
$options{'size'}
Truth table100%2/2
A
A= $options{'size'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1159 | ▶ | my $bl_width = $options{block_width} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options{'block_width'} || 0
MC/DC100%1/1
$options{'block_width'} || 0
$options{'block_width'}
Truth table100%2/2
A
A= $options{'block_width'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1159 | ▶ | my $bl_height = $options{block_height} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options{'block_height'} || 0
MC/DC100%1/1
$options{'block_height'} || 0
$options{'block_height'}
Truth table100%2/2
A
A= $options{'block_height'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1159 | ▶ | if ($bl_width and $bl_height and $bl_width && $bl_height) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%6/9
$bl_width and $bl_height and ($bl_width and $bl_height)
$bl_width and $bl_height
$bl_width and $bl_height
MC/DC50%2/4
$bl_width and $bl_height and ($bl_width and $bl_height)
$bl_width
$bl_height
$bl_width
$bl_height
Truth table60%3/5
A and B and C and D
A= $bl_widthB= $bl_heightC= $bl_widthD= $bl_height
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1133 | $size = $bl_width * $bl_height; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ▶ | elsif ($size and $size == int(sqrt($size)) ** 2) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$size and $size == int(sqrt $size) ** 2
MC/DC100%2/2
$size and $size == int(sqrt $size) ** 2
$size
$size == int(sqrt $size) ** 2
Truth table100%3/3
A and B
A= $sizeB= $size == int(sqrt $size) ** 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 7 | $bl_width = $bl_height = int(sqrt($size)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ▶ | elsif ($size or $bl_width or $bl_height) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$size or $bl_width or $bl_height
$size or $bl_width
MC/DC100%3/3
$size or $bl_width or $bl_height
$size
$bl_width
$bl_height
Truth table100%4/4
A or B or C
A= $sizeB= $bl_widthC= $bl_height
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 9 | ▶ | croak "Invalid size: $size" if $size; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 6 | ▶ | croak "Invalid block: width $bl_width, height $bl_height" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$bl_width or $bl_height
MC/DC0%0/2
$bl_width or $bl_height
$bl_width
$bl_height
Truth table66%2/3
A or B
A= $bl_widthB= $bl_height
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | if $bl_width || $bl_height; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 10 | $size = 9; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 10 | $bl_width = $bl_height = 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1150 | $this->{size} = $size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1150 | $this->{block_width} = $bl_width; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1150 | $this->{block_height} = $bl_height; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1150 | $this->_initialize(%options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1145 | $this; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub _initialize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my ($this, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 275893 | ▶ | sub _check { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 275893 | my ($this, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 275893 | ▶ | croak "Invalid value: undef" unless defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 275892 | ▶ | croak "Invalid value: $value" if $value > $this->{size} || $value < 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$value > $this->{"size"} or $value < 1
MC/DC100%2/2
$value > $this->{"size"} or $value < 1
$value > $this->{"size"}
$value < 1
Truth table100%3/3
A or B
A= $value > $this->{"size"}B= $value < 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 275882 | $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 568 | ▶ | sub _check0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check0: called CC=4 SCAR=15.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 568 | my ($this, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 568 | ▶ | croak "Invalid value: undef" unless defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 568 | ▶ | croak "Invalid value: $value" if $value > $this->{size} || $value < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$value > $this->{"size"} or $value < 0
MC/DC0%0/2
$value > $this->{"size"} or $value < 0
$value > $this->{"size"}
$value < 0
Truth table33%1/3
A or B
A= $value > $this->{"size"}B= $value < 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 568 | $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 58055 | ▶ | sub _block_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_block_id: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 58055 | my ($this, $row, $col) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 58055 | ▶ | croak "Invalid row: $row" unless $this->_check($row); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 58054 | ▶ | croak "Invalid col: $col" unless $this->_check($col); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 58054 | my $blockrow = int(($row - 1) / $this->{block_height}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 58054 | my $blockcol = int(($col - 1) / $this->{block_width}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 58054 | $blockrow * $this->{block_height} + $blockcol + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 21 | ▶ | sub size { $_[0]->{size} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 9 | ▶ | sub block_width { $_[0]->{block_width} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
block_width: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 9 | ▶ | sub block_height { $_[0]->{block_height} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
block_height: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||