blib/lib/PMLTQ/Relation/AncestorIteratorWithBoundedDepth.pm

filter: Statementstmt 47.9% 35 / 73 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 25 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 61.1% 11 / 18 Podpod 0.0% 0 / 7 totaltotal 30.0% 46 / 153 CC 17 SCAR 36.1
CC
17
Cov
31%
start
90.0
next
56.0
new
12.0
CRAP 37.0
« blib/lib/PMLTQ/Relation/CurrentFileIterator.pm ↑ Summary blib/lib/PMLTQ/Command.pm »
1 package PMLTQ::Relation::AncestorIteratorWithBoundedDepth;
2 12 our $AUTHORITY = 'cpan:MATY';
3 12 $PMLTQ::Relation::AncestorIteratorWithBoundedDepth::VERSION = '1.5.0';
4 # ABSTRACT: Iterates over ancestor nodes to given bound
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 DEPTH=>4;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 12 ▶use constant FILE=>5;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 sub new {
20 0 ▶ my ($class,$conditions,$min,$max)=@_;
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
21 0 ▶ croak "usage: $class->new(sub{...})" unless ref($conditions) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $conditions eq "CODE" 0 0 0
22 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
23 0 return bless [$conditions,$min,$max],$class;
24 }
25 sub clone {
26 0 ▶ my ($self)=@_;
Subroutine clone: not called CC=1 SCAR=6.9
Pod undocumented
27 0 return bless [$self->[CONDITIONS],$self->[MIN],$self->[MAX]], ref($self);
28 }
29 sub start {
30 0 ▶ my ($self,$node,$fsfile)=@_;
Subroutine start: not called CC=9 SCAR=45.0
Pod undocumented
31 0 ▶ my $min = $self->[MIN]||1;
Condition0%0/2
$self->[1] || 1
l!l
00
MC/DC0%0/1
$self->[1] || 1
$self->[1]
Truth table0%0/2
A
A= $self->[1]
Aresult
11
00
32 0 my $max = $self->[MAX];
33 0 $self->[FILE]=$fsfile;
34 0 my $depth=0;
35 0 ▶ while ($node and $depth<$min) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node and $depth < $min) 0 0 0
Condition0%0/3
$node and $depth < $min
!ll&&!rl&&r
000
MC/DC0%0/2
$node and $depth < $min
$node $depth < $min
Truth table0%0/3
A and B
A= $nodeB= $depth < $min
ABresult
0X0
100
111
36 0 $node = $node->parent ;
37 0 $depth++;
38 }
39 0 ▶ $node=undef if defined($max) and $depth>$max;
Branch: 1 branch
BranchTrueFalseTotal
if defined $max and $depth > $max 0 0 0
Condition0%0/3
defined $max and $depth > $max
!ll&&!rl&&r
000
MC/DC0%0/2
defined $max and $depth > $max
defined $max $depth > $max
Truth table0%0/3
A and B
A= defined $maxB= $depth > $max
ABresult
0X0
100
111
40 0 $self->[NODE]=$node;
41 0 $self->[DEPTH]=$depth;
42 0 ▶ return ($node && $self->[CONDITIONS]->($node,$fsfile)) ? $node : ($node && $self->next);
Branch: 1 branch
BranchTrueFalseTotal
$node && $self->[0]->($node, $fsfile) ? : 0 0 0
Condition0%0/6
$node and $self->[0]->($node, $fsfile)
!ll&&!rl&&r
000
$node and $self->next
!ll&&!rl&&r
000
MC/DC0%0/2
$node and $self->[0]->($node, $fsfile)
$node $self->[0]->($node, $fsfile)
MC/DC0%0/2
$node and $self->next
$node $self->next
Truth table0%0/3
A and B
A= $nodeB= $self->[0]->($node, $fsfile)
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $nodeB= $self->next
ABresult
0X0
100
111
43 }
44 sub next {
45 0 ▶ my ($self)=@_;
Subroutine next: not called CC=7 SCAR=40.3
Pod undocumented
46 0 my $conditions=$self->[CONDITIONS];
47 0 my $max = $self->[MAX];
48 0 my $depth = $self->[DEPTH];
49 0 ▶ return $self->[NODE]=undef if (defined($max) and $depth>=$max);
Branch: 1 branch
BranchTrueFalseTotal
if defined $max and $depth >= $max 0 0 0
Condition0%0/3
defined $max and $depth >= $max
!ll&&!rl&&r
000
MC/DC0%0/2
defined $max and $depth >= $max
defined $max $depth >= $max
Truth table0%0/3
A and B
A= defined $maxB= $depth >= $max
ABresult
0X0
100
111
50 0 my $n=$self->[NODE]->parent;
51 0 $depth++;
52 0 my $fsfile = $self->[FILE];
53 0 ▶ while ($n and !$conditions->($n,$fsfile)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n and not &$conditions($n, $fsfile)) 0 0 0
Condition0%0/3
$n and not &$conditions($n, $fsfile)
!ll&&!rl&&r
000
MC/DC0%0/2
$n and not &$conditions($n, $fsfile)
$n not &$conditions($n, $fsfile)
Truth table0%0/3
A and not(B)
A= $nB= not &$conditions($n, $fsfile)
ABresult
0X0
100
111
54 0 $depth++;
55 0 ▶ if (defined($max) and $depth<=$max) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $max and $depth <= $max) { } 0 0 0
Condition0%0/3
defined $max and $depth <= $max
!ll&&!rl&&r
000
MC/DC0%0/2
defined $max and $depth <= $max
defined $max $depth <= $max
Truth table0%0/3
A and B
A= defined $maxB= $depth <= $max
ABresult
0X0
100
111
56 0 $n=$n->parent;
57 } else {
58 0 $n=undef;
59 }
60 }
61 0 $self->[DEPTH]=$depth;
62 0 return $self->[NODE]=$n;
63 }
64 sub node {
65 0 ▶ return $_[0]->[NODE];
Subroutine node: not called CC=1 SCAR=6.9
Pod undocumented
66 }
67 sub file {
68 0 ▶ return $_[0]->[FILE];
Subroutine file: not called CC=1 SCAR=6.9
Pod undocumented
69 }
70 sub reset {
71 0 ▶ my ($self)=@_;
Subroutine reset: not called CC=1 SCAR=6.9
Pod undocumented
72 0 $self->[NODE]=undef;
73 0 $self->[FILE]=undef;
74 }
75  
76 12 1; # End of PMLTQ::Relation::AncestorIteratorWithBoundedDepth
77  
78 __END__
« blib/lib/PMLTQ/Relation/CurrentFileIterator.pm ↑ Summary blib/lib/PMLTQ/Command.pm »