blib/lib/PMLTQ/Relation/DescendantIteratorWithBoundedDepth.pm

filter: Statementstmt 45.4% 35 / 77 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 20 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 61.1% 11 / 18 Podpod 0.0% 0 / 7 totaltotal 30.8% 46 / 149 CC 16 SCAR 38.7
CC
16
Cov
31%
next
132.0
start
20.0
new
12.0
CRAP 48.1
« blib/lib/PMLTQ/Command/convert.pm ↑ Summary blib/lib/PMLTQ/Relation/TreexFileIterator.pm »
1 package PMLTQ::Relation::DescendantIteratorWithBoundedDepth;
2 12 our $AUTHORITY = 'cpan:MATY';
3 12 $PMLTQ::Relation::DescendantIteratorWithBoundedDepth::VERSION = '1.2.2';
4 # ABSTRACT: Iterates over descendant nodes in given boundaries
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 DEPTH=>3;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 12 ▶use constant NODE=>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,$parent,$fsfile)=@_;
Subroutine start: not called CC=4 SCAR=30.0
Pod undocumented
31 0 $self->[FILE]=$fsfile;
32 0 my $n=$parent->firstson;
33 0 $self->[DEPTH]=1;
34 0 $self->[NODE]=$n;
35 0 ▶ return ($self->[MIN]<=1 and $self->[CONDITIONS]->($n,$fsfile)) ? $n : ($n && $self->next);
Branch: 1 branch
BranchTrueFalseTotal
$self->[1] <= 1 && $self->[0]->($n, $fsfile) ? : 0 0 0
Condition0%0/6
$self->[1] <= 1 and $self->[0]->($n, $fsfile)
!ll&&!rl&&r
000
$n and $self->next
!ll&&!rl&&r
000
MC/DC0%0/2
$self->[1] <= 1 and $self->[0]->($n, $fsfile)
$self->[1] <= 1 $self->[0]->($n, $fsfile)
MC/DC0%0/2
$n and $self->next
$n $self->next
Truth table0%0/3
A and B
A= $self->[1] <= 1B= $self->[0]->($n, $fsfile)
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $nB= $self->next
ABresult
0X0
100
111
36 }
37 sub next {
38 0 ▶ my ($self)=@_;
Subroutine next: not called CC=11 SCAR=48.8
Pod undocumented
39 0 my $min = $self->[MIN];
40 0 my $max = $self->[MAX];
41 0 my $depth = $self->[DEPTH];
42 0 my $conditions=$self->[CONDITIONS];
43 0 my $n = $self->[NODE];
44 0 my $fsfile=$self->[FILE];
45 0 my $r;
46 SEARCH:
47 0 ▶ while ($n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n) 0 0 0
48 0 ▶ if ((!defined($max) or ($depth<$max)) and $n->firstson) {
Branch: 1 branch
BranchTrueFalseTotal
if (!defined($max) || $depth < $max and $n->firstson) { } 0 0 0
Condition0%0/6
!defined($max) || $depth < $max and $n->firstson
!ll&&!rl&&r
000
not defined $max or $depth < $max
l!l&&r!l&&!r
000
MC/DC0%0/3
!defined($max) || $depth < $max and $n->firstson
not defined $max $depth < $max $n->firstson
Truth table0%0/5
not(A) or B and C
A= not defined $maxB= $depth < $maxC= $n->firstson
ABCresult
00X0
1X00
0100
1X11
0111
49 0 $n=$n->firstson;
50 0 $depth++;
51 } else {
52 0 ▶ while ($n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n) 0 0 0
53 0 ▶ if ($depth == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($depth == 0) 0 0 0
54 0 undef $n;
55 0 last SEARCH;
56 }
57 0 ▶ if ($r = $n->rbrother) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r = $n->rbrother) { } 0 0 0
58 0 $n=$r;
59 0 last;
60 } else {
61 0 $n=$n->parent;
62 0 $depth--;
63 }
64 }
65 }
66 0 ▶ if ($n and $min<=$depth and $conditions->($n,$fsfile)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n and $min <= $depth and &$conditions($n, $fsfile)) 0 0 0
Condition0%0/6
$n and $min <= $depth and &$conditions($n, $fsfile)
!ll&&!rl&&r
000
$n and $min <= $depth
!ll&&!rl&&r
000
MC/DC0%0/3
$n and $min <= $depth and &$conditions($n, $fsfile)
$n $min <= $depth &$conditions($n, $fsfile)
Truth table0%0/4
A and B and C
A= $nB= $min <= $depthC= &$conditions($n, $fsfile)
ABCresult
0XX0
10X0
1100
1111
67 0 $self->[DEPTH]=$depth;
68 0 return $self->[NODE]=$n;
69 }
70 }
71 0 return $self->[NODE]=undef;
72 }
73 sub file {
74 0 ▶ return $_[0]->[FILE];
Subroutine file: not called CC=1 SCAR=6.9
Pod undocumented
75 }
76 sub node {
77 0 ▶ return $_[0]->[NODE];
Subroutine node: not called CC=1 SCAR=6.9
Pod undocumented
78 }
79 sub reset {
80 0 ▶ my ($self)=@_;
Subroutine reset: not called CC=1 SCAR=6.9
Pod undocumented
81 0 $self->[NODE]=undef;
82 0 $self->[FILE]=undef;
83 }
84  
85 12 1; # End of PMLTQ::Relation::DescendantIteratorWithBoundedDepth
86  
87 __END__
« blib/lib/PMLTQ/Command/convert.pm ↑ Summary blib/lib/PMLTQ/Relation/TreexFileIterator.pm »