Visitor/BreadthFirstTraversal.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 8 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 93.5% 58 / 62 CC 7 SCAR 12.4
CC
7
Cov
96%
visit
6.0
new
2.0
BEGIN
1.0
CRAP 3.5
« Visitor/PathToRoot.pm ↑ Summary Visitor/ToNestedArray.pm »
1 package Tree::Simple::Visitor::BreadthFirstTraversal;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 our $VERSION = '0.16';
7  
8 4 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 ▶use base qw(Tree::Simple::Visitor);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 6 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod documented
13 6 my ($_class) = @_;
14 6 ▶ my $class = ref($_class) || $_class;
Condition33%1/3
ref $_class || $_class
l!l&&r!l&&!r
060
MC/DC0%0/2
ref $_class || $_class
ref $_class $_class
Truth table33%1/3
A || B
A= ref $_classB= $_class
ABresult
1X1
011
000
15 6 my $visitor = {};
16 6 bless($visitor, $class);
17 6 $visitor->_init();
18 6 return $visitor;
19 }
20  
21 6 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
22 6 my ($self) = @_;
23 6 $self->SUPER::_init();
24 }
25  
26 11 ▶sub visit {
Subroutine visit: called CC=6 SCAR=17.9
Pod documented
27 11 my ($self, $tree) = @_;
28 11 ▶ (blessed($tree) && $tree->isa("Tree::Simple"))
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($tree) and $tree->isa("Tree::Simple") or die "Insufficient Arguments : You must supply a valid Tree::Simple object" 7 4 11
Condition100%3/3
builtin::blessed($tree) and $tree->isa("Tree::Simple")
!ll&&!rl&&r
317
MC/DC100%2/2
builtin::blessed($tree) and $tree->isa("Tree::Simple")
builtin::blessed($tree) $tree->isa("Tree::Simple")
Truth table100%3/3
A and B
A= builtin::blessed($tree)B= $tree->isa("Tree::Simple")
ABresult
0X0
100
111
29 || die "Insufficient Arguments : You must supply a valid Tree::Simple object";
30 # create a holder for our results
31 7 my @results;
32 # get our filter function
33 7 my $filter_function = $self->getNodeFilter();
34 # now create a queue for
35 # processing depth first
36 7 my @queue;
37 # if we are to include the trunk
38 7 ▶ if ($self->includeTrunk()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->includeTrunk) { } 3 4 7
39 # then enqueue that
40 3 @queue = ($tree);
41 }
42 # if we are not including the trunk
43 else {
44 # then we enqueue all the
45 # trunks children instead
46 4 @queue = ($tree->getAllChildren());
47 }
48 # until our queue is empty
49 7 ▶ while (scalar(@queue) != 0){
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @queue != 0) 78 3 81
50 # get the first item off the queue
51 78 my $current_tree = shift @queue;
52 # enqueue all the current tree's children
53 78 push @queue => $current_tree->getAllChildren();
54 # now collect the results
55 78 ▶ push @results => (($filter_function) ?
Branch: 1 branch
BranchTrueFalseTotal
$filter_function ? : 63 15 78
56 $filter_function->($current_tree)
57 :
58 $current_tree->getNodeValue());
59 }
60 # store our results
61 3 $self->setResults(@results);
62 }
63  
64 4 1;
65  
66 __END__
« Visitor/PathToRoot.pm ↑ Summary Visitor/ToNestedArray.pm »