blib/lib/PDL/PP/Dims.pm

filter: Statementstmt 100% 48 / 48 Branchbran 81.2% 13 / 16 Conditioncond 76.0% 19 / 25 MC/DCmcdc 40.0% 6 / 15 Subroutinesub 100% 18 / 18 Podpod n/a totaltotal 85.2% 104 / 122 CC 18 SCAR 14.7
CC
18
Cov
90%
add_value
8.4
get_indobj_make
7.3
get_initdim
4.0
CRAP 4.4
« blib/lib/PDL/Install/Files.pm ↑ Summary blib/lib/PDL/Demos/Sound.pm »
1 ##############################################
2 package # hide from PAUSE/MetaCPAN
3 PDL::PP::PdlDimsObj; # Hold more dims
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 247 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
9 247 my($type) = @_;
10 247 bless {},$type;
11 }
12  
13 160 ▶sub get_indobj_make {
Subroutine get_indobj_make: called CC=7 SCAR=19.9
14 160 my ($this,$expr,$calc,$orig_inds,$par_name) = @_;
15 160 ▶ my ($name, $val) = $expr =~ /^([a-zA-Z0-9]+)(?:=([0-9]+))?$/
Branch: 1 branch
BranchTrueFalseTotal
() = $expr =~ /^([a-zA-Z0-9]+)(?:=([0-9]+))?$/ or confess("Invalid index expr in Par '${par_name}' '${expr}' while parsing '${orig_inds}'\n") 160 0 160
16 or confess "Invalid index expr in Par '$par_name' '$expr' while parsing '$orig_inds'\n";
17 160 ▶ confess "Error: both simple value '$val' and CALC '$calc'"
Branch: 1 branch
BranchTrueFalseTotal
if $calc and defined $val 0 160 160
Condition66%2/3
$calc and defined $val
!ll&&!rl&&r
15910
MC/DC0%0/2
$calc and defined $val
$calc defined $val
Truth table66%2/3
A and B
A= $calcB= defined $val
ABresult
0X0
100
111
18 if $calc && defined $val;
19 160 ▶ $val //= $calc;
Condition100%3/3
$val //= $calc
l!l&&r!l&&!r
381121
MC/DC100%2/2
$val //= $calc
$val $calc
Truth table100%3/3
A //= B
A= $valB= $calc
ABresult
1X1
011
000
20 160 ▶ my $indobj = $this->{$name} //= PDL::PP::Ind->new($name);
Condition66%2/3
$this->{$name} //= "PDL::PP::Ind"->new($name)
l!l&&r!l&&!r
421180
MC/DC0%0/2
$this->{$name} //= "PDL::PP::Ind"->new($name)
$this->{$name} "PDL::PP::Ind"->new($name)
Truth table66%2/3
A //= B
A= $this->{$name}B= "PDL::PP::Ind"->new($name)
ABresult
1X1
011
000
21 160 ▶ $indobj->add_value($val) if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 39 121 160
22 160 return $indobj;
23 }
24  
25 103 ▶sub ind_obj {$_[0]{$_[1]}}
Subroutine ind_obj: called CC=1 SCAR=0.0
26 264 ▶sub ind_names {keys %{$_[0]}}
Subroutine ind_names: called CC=1 SCAR=0.0
27 59 ▶sub ind_fromcomp {grep defined $_->{From}, values %{$_[0]}}
Subroutine ind_fromcomp: called CC=1 SCAR=0.0
28 59 ▶sub ind_notfromcomp {grep !defined $_->{From}, values %{$_[0]}}
Subroutine ind_notfromcomp: called CC=1 SCAR=0.0
29  
30 #####################################################################
31 #
32 # Encapsulate one index.
33  
34 package # hide from PAUSE/MetaCPAN
35 PDL::PP::Ind;
36 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 118 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
39 118 my($type,$name) = @_;
40 118 bless {Name => $name},$type;
41 }
42  
43 # set the value of an index, also used by perl level broadcasting
44 57 ▶sub add_value {
Subroutine add_value: called CC=8 SCAR=21.3
45 57 my($this,$val) = @_;
46 57 ▶ croak("index values for $this->{Name} must be positive")
Branch: 1 branch
BranchTrueFalseTotal
if $val =~ /^\d+$/ and $val <= 0 0 57 57
Condition66%2/3
$val =~ /^\d+$/ and $val <= 0
!ll&&!rl&&r
1560
MC/DC0%0/2
$val =~ /^\d+$/ and $val <= 0
$val =~ /^\d+$/ $val <= 0
Truth table66%2/3
A and B
A= $val =~ /^\d+$/B= $val <= 0
ABresult
0X0
100
111
47 if $val =~ /^\d+$/ and $val <= 0;
48 return $this->{Value} = $val if
49 !defined $this->{Value} or
50 $this->{Value} == -1 or
51 57 ▶ $this->{Value} == 1;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $this->{"Value"} or $this->{"Value"} == -1 or $this->{"Value"} == 1 52 5 57
Condition66%4/6
not defined $this->{"Value"} or $this->{"Value"} == -1 or $this->{"Value"} == 1
l!l&&r!l&&!r
5205
not defined $this->{"Value"} or $this->{"Value"} == -1
l!l&&r!l&&!r
5205
MC/DC33%1/3
not defined $this->{"Value"} or $this->{"Value"} == -1 or $this->{"Value"} == 1
not defined $this->{"Value"} $this->{"Value"} == -1 $this->{"Value"} == 1
Truth table50%2/4
not(A) or B or C
A= not defined $this->{"Value"}B= $this->{"Value"} == -1C= $this->{"Value"} == 1
ABCresult
1XX1
01X1
0011
0000
52 5 ▶ croak "For index $this->{Name} conflicting values $this->{Value} and $val given\n" if $val != 1 && $val != $this->{Value};
Branch: 1 branch
BranchTrueFalseTotal
if $val != 1 and $val != $this->{"Value"} 2 3 5
Condition100%3/3
$val != 1 and $val != $this->{"Value"}
!ll&&!rl&&r
122
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
53 }
54  
55 # This index will take its size value from outside parameter ...
56 2 ▶sub set_from { my($this,$otherpar) = @_;
Subroutine set_from: called CC=1 SCAR=0.0
57 2 $this->{From} = $otherpar;
58 }
59  
60 417 ▶sub name {$_[0]{Name}}
Subroutine name: called CC=1 SCAR=0.0
61  
62 # where it occurs in the C arrays that track it (at least name and size)
63 94 ▶sub set_index {
Subroutine set_index: called CC=1 SCAR=0.0
64 94 my ($this, $i) = @_;
65 94 $this->{Index} = $i;
66 }
67 56 ▶sub get_index {$_[0]{Index} // confess "unknown index for $_[0]{Name}"}
Subroutine get_index: called CC=2 SCAR=7.6
Condition50%1/2
$_[0]{"Index"} // confess(qq[unknown index for $_[0]{"Name"}])
l!l
560
MC/DC0%0/1
$_[0]{"Index"} // confess(qq[unknown index for $_[0]{"Name"}])
$_[0]{"Index"}
Truth table50%1/2
A
A= $_[0]{"Index"}
Aresult
11
00
68  
69 58 ▶sub get_initdim { my($this) = @_;
Subroutine get_initdim: called CC=4 SCAR=13.9
70 my $init = $this->{Value} //
71 58 ▶ ($this->{From} ? "\$COMP(".$this->{From}{ProtoName}.")" : undef);
Branch: 1 branch
BranchTrueFalseTotal
$this->{'From'} ? : 1 50 51
Condition100%2/2
$this->{"Value"} // ($this->{"From"} ? '$COMP(' . $this->{"From"}{"ProtoName"} . ')' : undef)
l!l
751
MC/DC100%1/1
$this->{"Value"} // ($this->{"From"} ? '$COMP(' . $this->{"From"}{"ProtoName"} . ')' : undef)
$this->{"Value"}
Truth table100%2/2
A
A= $this->{"Value"}
Aresult
11
00
72 58 ▶ return if !defined $init;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $init 50 8 58
73 8 $this->get_size." = $init;"
74 }
75  
76 17 ▶sub get_size { my($this) = @_;
Subroutine get_size: called CC=1 SCAR=0.0
77 17 "\$PRIV(ind_sizes)[@{[$this->get_index]}]"
78 }
79  
80 6 1;
« blib/lib/PDL/Install/Files.pm ↑ Summary blib/lib/PDL/Demos/Sound.pm »