Quantity/Abstract/InstanceIndex.pm

filter: Statementstmt 87.5% 28 / 32 Branchbran 37.5% 3 / 8 Conditioncond 28.5% 4 / 14 MC/DCmcdc 14.2% 1 / 7 Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 4 totaltotal 58.9% 43 / 73 CC 10 SCAR 19.3
CC
10
Cov
65%
is_valid_index
20.0
is_index_value
5.2
readable_value
3.0
CRAP 6.9
« Quantity/Time/Time.pm ↑ Summary Quantity/Time/Year.pm »
1 ### Change History
2 # 1998-12-03 Created. -Simon
3  
4 package Data::Quantity::Abstract::InstanceIndex;
5  
6 3 require 5;
7 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 $VERSION = 0.001;
11  
12 3 ▶use Data::Quantity::Number::Integer '-isasubclass';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 3 ▶use Class::MakeMethods (
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 'Standard::Inheritable:scalar' => 'instances',
16 3 );
17  
18 # $flag = Data::Quantity::Abstract::InstanceIndex->is_valid_index($number);
19 # Is this value acceptable for this quantity.
20 0 ▶sub is_valid_index {
Subroutine is_valid_index: not called CC=4 SCAR=30.0
Pod undocumented
21 0 my $class_or_item = shift;
22 0 my $value = shift;
23
24 0 ▶ my $instances = $class_or_item->instances or return;
Branch: 1 branch
BranchTrueFalseTotal
my $instances = $class_or_item->instances or return 0 0 0
25 0 ▶ return ( $value >= 0 and $value == int($value) and $value <= $#$instances );
Condition0%0/6
$value >= 0 && $value == int $value && $value <= $instances->$#*
!ll&&!rl&&r
000
$value >= 0 and $value == int $value
!ll&&!rl&&r
000
MC/DC0%0/3
$value >= 0 && $value == int $value && $value <= $instances->$#*
$value >= 0 $value == int $value $value <= $instances->$#*
Truth table0%0/4
A and B && C
A= $value >= 0B= $value == int $valueC= $value <= $instances->$#*
ABCresult
0XX0
10X0
1100
1111
26 }
27  
28 # $flag = Data::Quantity::Abstract::InstanceIndex->is_index_value($number);
29 # Is this value acceptable, and *not blank or empty*, for this quantity.
30 11 ▶sub is_index_value {
Subroutine is_index_value: called CC=4 SCAR=16.4
Pod undocumented
31 11 my $class_or_item = shift;
32 11 my $value = shift;
33
34 11 ▶ my $instances = $class_or_item->instances or return;
Branch: 1 branch
BranchTrueFalseTotal
my $instances = $class_or_item->instances or return 11 0 11
35 11 ▶ return ( $value > 0 and $value == int($value) and $value <= $#$instances );
Condition33%2/6
$value > 0 && $value == int $value && $value <= $instances->$#*
!ll&&!rl&&r
0011
$value > 0 and $value == int $value
!ll&&!rl&&r
0011
MC/DC0%0/3
$value > 0 && $value == int $value && $value <= $instances->$#*
$value > 0 $value == int $value $value <= $instances->$#*
Truth table25%1/4
A and B && C
A= $value > 0B= $value == int $valueC= $value <= $instances->$#*
ABCresult
0XX0
10X0
1100
1111
36 }
37  
38 # $definition = Data::Quantity::Abstract::InstanceIndex->instance($number);
39 11 ▶sub instance {
Subroutine instance: called CC=2 SCAR=7.0
Pod undocumented
40 11 my $class_or_item = shift;
41 11 my $value = shift;
42
43 11 ▶ return unless $class_or_item->is_index_value($value);
Branch: 1 branch
BranchTrueFalseTotal
unless $class_or_item->is_index_value($value) 0 11 11
44 11 return $class_or_item->instances->[ $value ];
45 }
46  
47 # $value = Data::Quantity::Abstract::InstanceIndex->readable_value($number)
48 # $value = Data::Quantity::Abstract::InstanceIndex->readable_value($number, $style)
49 11 ▶sub readable_value {
Subroutine readable_value: called CC=3 SCAR=11.0
Pod undocumented
50 11 my $class_or_item = shift;
51 11 my $value = shift;
52 11 ▶ my $style = shift || 'name';
Condition100%2/2
shift() || 'name'
l!l
110
MC/DC100%1/1
shift() || 'name'
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
53
54 11 ▶ my $instance = $class_or_item->instance($value) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $instance = $class_or_item->instance($value) or return 11 0 11
55
56 11 return $instance->{ $style };
57 }
58  
59 3 1;
« Quantity/Time/Time.pm ↑ Summary Quantity/Time/Year.pm »