blib/lib/PDL/PP/Dims.pm

filter: Statementstmt 93.4% 43 / 46 Branchbran 72.2% 13 / 18 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 91.6% 11 / 12 Podpod n/a totaltotal 84.8% 73 / 86 CC 12 SCAR 13.5
CC
12
Cov
86%
add_value
7.7
get_indobj_make
4.0
get_initdim
3.1
CRAP 3.9
« blib/lib/PDL/Graphics/State.pm ↑ Summary blib/lib/PDL/Lvalue.pm »
1 ##############################################
2 package PDL::PP::PdlDimsObj; # Hold more dims
3 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 sub new {
6 7 ▶ my($type) = @_;
Subroutine new: called CC=1 SCAR=0.0
7 7 bless {},$type;
8 }
9  
10 sub get_indobj_make {
11 11 ▶ my($this,$expr) = @_;
Subroutine get_indobj_make: called CC=4 SCAR=13.9
12 11 ▶ $expr =~ /^([a-zA-Z0-9]+)(?:=([0-9]+))?$/ or confess "Invalid index expr '$expr'\n";
Branch: 1 branch
BranchTrueFalseTotal
$expr =~ /^([a-zA-Z0-9]+)(?:=([0-9]+))?$/ or confess("Invalid index expr '${expr}'\n") 0 11 11
13 11 my $name = $1; my $val = $2;
14 11 my $indobj;
15 11 ▶ if(defined $this->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $this->{$name}) { } 3 8 11
16 3 $indobj = $this->{$name};
17 } else {
18 8 $indobj = PDL::PP::Ind->new($name);
19 8 $this->{$name}=$indobj;
20 }
21 11 ▶ if(defined $val) { $indobj->add_value($val); }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val) 1 10 11
22 11 return $indobj;
23 }
24  
25 #####################################################################
26 #
27 # Encapsulate one index.
28  
29 package PDL::PP::Ind;
30 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 sub new {
33 8 ▶ my($type,$name) = @_;
Subroutine new: called CC=1 SCAR=0.0
34 8 my $this = bless {Name => $name},$type;
35 8 return $this;
36 }
37  
38 # set the value of an index, also used by perl level threading
39 sub add_value {
40 10 ▶ my($this,$val) = @_;
Subroutine add_value: called CC=7 SCAR=20.4
41 10 ▶ croak("index values for $this->{Name} must be positive")
Branch: 1 branch
BranchTrueFalseTotal
unless $val > 0 0 10 10
42 unless $val > 0;
43 10 ▶ if(defined $this->{Value}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $this->{'Value'}) { } 4 6 10
44 4 ▶ if ($this->{Value} == -1 || $this->{Value} == 1)
Branch: 2 branches
BranchTrueFalseTotal
if ($this->{'Value'} == -1 or $this->{'Value'} == 1) { } 0 4 4
elsif ($val != 1 and $val != $this->{'Value'}) { } 2 3 5
Condition33%1/3
$this->{"Value"} == -1 or $this->{"Value"} == 1
l!l&&r!l&&!r
004
MC/DC0%0/2
$this->{"Value"} == -1 or $this->{"Value"} == 1
$this->{"Value"} == -1 $this->{"Value"} == 1
Truth table33%1/3
A or B
A= $this->{"Value"} == -1B= $this->{"Value"} == 1
ABresult
1X1
011
000
45 0 { $this->{Value} = $val }
46 ▶ elsif($val != 1 && $val != $this->{Value}) {
Condition100%3/3
$val != 1 and $val != $this->{"Value"}
!ll&&!rl&&r
112
MC/DC100%2/2
$val != 1 and $val != $this->{"Value"}
$val != 1 $val != $this->{"Value"}
Truth table100%3/3
A and B
A= $val != 1B= $val != $this->{"Value"}
ABresult
0X0
100
111
47 2 croak("For index $this->{Name} conflicting values $this->{Value} and $val given\n");
48 }
49 } else {
50 6 $this->{Value} = $val;
51 }
52 }
53  
54 # This index will take its size value from outside parameter ...
55 0 ▶sub set_from { my($this,$otherpar) = @_;
Subroutine set_from: not called CC=1 SCAR=6.9
56 0 $this->{From} = $otherpar;
57 }
58  
59 32 ▶sub name {return (shift)->{Name}}
Subroutine name: called CC=1 SCAR=0.0
60  
61 1 ▶sub get_decldim { my($this) = @_;
Subroutine get_decldim: called CC=1 SCAR=0.0
62 1 return "PDL_Indx __$this->{Name}_size;";
63 }
64  
65 1 ▶sub get_initdim { my($this) = @_;
Subroutine get_initdim: called CC=3 SCAR=11.3
66 1 my $init = '-1';
67 $init = "\$COMP(".$this->{From}->{ProtoName}.")"
68 1 ▶ if $this->{From};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"From"} 0 1 1
69 1 ▶ $init = $this->{Value} if defined $this->{Value};
Branch: 1 branch
BranchTrueFalseTotal
if defined $this->{"Value"} 0 1 1
70 1 "\$PRIV(__$this->{Name}_size) = $init;"
71 }
72  
73 1 ▶sub get_copydim { my($this,$fromsub,$tosub) = @_;
Subroutine get_copydim: called CC=1 SCAR=0.0
74 1 my($iname) = "__$this->{Name}_size";
75 1 &$tosub($iname) ."=". &$fromsub($iname) .";" ;
76 }
77  
78 2 ▶sub get_size { my($this) = @_;
Subroutine get_size: called CC=1 SCAR=0.0
79 2 "\$PRIV(__$this->{Name}_size)"
80 }
81  
82 3 1;
« blib/lib/PDL/Graphics/State.pm ↑ Summary blib/lib/PDL/Lvalue.pm »