blib/lib/PMLTQ/Relation/TreeIterator.pm

filter: Statementstmt 56.8% 29 / 51 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 50.0% 9 / 18 Podpod 0.0% 0 / 9 totaltotal 39.5% 38 / 96 CC 7 SCAR 18.3
CC
7
Cov
45%
start
20.0
next
12.0
new
6.0
CRAP 6.2
« blib/lib/PMLTQ/Relation/SimpleListIterator.pm ↑ Summary blib/lib/PMLTQ/Relation.pm »
1 package PMLTQ::Relation::TreeIterator;
2 13 our $AUTHORITY = 'cpan:MATY';
3 13 $PMLTQ::Relation::TreeIterator::VERSION = '1.5.0';
4 # ABSTRACT: Evaluates condition on the whole tree of given node
5  
6 13 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 13 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 13 ▶use base qw(PMLTQ::Relation::Iterator);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 13 ▶use constant CONDITIONS=>0;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 13 ▶use constant TREE=>1;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 13 ▶use constant NODE=>2;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 13 ▶use constant FILE=>3;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 sub new {
18 0 ▶ my ($class,$conditions,$root,$fsfile)=@_;
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
19 0 ▶ croak "usage: $class->new(sub{...})" unless ref($conditions) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $conditions eq "CODE" 0 0 0
20 0 return bless [$conditions,$root,undef,$fsfile],$class;
21 }
22 sub clone {
23 0 ▶ my ($self)=@_;
Subroutine clone: not called CC=1 SCAR=6.9
Pod undocumented
24 0 return bless [$self->[CONDITIONS],$self->[NODE],$self->[TREE],$self->[FILE]], ref($self);
25 }
26 sub start {
27 0 ▶ my ($self)=@_;
Subroutine start: not called CC=4 SCAR=30.0
Pod undocumented
28 0 my $root = $self->[NODE] = $self->[TREE];
29 0 ▶ return ($root && $self->[CONDITIONS]->($root,$self->[FILE])) ? $root : ($root && $self->next);
Branch: 1 branch
BranchTrueFalseTotal
$root && $self->[0]->($root, $self->[3]) ? : 0 0 0
Condition0%0/6
$root and $self->[0]->($root, $self->[3])
!ll&&!rl&&r
000
$root and $self->next
!ll&&!rl&&r
000
MC/DC0%0/2
$root and $self->[0]->($root, $self->[3])
$root $self->[0]->($root, $self->[3])
MC/DC0%0/2
$root and $self->next
$root $self->next
Truth table0%0/3
A and B
A= $rootB= $self->[0]->($root, $self->[3])
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $rootB= $self->next
ABresult
0X0
100
111
30 }
31 sub next {
32 0 ▶ my ($self)=@_;
Subroutine next: not called CC=3 SCAR=24.8
Pod undocumented
33 0 my $conditions=$self->[CONDITIONS];
34 0 my $n=$self->[NODE];
35 0 my $fsfile=$self->[FILE];
36 0 ▶ while ($n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n) 0 0 0
37 0 $n = $n->following;
38 0 ▶ last if $conditions->($n,$fsfile);
Branch: 1 branch
BranchTrueFalseTotal
if &$conditions($n, $fsfile) 0 0 0
39 }
40 0 return $self->[NODE]=$n;
41 }
42 sub node {
43 0 ▶ return $_[0]->[NODE];
Subroutine node: not called CC=1 SCAR=6.9
Pod undocumented
44 }
45 sub file {
46 0 ▶ return $_[0]->[FILE];
Subroutine file: not called CC=1 SCAR=6.9
Pod undocumented
47 }
48 sub set_file {
49 0 ▶ $_[0]->[FILE] = $_[1];
Subroutine set_file: not called CC=1 SCAR=6.9
Pod undocumented
50 }
51 sub set_tree {
52 0 ▶ $_[0]->[TREE] = $_[1];
Subroutine set_tree: not called CC=1 SCAR=6.9
Pod undocumented
53 }
54 sub reset {
55 0 ▶ my ($self)=@_;
Subroutine reset: not called CC=1 SCAR=6.9
Pod undocumented
56 0 $self->[NODE]=undef;
57 }
58  
59 13 1; # End of PMLTQ::Relation::TreeIterator
60  
61 __END__
« blib/lib/PMLTQ/Relation/SimpleListIterator.pm ↑ Summary blib/lib/PMLTQ/Relation.pm »