blib/lib/PMLTQ/Relation/SiblingIteratorWithDistance.pm

filter: Statementstmt 38.3% 38 / 99 Branchbran 0.0% 0 / 38 Conditioncond 0.0% 0 / 44 MC/DCmcdc 0.0% 0 / 28 Subroutinesub 63.1% 12 / 19 Podpod 0.0% 0 / 7 totaltotal 21.2% 50 / 235 CC 35 SCAR 53.7
CC
35
Cov
21%
start
420.0
next
210.0
new
12.0
CRAP 215.0
« blib/lib/PMLTQ/Relation/TransitiveIterator.pm ↑ Summary blib/lib/PMLTQ/Command/webverify.pm »
1 package PMLTQ::Relation::SiblingIteratorWithDistance;
2 12 our $AUTHORITY = 'cpan:MATY';
3 12 $PMLTQ::Relation::SiblingIteratorWithDistance::VERSION = '1.5.0';
4 # ABSTRACT: Iterates over siblings given node with boudaries
5  
6 12 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 12 ▶use base qw(PMLTQ::Relation::Iterator);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use constant CONDITIONS=>0;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 12 ▶use constant MIN=>1;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 12 ▶use constant MAX=>2;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 12 ▶use constant NODE=>3;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 12 ▶use constant DIST=>4;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 12 ▶use constant FILE=>5;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 12 ▶use constant START=>6;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 sub new {
21 0 ▶ my ($class,$conditions,$min,$max)=@_;
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
22 0 ▶ croak "usage: $class->new(sub{...})" unless ref($conditions) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $conditions eq "CODE" 0 0 0
23 0 ▶ $min||=0;
Condition0%0/2
$min ||= 0
l!l
00
MC/DC0%0/1
$min ||= 0
$min
Truth table0%0/2
A
A= $min
Aresult
11
00
24 0 return bless [$conditions,$min,$max],$class;
25 }
26 sub clone {
27 0 ▶ my ($self)=@_;
Subroutine clone: not called CC=1 SCAR=6.9
Pod undocumented
28 0 return bless [$self->[CONDITIONS],$self->[MIN],$self->[MAX]], ref($self);
29 }
30 # the iterator will first go right from the start node,
31 # then left
32 sub start {
33 0 ▶ my ($self,$node,$fsfile)=@_;
Subroutine start: not called CC=20 SCAR=60.4
Pod undocumented
34 0 my $min = $self->[MIN];
35 0 my $max = $self->[MAX];
36 0 $self->[FILE]=$fsfile;
37 0 $self->[START]=$node;
38 # -10, means -10 to +infty
39 # -10,0 means in fact -10,-1
40 # ,10, means -infty to 10,
41 # 0,10 means 1,10
42 # ,-10 means -infty to -10
43 # N,M with N=M=0 or M<N is never satisfied
44 0 ▶ return if (defined($min) and defined($max) and $min>$max);
Branch: 1 branch
BranchTrueFalseTotal
if defined $min and defined $max and $min > $max 0 0 0
Condition0%0/6
defined $min and defined $max and $min > $max
!ll&&!rl&&r
000
defined $min and defined $max
!ll&&!rl&&r
000
MC/DC0%0/3
defined $min and defined $max and $min > $max
defined $min defined $max $min > $max
Truth table0%0/4
A and B and C
A= defined $minB= defined $maxC= $min > $max
ABCresult
0XX0
10X0
1100
1111
45 0 my $dist=1;
46 0 my $n=$node->rbrother;
47 0 ▶ if (defined($min) and $min>$dist) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $min and $min > $dist) 0 0 0
Condition0%0/3
defined $min and $min > $dist
!ll&&!rl&&r
000
MC/DC0%0/2
defined $min and $min > $dist
defined $min $min > $dist
Truth table0%0/3
A and B
A= defined $minB= $min > $dist
ABresult
0X0
100
111
48 0 ▶ $n = $n->rbrother while ($n and ($dist++)<$min);
Branch: 1 branch
BranchTrueFalseTotal
$n and $dist++ < $min and do { $n = $n->rbrother } 0 0 0
Condition0%0/3
$n and $dist++ < $min
!ll&&!rl&&r
000
MC/DC0%0/2
$n and $dist++ < $min
$n $dist++ < $min
Truth table0%0/3
A and B
A= $nB= $dist++ < $min
ABresult
0X0
100
111
49 }
50 0 ▶ $n=undef 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
51 0 ▶ if (!$n) { # try going left
Branch: 1 branch
BranchTrueFalseTotal
unless ($n) 0 0 0
52 0 $dist = -1;
53 0 $n=$node->lbrother;
54 0 ▶ if (defined($max) and $max<$dist) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $max and $max < $dist) 0 0 0
Condition0%0/3
defined $max and $max < $dist
!ll&&!rl&&r
000
MC/DC0%0/2
defined $max and $max < $dist
defined $max $max < $dist
Truth table0%0/3
A and B
A= defined $maxB= $max < $dist
ABresult
0X0
100
111
55 0 ▶ $n = $n->lbrother while ($n and ($dist--)>$max);
Branch: 1 branch
BranchTrueFalseTotal
$n and $dist-- > $max and do { $n = $n->lbrother } 0 0 0
Condition0%0/3
$n and $dist-- > $max
!ll&&!rl&&r
000
MC/DC0%0/2
$n and $dist-- > $max
$n $dist-- > $max
Truth table0%0/3
A and B
A= $nB= $dist-- > $max
ABresult
0X0
100
111
56 }
57 0 ▶ $n=undef if defined($min) and $dist<$min;
Branch: 1 branch
BranchTrueFalseTotal
if defined $min and $dist < $min 0 0 0
Condition0%0/3
defined $min and $dist < $min
!ll&&!rl&&r
000
MC/DC0%0/2
defined $min and $dist < $min
defined $min $dist < $min
Truth table0%0/3
A and B
A= defined $minB= $dist < $min
ABresult
0X0
100
111
58 }
59 0 $self->[NODE]=$n;
60 0 $self->[DIST]=$dist;
61 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
62 }
63 sub next {
64 0 ▶ my ($self)=@_;
Subroutine next: not called CC=14 SCAR=53.5
Pod undocumented
65 0 my $conditions=$self->[CONDITIONS];
66 0 my $max = $self->[MAX];
67 0 my $min = $self->[MIN];
68 0 my $dist = $self->[DIST];
69 0 my $fsfile = $self->[FILE];
70 0 my $n=$self->[NODE];
71 0 ▶ if ($dist>0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dist > 0) 0 0 0
72 # advance right
73 0 ▶ while ($n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n) 0 0 0
74 0 $n=$n->rbrother;
75 0 $dist++;
76 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
77 0 ▶ if ($conditions->($n,$fsfile)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$conditions($n, $fsfile)) 0 0 0
78 0 $self->[DIST]=$dist;
79 0 return $self->[NODE]=$n;
80 }
81 }
82 # return to start node
83 0 $dist = 0;
84 0 $n=$self->[START];
85 0 ▶ if (defined($max) and $max+1<$dist) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $max and $max + 1 < $dist) 0 0 0
Condition0%0/3
defined $max and $max + 1 < $dist
!ll&&!rl&&r
000
MC/DC0%0/2
defined $max and $max + 1 < $dist
defined $max $max + 1 < $dist
Truth table0%0/3
A and B
A= defined $maxB= $max + 1 < $dist
ABresult
0X0
100
111
86 0 ▶ $n = $n->lbrother while ($n and $max+1<$dist--);
Branch: 1 branch
BranchTrueFalseTotal
$n and $max + 1 < $dist-- and do { $n = $n->lbrother } 0 0 0
Condition0%0/3
$n and $max + 1 < $dist--
!ll&&!rl&&r
000
MC/DC0%0/2
$n and $max + 1 < $dist--
$n $max + 1 < $dist--
Truth table0%0/3
A and B
A= $nB= $max + 1 < $dist--
ABresult
0X0
100
111
87 }
88 }
89 # advance left
90 0 ▶ while ($n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n) 0 0 0
91 0 $n=$n->lbrother;
92 0 $dist--;
93 0 ▶ last if defined($min) and $dist<$min;
Branch: 1 branch
BranchTrueFalseTotal
if defined $min and $dist < $min 0 0 0
Condition0%0/3
defined $min and $dist < $min
!ll&&!rl&&r
000
MC/DC0%0/2
defined $min and $dist < $min
defined $min $dist < $min
Truth table0%0/3
A and B
A= defined $minB= $dist < $min
ABresult
0X0
100
111
94 0 ▶ if ($conditions->($n,$fsfile)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$conditions($n, $fsfile)) 0 0 0
95 0 $self->[DIST]=$dist;
96 0 return $self->[NODE]=$n;
97 }
98 }
99 0 $self->[DIST]=0;
100 0 return $_[0]->[NODE]=undef;
101 }
102 sub node {
103 0 ▶ return $_[0]->[NODE];
Subroutine node: not called CC=1 SCAR=6.9
Pod undocumented
104 }
105 sub file {
106 0 ▶ return $_[0]->[FILE];
Subroutine file: not called CC=1 SCAR=6.9
Pod undocumented
107 }
108 sub reset {
109 0 ▶ my ($self)=@_;
Subroutine reset: not called CC=1 SCAR=6.9
Pod undocumented
110 0 $self->[NODE]=undef;
111 0 $self->[FILE]=undef;
112 0 $self->[START]=undef;
113 0 $self->[DIST]=0;
114 }
115  
116 12 1; # End of PMLTQ::Relation::SiblingIteratorWithDistance
117  
118 __END__
« blib/lib/PMLTQ/Relation/TransitiveIterator.pm ↑ Summary blib/lib/PMLTQ/Command/webverify.pm »