lib/XML/XMetaL/Mock/DOMNode.pm

filter: Statementstmt 94.2% 49 / 52 Branchbran 50.0% 3 / 6 Conditioncond 28.5% 2 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 91.6% 11 / 12 Podpod 0.0% 0 / 3 totaltotal 77.3% 65 / 84 CC 7 SCAR 7.5
CC
7
Cov
83%
_set_node_type
3.2
new
3.1
appendChild
3.1
CRAP 2.1
« lib/XML/XMetaL/Mock/DOMNodeList.pm ↑ Summary blib/lib/XML/gmcr.pl »
1 package XML::XMetaL::Mock::DOMNode;
2
3 3 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Hash::Util qw(lock_keys);
Subroutine BEGIN: called CC=1 SCAR=0.0
9
10 3 ▶use XML::XMetaL::Mock::DOMNodeList;
Subroutine BEGIN: called CC=1 SCAR=0.0
11
12 3 ▶use constant TRUE => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use constant FALSE => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
14
15 3 our @keys = qw(
16 nodeID
17 attributes
18 childNodes
19 firstChild
20 lastChild
21 nextSibling
22 nodeName
23 nodeType
24 nodeValue
25 ownerDocument
26 parentNode
27 previousSibling
28 );
29
30 3 our %node_types = (
31 DOMElement => 1,
32 DOMAttr => 2,
33 DOMText => 3,
34 DOMCDATASection => 4,
35 DOMEntityReference => 5,
36 DOMEntity => 6,
37 DOMProcessingInstruction => 7,
38 DOMComment => 8,
39 DOMDocument => 9,
40 DOMDocumentType => 10,
41 DOMDocumentFragment => 11,
42 DOMNotation => 12,
43 DOMCharacterReference => 505,
44 );
45
46 6 ▶sub new {
Subroutine new: called CC=3 SCAR=11.2
Pod undocumented
47 6 my ($class, %args) = @_;
48 6 my $self;
49 6 eval {
50 6 my %properties;
51 6 @properties{@keys} = @args{@keys};
52 6 ▶ $self = bless \%properties, 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
53 #lock_keys(%$self, @keys);
54 6 $self->{childNodes} = XML::XMetaL::Mock::DOMNodeList->new();
55 6 $self->_set_node_type();
56 };
57 6 ▶ croak $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 6 6
58 6 return $self;
59 }
60
61 6 ▶sub _set_node_type {
Subroutine _set_node_type: called CC=3 SCAR=11.8
62 6 my ($self) = @_;
63 6 my $class = ref $self;
64 6 my ($key) = $class =~ /([^:]+)$/;
65 croak "Node name ".($key || "FALSE")." does not exist"
66 6 ▶ unless exists $node_types{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $XML::XMetaL::Mock::DOMNode::node_types{$key} 0 6 6
Condition0%0/2
$key || 'FALSE'
l!l
00
MC/DC0%0/1
$key || 'FALSE'
$key
Truth table0%0/2
A
A= $key
Aresult
11
00
67 6 my $node_type = $node_types{$key};
68 6 $self->{nodeType} = $node_type;
69 }
70
71 3 ▶sub appendChild {
Subroutine appendChild: called CC=3 SCAR=11.2
Pod undocumented
72 3 eval {
73 3 my $self = shift @_;
74 3 ▶ my XML::XMetaL::Mock::DOMNode $child_node = shift(@_) || croak("Missing argument");
Condition50%1/2
shift @_ || croak('Missing argument')
l!l
30
MC/DC0%0/1
shift @_ || croak('Missing argument')
shift @_
Truth table50%1/2
A
A= shift @_
Aresult
11
00
75 3 my XML::XMetaL::Mock::DOMNodeList $child_node_list = $self->{childNodes};
76 3 $child_node->{parentNode} = $self;
77 3 $child_node_list->add($child_node);
78 };
79 3 ▶ croak $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 3 3
80 }
81
82 #cloneNode
83
84 0 ▶sub hasChildNodes {
Subroutine hasChildNodes: not called CC=1 SCAR=6.9
Pod undocumented
85 0 my $self = shift @_;
86 0 my XML::XMetaL::Mock::DOMNodeList $child_node_list = $self->{childNodes};
87 0 return $child_node_list->hasChildNodes();
88 }
89
90 #insertBefore
91 #removeChild
92 #replaceChild
93
94
95 3 1;
96 __END__
« lib/XML/XMetaL/Mock/DOMNodeList.pm ↑ Summary blib/lib/XML/gmcr.pl »