blib/lib/PMLTQ/Relation/DepthFirstRangeIterator.pm

filter: Statementstmt 37.2% 44 / 118 Branchbran 0.0% 0 / 38 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 20 Subroutinesub 66.6% 14 / 21 Podpod 0.0% 0 / 7 totaltotal 24.4% 58 / 237 CC 31 SCAR 51.2
CC
31
Cov
23%
start
342.0
next
182.0
new
6.0
CRAP 167.8
« blib/lib/PMLTQ/Command/webverify.pm ↑ Summary blib/lib/PMLTQ/Commands.pm »
1 package PMLTQ::Relation::DepthFirstRangeIterator;
2 12 our $AUTHORITY = 'cpan:MATY';
3 12 $PMLTQ::Relation::DepthFirstRangeIterator::VERSION = '1.5.0';
4 # ABSTRACT: Iterates tree using depth first search in given boundaries
5  
6  
7 12 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 12 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use base qw(PMLTQ::Relation::Iterator);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 12 ▶use constant CONDITIONS=>0;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 12 ▶use constant LMIN =>1;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 12 ▶use constant LMAX =>2;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 12 ▶use constant RMIN =>3;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 12 ▶use constant RMAX =>4;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 12 ▶use constant DIST =>5;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 12 ▶use constant NODE=>6;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 12 ▶use constant FILE=>7;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 12 ▶use constant START=>8;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23  
24 sub new {
25 0 ▶ my ($class,$conditions,$lmin,$lmax,$rmin,$rmax)=@_;
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
26 0 ▶ croak "usage: $class->new(sub{...})" unless ref($conditions) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $conditions eq "CODE" 0 0 0
27 0 return bless [$conditions,$lmin,$lmax,$rmin,$rmax],$class;
28 }
29 sub clone {
30 0 ▶ my ($self)=@_;
Subroutine clone: not called CC=1 SCAR=6.9
Pod undocumented
31 0 return bless [$self->[CONDITIONS],$self->[LMIN],$self->[LMAX],$self->[RMIN],$self->[RMAX]], ref($self);
32 }
33 sub start {
34 0 ▶ my ($self,$start_node,$fsfile)=@_;
Subroutine start: not called CC=18 SCAR=58.3
Pod undocumented
35 0 ▶ if ($fsfile) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fsfile) { } 0 0 0
36 0 $self->[FILE]=$fsfile;
37 } else {
38 0 $fsfile=$self->[FILE];
39 }
40 0 $self->[START] = $start_node;
41 0 my $n;
42 0 my $dist=0;
43 0 my $rmin = $self->[RMIN];
44 0 ▶ if (defined($rmin)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rmin) 0 0 0
45 0 $n=$start_node;
46 0 ▶ while ($n and $dist<$rmin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n and $dist < $rmin) 0 0 0
Condition0%0/3
$n and $dist < $rmin
!ll&&!rl&&r
000
MC/DC0%0/2
$n and $dist < $rmin
$n $dist < $rmin
Truth table0%0/3
A and B
A= $nB= $dist < $rmin
ABresult
0X0
100
111
47 0 $n = $n->following;
48 0 $dist++;
49 }
50 0 my $rmax = $self->[RMAX];
51 0 ▶ undef $n if ($n and defined($rmax) and $dist>$rmax);
Branch: 1 branch
BranchTrueFalseTotal
if $n and defined $rmax and $dist > $rmax 0 0 0
Condition0%0/6
$n and defined $rmax and $dist > $rmax
!ll&&!rl&&r
000
$n and defined $rmax
!ll&&!rl&&r
000
MC/DC0%0/3
$n and defined $rmax and $dist > $rmax
$n defined $rmax $dist > $rmax
Truth table0%0/4
A and B and C
A= $nB= defined $rmaxC= $dist > $rmax
ABCresult
0XX0
10X0
1100
1111
52 }
53 0 ▶ if (!$n) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($n) 0 0 0
54 0 my $lmin = $self->[LMIN];
55 0 ▶ if (defined($lmin)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $lmin) 0 0 0
56 0 $dist=0;
57 0 $n=$start_node;
58 0 ▶ while ($n and $dist>$lmin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n and $dist > $lmin) 0 0 0
Condition0%0/3
$n and $dist > $lmin
!ll&&!rl&&r
000
MC/DC0%0/2
$n and $dist > $lmin
$n $dist > $lmin
Truth table0%0/3
A and B
A= $nB= $dist > $lmin
ABresult
0X0
100
111
59 0 $n = $n->previous;
60 0 $dist--;
61 }
62 0 my $lmax = $self->[LMAX];
63 0 ▶ undef $n if ($n and defined($lmax) and $dist<$lmax);
Branch: 1 branch
BranchTrueFalseTotal
if $n and defined $lmax and $dist < $lmax 0 0 0
Condition0%0/6
$n and defined $lmax and $dist < $lmax
!ll&&!rl&&r
000
$n and defined $lmax
!ll&&!rl&&r
000
MC/DC0%0/3
$n and defined $lmax and $dist < $lmax
$n defined $lmax $dist < $lmax
Truth table0%0/4
A and B and C
A= $nB= defined $lmaxC= $dist < $lmax
ABCresult
0XX0
10X0
1100
1111
64 }
65 }
66 0 $self->[DIST]=$dist;
67 0 $self->[NODE]=$n;
68 0 ▶ return ($n && $self->[CONDITIONS]->($n,$fsfile)) ? $n : ($n && $self->next);
Branch: 1 branch
BranchTrueFalseTotal
$n && $self->[0]->($n, $fsfile) ? : 0 0 0
Condition0%0/6
$n and $self->[0]->($n, $fsfile)
!ll&&!rl&&r
000
$n and $self->next
!ll&&!rl&&r
000
MC/DC0%0/2
$n and $self->[0]->($n, $fsfile)
$n $self->[0]->($n, $fsfile)
MC/DC0%0/2
$n and $self->next
$n $self->next
Truth table0%0/3
A and B
A= $nB= $self->[0]->($n, $fsfile)
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $nB= $self->next
ABresult
0X0
100
111
69 }
70 sub next {
71 0 ▶ my ($self)=@_;
Subroutine next: not called CC=13 SCAR=52.0
Pod undocumented
72 0 my $conditions=$self->[CONDITIONS];
73 0 my $n=$self->[NODE];
74 0 my $fsfile=$self->[FILE];
75 0 my $dist=$self->[DIST];
76  
77 0 my $max;
78 0 ▶ if ($dist>0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dist > 0) 0 0 0
79 # advance right
80 0 $max=$self->[RMAX];
81 0 ▶ while ($n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n) 0 0 0
82 0 $dist++;
83 0 ▶ last if (defined($max) and $dist>$max);
Branch: 1 branch
BranchTrueFalseTotal
if defined $max and $dist > $max 0 0 0
Condition0%0/3
defined $max and $dist > $max
!ll&&!rl&&r
000
MC/DC0%0/2
defined $max and $dist > $max
defined $max $dist > $max
Truth table0%0/3
A and B
A= defined $maxB= $dist > $max
ABresult
0X0
100
111
84 0 $n=$n->following();
85 0 ▶ if ($conditions->($n,$fsfile)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$conditions($n, $fsfile)) 0 0 0
86 0 $self->[DIST]=$dist;
87 0 return $self->[NODE]=$n;
88 }
89 }
90 0 my $lmin = $self->[LMIN];
91 0 ▶ unless (defined $lmin) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $lmin) 0 0 0
92 0 $self->[DIST]=$dist;
93 0 return($self->[NODE]=undef);
94 }
95 0 $dist = 0;
96 0 $n = $self->[START];
97 0 ▶ while ($n and ($dist-1) > $lmin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n and $dist - 1 > $lmin) 0 0 0
Condition0%0/3
$n and $dist - 1 > $lmin
!ll&&!rl&&r
000
MC/DC0%0/2
$n and $dist - 1 > $lmin
$n $dist - 1 > $lmin
Truth table0%0/3
A and B
A= $nB= $dist - 1 > $lmin
ABresult
0X0
100
111
98 0 $n = $n->previous;
99 0 $dist--;
100 }
101 }
102 # advance left
103 0 $max = $self->[LMAX];
104 0 ▶ while ($n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n) 0 0 0
105 0 $dist--;
106 0 ▶ if (defined($max) and $dist<$max) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $max and $dist < $max) 0 0 0
Condition0%0/3
defined $max and $dist < $max
!ll&&!rl&&r
000
MC/DC0%0/2
defined $max and $dist < $max
defined $max $dist < $max
Truth table0%0/3
A and B
A= defined $maxB= $dist < $max
ABresult
0X0
100
111
107 0 undef $n;
108 0 last;
109 }
110 0 $n=$n->previous();
111 0 ▶ last if $conditions->($n,$fsfile);
Branch: 1 branch
BranchTrueFalseTotal
if &$conditions($n, $fsfile) 0 0 0
112 }
113 0 $self->[DIST]=$dist;
114 0 return $self->[NODE]=$n;
115 }
116 sub node {
117 0 ▶ return $_[0]->[NODE];
Subroutine node: not called CC=1 SCAR=6.9
Pod undocumented
118 }
119 sub file {
120 0 ▶ return $_[0]->[FILE];
Subroutine file: not called CC=1 SCAR=6.9
Pod undocumented
121 }
122 sub reset {
123 0 ▶ my ($self)=@_;
Subroutine reset: not called CC=1 SCAR=6.9
Pod undocumented
124 0 $self->[NODE]=undef;
125 0 $self->[FILE]=undef;
126 0 $self->[START]=undef;
127 0 $self->[DIST]=undef;
128 }
129  
130 12 1; # End of PMLTQ::Relation::DepthFirstRangeIterator
131  
132 __END__
« blib/lib/PMLTQ/Command/webverify.pm ↑ Summary blib/lib/PMLTQ/Commands.pm »