lib/XML/XMetaL/Mock/DOMNodeList.pm

filter: Statementstmt 86.9% 40 / 46 Branchbran 50.0% 4 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 10 / 12 Podpod 0.0% 0 / 4 totaltotal 73.3% 55 / 75 CC 7 SCAR 9.9
CC
7
Cov
79%
hasChildNodes
6.0
new
4.3
add
3.0
CRAP 2.7
« lib/XML/XMetaL.pm ↑ Summary lib/XML/XMetaL/Mock/DOMNode.pm »
1 package XML::XMetaL::Mock::DOMNodeList;
2
3 4 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Hash::Util qw(lock_keys);
Subroutine BEGIN: called CC=1 SCAR=0.0
9
10 4 ▶use constant TRUE => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use constant FALSE => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
12
13 6 ▶sub new {
Subroutine new: called CC=4 SCAR=14.6
Pod undocumented
14 6 my ($class, @items) = @_;
15 6 my $self;
16 6 eval {
17 #lock_keys(%args,qw());
18 6 ▶ $self = bless {
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
19 length => undef,
20 _node_list => [],
21 }, ref($class) || $class;
22 6 lock_keys(%$self, keys %$self);
23 6 ▶ $self->add(@items) if @items;
Branch: 1 branch
BranchTrueFalseTotal
if @items 0 6 6
24 };
25 6 ▶ croak $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 6 6
26 6 return $self;
27 }
28
29 3 ▶sub add {
Subroutine add: called CC=3 SCAR=11.0
Pod undocumented
30 3 my ($self, @items) = @_;
31 3 my $node_list = $self->{_node_list};
32 #push @$node_list, grep {eval{$_->isa('XML::XMetaL::Mock::DOMNode')}} @items;
33 3 my $last_node_in_list;
34 3 foreach my $item (@items) {
35 3 ▶ if (scalar(@$node_list)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$node_list) 1 2 3
36 1 $last_node_in_list = $$node_list[-1];
37 1 $self->_link_to_next($last_node_in_list, $item);
38 #$self->_link_to_previous($last_node_in_list, $item);
39 }
40 3 push @$node_list, $item;
41 }
42 3 $self->{length} = scalar @$node_list;
43 }
44
45 1 ▶sub _link_to_next {
Subroutine _link_to_next: called CC=1 SCAR=0.0
46 1 my ($self, $previous_node, $next_node) = @_;
47 1 $previous_node->{nextSibling} = $next_node;
48 }
49
50 0 ▶sub item {
Subroutine item: not called CC=1 SCAR=6.9
Pod undocumented
51 0 my ($self, $index) = @_;
52 0 my $node_list = $self->{_node_list};
53 0 return $$node_list[$index];
54 }
55
56 #cloneNode
57
58 0 ▶sub hasChildNodes {
Subroutine hasChildNodes: not called CC=2 SCAR=17.9
Pod undocumented
59 0 my $self = shift @_;
60 0 my XML::XMetaL::Mock::DOMNodeList $child_node_list = $self->{_node_list};
61 0 ▶ return scalar(@$child_node_list) ? TRUE : FALSE;
Branch: 1 branch
BranchTrueFalseTotal
scalar @$child_node_list ? : 0 0 0
62 }
63
64 #insertBefore
65 #removeChild
66 #replaceChild
67
68
69 4 1;
70 __END__
« lib/XML/XMetaL.pm ↑ Summary lib/XML/XMetaL/Mock/DOMNode.pm »