Data/ZPath/Node.pm

filter: Statementstmt 86.8% 179 / 206 Branchbran 69.7% 120 / 172 Conditioncond 72.3% 123 / 170 MC/DCmcdc 43.8% 46 / 105 Subroutinesub 96.5% 28 / 29 Podpod 100% 19 / 19 totaltotal 73.4% 515 / 701 CC 146 SCAR 33.8
CC
146
Cov
77%
primitive_value
87.6
_is_bool
31.7
type
27.2
CRAP 29.5
« Data/ZPath/_Parser.pm ↑ Summary Text/ZTemplate.pm »
1 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Data::ZPath::Node;
5  
6 9 ▶use B ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶use Scalar::Util qw(blessed refaddr reftype isdual);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 9 our $VERSION = '0.001000';
10  
11 2181 ▶sub _created_as_string {
Subroutine _created_as_string: called CC=4 SCAR=17.9
12 2181 my $value = shift;
13 2181 ▶ defined $value
Branch: 1 branch
BranchTrueFalseTotal
defined $value and not ref $value and not _is_bool($value) and not _created_as_number($value) 2181 0 2181
Condition33%2/6
defined $value and not ref $value and not _is_bool($value)
!ll&&!rl&&r
002181
defined $value and not ref $value
!ll&&!rl&&r
002181
MC/DC0%0/3
defined $value and not ref $value and not _is_bool($value)
defined $value not ref $value not _is_bool($value)
Truth table25%1/4
A and not(B) and not(C)
A= defined $valueB= not ref $valueC= not _is_bool($value)
ABCresult
0XX0
10X0
1100
1111
14 and not ref $value
15 and not _is_bool( $value )
16 and not _created_as_number( $value );
17 }
18  
19 5518 ▶sub _created_as_number {
Subroutine _created_as_number: called CC=6 SCAR=18.0
20 5518 my $value = shift;
21 5518 ▶ return !!0 unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 5518 5518
22 5518 ▶ return !!0 if ref $value;
Branch: 1 branch
BranchTrueFalseTotal
if ref $value 0 5518 5518
23 5518 ▶ return !!0 if utf8::is_utf8( $value );
Branch: 1 branch
BranchTrueFalseTotal
if utf8::is_utf8($value) 84 5434 5518
24 5434 my $b_obj = B::svref_2object(\$value);
25 5434 my $flags = $b_obj->FLAGS;
26 5434 ▶ return !!1 if $flags & ( B::SVp_IOK() | B::SVp_NOK() ) and not( $flags & B::SVp_POK() );
Branch: 1 branch
BranchTrueFalseTotal
if $flags & 12288 and not $flags & 16384 1156 4278 5434
Condition100%3/3
$flags & 12288 and not $flags & 16384
!ll&&!rl&&r
4242361156
MC/DC100%2/2
$flags & 12288 and not $flags & 16384
$flags & 12288 not $flags & 16384
Truth table100%3/3
A and not(B)
A= $flags & 12288B= not $flags & 16384
ABresult
0X0
100
111
27 4278 return !!0;
28 }
29  
30 5615 ▶sub _is_bool {
Subroutine _is_bool: called CC=19 SCAR=34.6
31 5615 my $value = shift;
32  
33 5615 ▶ my $ref = ref($value) || '';
Condition100%2/2
ref $value || ''
l!l
975518
MC/DC100%1/1
ref $value || ''
ref $value
Truth table100%2/2
A
A= ref $value
Aresult
11
00
34 5615 ▶ if ( $ref eq 'SCALAR' and defined $$value ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref eq "SCALAR" and defined $$value) 1 5614 5615
Condition66%2/3
$ref eq "SCALAR" and defined $$value
!ll&&!rl&&r
561401
MC/DC50%1/2
$ref eq "SCALAR" and defined $$value
$ref eq "SCALAR" defined $$value
Truth table66%2/3
A and B
A= $ref eq "SCALAR"B= defined $$value
ABresult
0X0
100
111
35 1 ▶ return !!1 if $$value eq 0;
Branch: 1 branch
BranchTrueFalseTotal
if $$value eq 0 0 1 1
36 1 ▶ return !!1 if $$value eq 1;
Branch: 1 branch
BranchTrueFalseTotal
if $$value eq 1 1 0 1
37 }
38  
39 5614 ▶ if ( blessed($value) and $value->isa('Types::Serialiser::Boolean') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Types::Serialiser::Boolean")) 0 5614 5614
Condition66%2/3
builtin::blessed($value) and $value->isa("Types::Serialiser::Boolean")
!ll&&!rl&&r
5518960
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Types::Serialiser::Boolean")
builtin::blessed($value) $value->isa("Types::Serialiser::Boolean")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("Types::Serialiser::Boolean")
ABresult
0X0
100
111
40 0 return !!1;
41 }
42  
43 5614 ▶ if ( blessed($value) and $value->isa('JSON::PP::Boolean') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("JSON::PP::Boolean")) 96 5518 5614
Condition66%2/3
builtin::blessed($value) and $value->isa("JSON::PP::Boolean")
!ll&&!rl&&r
5518096
MC/DC50%1/2
builtin::blessed($value) and $value->isa("JSON::PP::Boolean")
builtin::blessed($value) $value->isa("JSON::PP::Boolean")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("JSON::PP::Boolean")
ABresult
0X0
100
111
44 96 return !!1;
45 }
46  
47 5518 ▶ return !!0 unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 5518 5518
48 5518 ▶ return !!0 if $ref;
Branch: 1 branch
BranchTrueFalseTotal
if $ref 0 5518 5518
49 5518 ▶ return !!0 unless isdual( $value );
Branch: 1 branch
BranchTrueFalseTotal
unless &isdual($value) 5482 36 5518
50 36 ▶ return !!1 if $value and "$value" eq '1' and $value + 0 == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $value and "$value" eq 1 and $value + 0 == 1 0 36 36
Condition33%2/6
$value and "$value" eq 1 and $value + 0 == 1
!ll&&!rl&&r
3600
$value and "$value" eq 1
!ll&&!rl&&r
3600
MC/DC0%0/3
$value and "$value" eq 1 and $value + 0 == 1
$value "$value" eq 1 $value + 0 == 1
Truth table25%1/4
A and B and C
A= $valueB= "$value" eq 1C= $value + 0 == 1
ABCresult
0XX0
10X0
1100
1111
51 36 ▶ return !!1 if not $value and "$value" eq q'' and $value + 0 == 0;
Branch: 1 branch
BranchTrueFalseTotal
if not $value and "$value" eq "" and $value + 0 == 0 0 36 36
Condition33%2/6
not $value and "$value" eq "" and $value + 0 == 0
!ll&&!rl&&r
3600
not $value and "$value" eq ""
!ll&&!rl&&r
0360
MC/DC0%0/3
not $value and "$value" eq "" and $value + 0 == 0
not $value "$value" eq "" $value + 0 == 0
Truth table25%1/4
not(A) and B and C
A= not $valueB= "$value" eq ""C= $value + 0 == 0
ABCresult
0XX0
10X0
1100
1111
52 36 return !!0;
53 }
54  
55 424 ▶sub from_root {
Subroutine from_root: called CC=1 SCAR=0.0
Pod documented
56 424 my ( $class, $obj ) = @_;
57 424 return $class->_wrap($obj);
58 }
59  
60 10174 ▶sub _wrap {
Subroutine _wrap: called CC=9 SCAR=22.0
61 10174 my ( $class, $obj, $parent, $key, $ix ) = @_;
62  
63 10174 ▶ my $is_xml = blessed($obj) && $obj->isa('XML::LibXML::Node');
Condition100%3/3
builtin::blessed($obj) && $obj->isa('XML::LibXML::Node')
!ll&&!rl&&r
65041053565
MC/DC100%2/2
builtin::blessed($obj) && $obj->isa('XML::LibXML::Node')
builtin::blessed($obj) $obj->isa('XML::LibXML::Node')
Truth table100%3/3
A && B
A= builtin::blessed($obj)B= $obj->isa('XML::LibXML::Node')
ABresult
0X0
100
111
64 10174 my $id;
65  
66 10174 ▶ if ( blessed($obj) && $obj->isa('XML::LibXML::Document') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($obj) and $obj->isa("XML::LibXML::Document")) 86 10088 10174
Condition100%3/3
builtin::blessed($obj) and $obj->isa("XML::LibXML::Document")
!ll&&!rl&&r
6504358486
MC/DC100%2/2
builtin::blessed($obj) and $obj->isa("XML::LibXML::Document")
builtin::blessed($obj) $obj->isa("XML::LibXML::Document")
Truth table100%3/3
A and B
A= builtin::blessed($obj)B= $obj->isa("XML::LibXML::Document")
ABresult
0X0
100
111
67 86 $obj = $obj->documentElement;
68 86 $key = $obj->nodeName;
69 86 $is_xml = 1;
70 }
71  
72 10174 ▶ if ( $is_xml ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($is_xml) { } 3565 6609 10174
elsif (ref $obj) { } 1806 4803 6609
elsif ($parent) { } 3019 1784 4803
73 3565 $id = 'xml:' . refaddr($obj);
74 } elsif ( ref($obj) ) {
75 1806 $id = 'ref:' . refaddr($obj);
76 } elsif ( $parent ) {
77 3019 my $pid = $parent->id;
78 3019 ▶ $pid = 'root' unless defined $pid;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pid 0 3019 3019
79 3019 ▶ my $k = defined $key ? $key : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $key ? : 3019 0 3019
80 3019 $id = 'slot:' . $pid . ':' . $k;
81 } else {
82 # primitive: no stable identity, but used as a value node (not deduped as a tree node)
83 1784 $id = undef;
84 }
85  
86 10174 return bless {
87 raw => $obj,
88 parent => $parent,
89 key => $key,
90 id => $id,
91 ix => $ix,
92 slot => undef, # coderef getter/setter for Perl scalar lvalue
93 }, $class;
94 }
95  
96 4643 ▶sub raw { $_[0]{raw} }
Subroutine raw: called CC=1 SCAR=0.0
Pod documented
97 197 ▶sub parent { $_[0]{parent} }
Subroutine parent: called CC=1 SCAR=0.0
Pod documented
98 45 ▶sub key { $_[0]{key} }
Subroutine key: called CC=1 SCAR=0.0
Pod documented
99 7220 ▶sub id { $_[0]{id} }
Subroutine id: called CC=1 SCAR=0.0
Pod documented
100 28 ▶sub ix { $_[0]{ix} }
Subroutine ix: called CC=1 SCAR=0.0
Pod documented
101 3 ▶sub index { $_[0]{ix} }
Subroutine index: called CC=1 SCAR=0.0
Pod documented
102  
103 5 ▶sub slot {
Subroutine slot: called CC=1 SCAR=0.0
Pod documented
104 5 my ( $self ) = @_;
105 5 return $self->{slot};
106 }
107  
108 3020 ▶sub with_slot {
Subroutine with_slot: called CC=1 SCAR=0.0
Pod documented
109 3020 my ( $self, $slot ) = @_;
110 3020 $self->{slot} = $slot;
111 3020 return $self;
112 }
113  
114 8380 ▶sub type {
Subroutine type: called CC=24 SCAR=33.0
Pod documented
115 8380 my ( $self, $x ) = @_;
116 8380 ▶ $x = $self->{raw} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 8378 2 8380
117  
118 8380 ▶ if ( blessed($x) && $x->isa('CBOR::Free::Tagged') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("CBOR::Free::Tagged")) 2 8378 8380
Condition100%3/3
builtin::blessed($x) and $x->isa("CBOR::Free::Tagged")
!ll&&!rl&&r
484035382
MC/DC100%2/2
builtin::blessed($x) and $x->isa("CBOR::Free::Tagged")
builtin::blessed($x) $x->isa("CBOR::Free::Tagged")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("CBOR::Free::Tagged")
ABresult
0X0
100
111
119 2 return $self->type($x->[1]);
120 }
121  
122 8378 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Namespace') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Namespace")) 0 8378 8378
Condition66%2/3
builtin::blessed($x) and $x->isa("XML::LibXML::Namespace")
!ll&&!rl&&r
484035380
MC/DC0%0/2
builtin::blessed($x) and $x->isa("XML::LibXML::Namespace")
builtin::blessed($x) $x->isa("XML::LibXML::Namespace")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Namespace")
ABresult
0X0
100
111
123 0 return 'attr';
124 }
125 8378 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Attr') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Attr")) 27 8351 8378
Condition100%3/3
builtin::blessed($x) and $x->isa("XML::LibXML::Attr")
!ll&&!rl&&r
4840351127
MC/DC100%2/2
builtin::blessed($x) and $x->isa("XML::LibXML::Attr")
builtin::blessed($x) $x->isa("XML::LibXML::Attr")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Attr")
ABresult
0X0
100
111
126 27 return 'attr';
127 }
128 8351 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Text') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Text")) 1278 7073 8351
Condition100%3/3
builtin::blessed($x) and $x->isa("XML::LibXML::Text")
!ll&&!rl&&r
484022331278
MC/DC100%2/2
builtin::blessed($x) and $x->isa("XML::LibXML::Text")
builtin::blessed($x) $x->isa("XML::LibXML::Text")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Text")
ABresult
0X0
100
111
129 1278 return 'text';
130 }
131 7073 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Element') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Element")) 2137 4936 7073
Condition100%3/3
builtin::blessed($x) and $x->isa("XML::LibXML::Element")
!ll&&!rl&&r
4840962137
MC/DC100%2/2
builtin::blessed($x) and $x->isa("XML::LibXML::Element")
builtin::blessed($x) $x->isa("XML::LibXML::Element")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Element")
ABresult
0X0
100
111
132 2137 return 'element';
133 }
134 4936 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Document') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Document")) 0 4936 4936
Condition66%2/3
builtin::blessed($x) and $x->isa("XML::LibXML::Document")
!ll&&!rl&&r
4840960
MC/DC0%0/2
builtin::blessed($x) and $x->isa("XML::LibXML::Document")
builtin::blessed($x) $x->isa("XML::LibXML::Document")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Document")
ABresult
0X0
100
111
135 0 return 'document';
136 }
137 4936 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Comment') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Comment")) 0 4936 4936
Condition66%2/3
builtin::blessed($x) and $x->isa("XML::LibXML::Comment")
!ll&&!rl&&r
4840960
MC/DC0%0/2
builtin::blessed($x) and $x->isa("XML::LibXML::Comment")
builtin::blessed($x) $x->isa("XML::LibXML::Comment")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Comment")
ABresult
0X0
100
111
138 0 return 'comment';
139 }
140  
141 4936 ▶ if ( blessed($x) && $x->isa('Math::BigInt') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("Math::BigInt")) 0 4936 4936
Condition66%2/3
builtin::blessed($x) and $x->isa("Math::BigInt")
!ll&&!rl&&r
4840960
MC/DC0%0/2
builtin::blessed($x) and $x->isa("Math::BigInt")
builtin::blessed($x) $x->isa("Math::BigInt")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("Math::BigInt")
ABresult
0X0
100
111
142 0 return 'number';
143 }
144  
145 4936 ▶ return 'null' unless defined $x;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 101 4835 4936
146 4835 ▶ return 'map' if ref($x) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $x eq "HASH" 872 3963 4835
147 3963 ▶ return 'list' if ref($x) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $x eq "ARRAY" 529 3434 3963
148 3434 ▶ return 'boolean' if _is_bool($x);
Branch: 1 branch
BranchTrueFalseTotal
if _is_bool($x) 97 3337 3434
149 3337 ▶ return 'number' if _created_as_number($x);
Branch: 1 branch
BranchTrueFalseTotal
if _created_as_number($x) 1156 2181 3337
150 2181 ▶ return 'string' if _created_as_string($x);
Branch: 1 branch
BranchTrueFalseTotal
if _created_as_string($x) 2181 0 2181
151 0 return ref($x);
152 }
153  
154 # Essentially returns raw, but normalizes booleans
155 459 ▶sub value {
Subroutine value: called CC=13 SCAR=29.8
Pod documented
156 459 my ( $self, $x ) = @_;
157 459 ▶ $x = $self->{raw} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 459 0 459
158  
159 459 ▶ if ( ref $x and reftype($x) and reftype($x) eq 'SCALAR' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $x and builtin::reftype($x) and builtin::reftype($x) eq "SCALAR") 103 356 459
Condition83%5/6
ref $x and builtin::reftype($x) and builtin::reftype($x) eq "SCALAR"
!ll&&!rl&&r
246110103
ref $x and builtin::reftype($x)
!ll&&!rl&&r
2460213
MC/DC66%2/3
ref $x and builtin::reftype($x) and builtin::reftype($x) eq "SCALAR"
ref $x builtin::reftype($x) builtin::reftype($x) eq "SCALAR"
Truth table75%3/4
A and B and C
A= ref $xB= builtin::reftype($x)C= builtin::reftype($x) eq "SCALAR"
ABCresult
0XX0
10X0
1100
1111
160 103 ▶ return !!$$x if $x eq 0 || $x eq 1;
Branch: 1 branch
BranchTrueFalseTotal
if $x eq 0 or $x eq 1 1 102 103
Condition66%2/3
$x eq 0 or $x eq 1
l!l&&r!l&&!r
10102
MC/DC50%1/2
$x eq 0 or $x eq 1
$x eq 0 $x eq 1
Truth table66%2/3
A or B
A= $x eq 0B= $x eq 1
ABresult
1X1
011
000
161 }
162 458 ▶ if ( blessed($x) and $x->isa('Types::Serialiser::Boolean') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("Types::Serialiser::Boolean")) 0 458 458
Condition66%2/3
builtin::blessed($x) and $x->isa("Types::Serialiser::Boolean")
!ll&&!rl&&r
3561020
MC/DC0%0/2
builtin::blessed($x) and $x->isa("Types::Serialiser::Boolean")
builtin::blessed($x) $x->isa("Types::Serialiser::Boolean")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("Types::Serialiser::Boolean")
ABresult
0X0
100
111
163 0 ▶ return !!( $x ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$x ? : 0 0 0
164 }
165 458 ▶ if ( blessed($x) and $x->isa('JSON::PP::Boolean') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("JSON::PP::Boolean")) 0 458 458
Condition66%2/3
builtin::blessed($x) and $x->isa("JSON::PP::Boolean")
!ll&&!rl&&r
3561020
MC/DC0%0/2
builtin::blessed($x) and $x->isa("JSON::PP::Boolean")
builtin::blessed($x) $x->isa("JSON::PP::Boolean")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("JSON::PP::Boolean")
ABresult
0X0
100
111
166 0 ▶ return !!( $x ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$x ? : 0 0 0
167 }
168  
169 458 return $x;
170 }
171  
172 1296 ▶sub primitive_value {
Subroutine primitive_value: called CC=30 SCAR=44.7
Pod documented
173 1296 my ( $self, $x ) = @_;
174 1296 ▶ $x = $self->{raw} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 1296 0 1296
175  
176 1296 ▶ if ( blessed($x) && $x->isa('CBOR::Free::Tagged') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("CBOR::Free::Tagged")) 0 1296 1296
Condition66%2/3
builtin::blessed($x) and $x->isa("CBOR::Free::Tagged")
!ll&&!rl&&r
1275210
MC/DC0%0/2
builtin::blessed($x) and $x->isa("CBOR::Free::Tagged")
builtin::blessed($x) $x->isa("CBOR::Free::Tagged")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("CBOR::Free::Tagged")
ABresult
0X0
100
111
177 0 return $self->type($x->[1]);
178 }
179  
180 1296 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Document') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Document")) 0 1296 1296
Condition66%2/3
builtin::blessed($x) and $x->isa("XML::LibXML::Document")
!ll&&!rl&&r
1275210
MC/DC0%0/2
builtin::blessed($x) and $x->isa("XML::LibXML::Document")
builtin::blessed($x) $x->isa("XML::LibXML::Document")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Document")
ABresult
0X0
100
111
181 0 my $de = $x->documentElement;
182 0 ▶ return defined($de) ? $de->textContent : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $de ? : 0 0 0
183 }
184 1296 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Namespace') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Namespace")) 0 1296 1296
Condition66%2/3
builtin::blessed($x) and $x->isa("XML::LibXML::Namespace")
!ll&&!rl&&r
1275210
MC/DC0%0/2
builtin::blessed($x) and $x->isa("XML::LibXML::Namespace")
builtin::blessed($x) $x->isa("XML::LibXML::Namespace")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Namespace")
ABresult
0X0
100
111
185 0 ▶ return $x->declaredURI // $x->nodeValue // '';
Condition0%0/5
($x->declaredURI // $x->nodeValue) // ""
l!l
00
$x->declaredURI // $x->nodeValue
l!l&&r!l&&!r
000
MC/DC0%0/2
($x->declaredURI // $x->nodeValue) // ""
$x->declaredURI $x->nodeValue
Truth table0%0/3
A // B
A= $x->declaredURIB= $x->nodeValue
ABresult
1X1
011
000
186 }
187 1296 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Attr') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Attr")) 4 1292 1296
Condition100%3/3
builtin::blessed($x) and $x->isa("XML::LibXML::Attr")
!ll&&!rl&&r
1275174
MC/DC100%2/2
builtin::blessed($x) and $x->isa("XML::LibXML::Attr")
builtin::blessed($x) $x->isa("XML::LibXML::Attr")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Attr")
ABresult
0X0
100
111
188 4 return $x->getValue;
189 }
190 1292 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Element') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Element")) 12 1280 1292
Condition100%3/3
builtin::blessed($x) and $x->isa("XML::LibXML::Element")
!ll&&!rl&&r
1275512
MC/DC100%2/2
builtin::blessed($x) and $x->isa("XML::LibXML::Element")
builtin::blessed($x) $x->isa("XML::LibXML::Element")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Element")
ABresult
0X0
100
111
191 12 return $x->textContent;
192 }
193 1280 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Text') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Text")) 0 1280 1280
Condition66%2/3
builtin::blessed($x) and $x->isa("XML::LibXML::Text")
!ll&&!rl&&r
127550
MC/DC0%0/2
builtin::blessed($x) and $x->isa("XML::LibXML::Text")
builtin::blessed($x) $x->isa("XML::LibXML::Text")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Text")
ABresult
0X0
100
111
194 0 return $x->data;
195 }
196 1280 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Comment') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Comment")) 0 1280 1280
Condition66%2/3
builtin::blessed($x) and $x->isa("XML::LibXML::Comment")
!ll&&!rl&&r
127550
MC/DC0%0/2
builtin::blessed($x) and $x->isa("XML::LibXML::Comment")
builtin::blessed($x) $x->isa("XML::LibXML::Comment")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Comment")
ABresult
0X0
100
111
197 0 return $x->data;
198 }
199  
200 1280 ▶ if ( ref $x and reftype($x) and reftype($x) eq 'SCALAR' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $x and builtin::reftype($x) and builtin::reftype($x) eq "SCALAR") 1 1279 1280
Condition83%5/6
ref $x and builtin::reftype($x) and builtin::reftype($x) eq "SCALAR"
!ll&&!rl&&r
1269101
ref $x and builtin::reftype($x)
!ll&&!rl&&r
1269011
MC/DC66%2/3
ref $x and builtin::reftype($x) and builtin::reftype($x) eq "SCALAR"
ref $x builtin::reftype($x) builtin::reftype($x) eq "SCALAR"
Truth table75%3/4
A and B and C
A= ref $xB= builtin::reftype($x)C= builtin::reftype($x) eq "SCALAR"
ABCresult
0XX0
10X0
1100
1111
201 1 ▶ return !!$$x if $x eq 0 || $x eq 1;
Branch: 1 branch
BranchTrueFalseTotal
if $x eq 0 or $x eq 1 0 1 1
Condition33%1/3
$x eq 0 or $x eq 1
l!l&&r!l&&!r
001
MC/DC0%0/2
$x eq 0 or $x eq 1
$x eq 0 $x eq 1
Truth table33%1/3
A or B
A= $x eq 0B= $x eq 1
ABresult
1X1
011
000
202 }
203  
204 1280 ▶ if ( blessed($x) and $x->isa('Types::Serialiser::Boolean') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("Types::Serialiser::Boolean")) 0 1280 1280
Condition66%2/3
builtin::blessed($x) and $x->isa("Types::Serialiser::Boolean")
!ll&&!rl&&r
127550
MC/DC0%0/2
builtin::blessed($x) and $x->isa("Types::Serialiser::Boolean")
builtin::blessed($x) $x->isa("Types::Serialiser::Boolean")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("Types::Serialiser::Boolean")
ABresult
0X0
100
111
205 0 ▶ return !!( $x ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$x ? : 0 0 0
206 }
207  
208 1280 ▶ if ( blessed($x) and $x->isa('JSON::PP::Boolean') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("JSON::PP::Boolean")) 0 1280 1280
Condition66%2/3
builtin::blessed($x) and $x->isa("JSON::PP::Boolean")
!ll&&!rl&&r
127550
MC/DC0%0/2
builtin::blessed($x) and $x->isa("JSON::PP::Boolean")
builtin::blessed($x) $x->isa("JSON::PP::Boolean")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("JSON::PP::Boolean")
ABresult
0X0
100
111
209 0 ▶ return !!( $x ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$x ? : 0 0 0
210 }
211  
212 1280 return $x;
213 }
214  
215 465 ▶sub string_value {
Subroutine string_value: called CC=20 SCAR=32.5
Pod documented
216 465 my ( $self, $x ) = @_;
217 465 ▶ $x = $self->{raw} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 465 0 465
218  
219 465 ▶ if ( blessed($x) && $x->isa('CBOR::Free::Tagged') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("CBOR::Free::Tagged")) 0 465 465
Condition66%2/3
builtin::blessed($x) and $x->isa("CBOR::Free::Tagged")
!ll&&!rl&&r
3321330
MC/DC0%0/2
builtin::blessed($x) and $x->isa("CBOR::Free::Tagged")
builtin::blessed($x) $x->isa("CBOR::Free::Tagged")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("CBOR::Free::Tagged")
ABresult
0X0
100
111
220 0 return $self->type($x->[1]);
221 }
222  
223 465 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Document') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Document")) 0 465 465
Condition66%2/3
builtin::blessed($x) and $x->isa("XML::LibXML::Document")
!ll&&!rl&&r
3321330
MC/DC0%0/2
builtin::blessed($x) and $x->isa("XML::LibXML::Document")
builtin::blessed($x) $x->isa("XML::LibXML::Document")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Document")
ABresult
0X0
100
111
224 0 my $de = $x->documentElement;
225 0 ▶ return defined($de) ? $de->textContent : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $de ? : 0 0 0
226 }
227 465 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Namespace') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Namespace")) 1 464 465
Condition100%3/3
builtin::blessed($x) and $x->isa("XML::LibXML::Namespace")
!ll&&!rl&&r
3321321
MC/DC100%2/2
builtin::blessed($x) and $x->isa("XML::LibXML::Namespace")
builtin::blessed($x) $x->isa("XML::LibXML::Namespace")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Namespace")
ABresult
0X0
100
111
228 1 ▶ return $x->declaredURI // $x->nodeValue // '';
Condition40%2/5
($x->declaredURI // $x->nodeValue) // ""
l!l
10
$x->declaredURI // $x->nodeValue
l!l&&r!l&&!r
100
MC/DC0%0/2
($x->declaredURI // $x->nodeValue) // ""
$x->declaredURI $x->nodeValue
Truth table33%1/3
A // B
A= $x->declaredURIB= $x->nodeValue
ABresult
1X1
011
000
229 }
230 464 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Attr') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Attr")) 48 416 464
Condition100%3/3
builtin::blessed($x) and $x->isa("XML::LibXML::Attr")
!ll&&!rl&&r
3328448
MC/DC100%2/2
builtin::blessed($x) and $x->isa("XML::LibXML::Attr")
builtin::blessed($x) $x->isa("XML::LibXML::Attr")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Attr")
ABresult
0X0
100
111
231 48 return $x->getValue;
232 }
233 416 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Element') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Element")) 73 343 416
Condition100%3/3
builtin::blessed($x) and $x->isa("XML::LibXML::Element")
!ll&&!rl&&r
3321173
MC/DC100%2/2
builtin::blessed($x) and $x->isa("XML::LibXML::Element")
builtin::blessed($x) $x->isa("XML::LibXML::Element")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Element")
ABresult
0X0
100
111
234 73 return $x->textContent;
235 }
236 343 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Text') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Text")) 10 333 343
Condition100%3/3
builtin::blessed($x) and $x->isa("XML::LibXML::Text")
!ll&&!rl&&r
332110
MC/DC100%2/2
builtin::blessed($x) and $x->isa("XML::LibXML::Text")
builtin::blessed($x) $x->isa("XML::LibXML::Text")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Text")
ABresult
0X0
100
111
237 10 return $x->data;
238 }
239 333 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Comment') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Comment")) 0 333 333
Condition66%2/3
builtin::blessed($x) and $x->isa("XML::LibXML::Comment")
!ll&&!rl&&r
33210
MC/DC0%0/2
builtin::blessed($x) and $x->isa("XML::LibXML::Comment")
builtin::blessed($x) $x->isa("XML::LibXML::Comment")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Comment")
ABresult
0X0
100
111
240 0 return $x->data;
241 }
242  
243 333 my $v = $self->primitive_value;
244 333 ▶ return undef unless defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 1 332 333
245 332 return "$v";
246 }
247  
248 263 ▶sub number_value {
Subroutine number_value: called CC=5 SCAR=16.1
Pod documented
249 263 my ( $self ) = @_;
250 263 my $v = $self->primitive_value;
251 263 ▶ return undef unless defined $v && Scalar::Util::looks_like_number($v);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v and &Scalar::Util::looks_like_number($v) 1 262 263
Condition66%2/3
defined $v and &Scalar::Util::looks_like_number($v)
!ll&&!rl&&r
01262
MC/DC50%1/2
defined $v and &Scalar::Util::looks_like_number($v)
defined $v &Scalar::Util::looks_like_number($v)
Truth table66%2/3
A and B
A= defined $vB= &Scalar::Util::looks_like_number($v)
ABresult
0X0
100
111
252  
253 262 ▶ if ( $Data::ZPath::UseBigInt and $v =~ /\A-?[0-9]{19,}\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Data::ZPath::UseBigInt and $v =~ /\A-?[0-9]{19,}\z/) 10 252 262
Condition100%3/3
$Data::ZPath::UseBigInt and $v =~ /\A-?[0-9]{19,}\z/
!ll&&!rl&&r
125110
MC/DC100%2/2
$Data::ZPath::UseBigInt and $v =~ /\A-?[0-9]{19,}\z/
$Data::ZPath::UseBigInt $v =~ /\A-?[0-9]{19,}\z/
Truth table100%3/3
A and B
A= $Data::ZPath::UseBigIntB= $v =~ /\A-?[0-9]{19,}\z/
ABresult
0X0
100
111
254 10 require Math::BigInt;
255 10 return Math::BigInt->from_dec($v);
256 }
257  
258 252 return 0 + $v;
259 }
260  
261 6790 ▶sub children {
Subroutine children: called CC=14 SCAR=27.6
Pod documented
262 6790 my ( $self ) = @_;
263 6790 my $x = $self->{raw};
264  
265 # XML document: treat documentElement as child
266 6790 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Document') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Document")) 0 6790 6790
Condition66%2/3
builtin::blessed($x) and $x->isa("XML::LibXML::Document")
!ll&&!rl&&r
353732530
MC/DC0%0/2
builtin::blessed($x) and $x->isa("XML::LibXML::Document")
builtin::blessed($x) $x->isa("XML::LibXML::Document")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Document")
ABresult
0X0
100
111
267 0 my $de = $x->documentElement;
268 0 ▶ return unless $de;
Branch: 1 branch
BranchTrueFalseTotal
unless $de 0 0 0
269 0 return Data::ZPath::Node->_wrap($de, $self, 0);
270 }
271  
272 6790 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Element') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Element")) 1975 4815 6790
Condition100%3/3
builtin::blessed($x) and $x->isa("XML::LibXML::Element")
!ll&&!rl&&r
353712781975
MC/DC100%2/2
builtin::blessed($x) and $x->isa("XML::LibXML::Element")
builtin::blessed($x) $x->isa("XML::LibXML::Element")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Element")
ABresult
0X0
100
111
273 1975 ▶ my @kids = $Data::ZPath::XmlIgnoreWS ? $x->nonBlankChildNodes : $x->childNodes;
Branch: 1 branch
BranchTrueFalseTotal
$Data::ZPath::XmlIgnoreWS ? : 1975 0 1975
274 1975 my %count;
275 1975 ▶ return map { Data::ZPath::Node->_wrap($_, $self, $_->nodeName, $count{$_->nodeName}++ || 0) } @kids;
Condition100%2/2
$count{$_->nodeName}++ || 0
l!l
6532757
MC/DC100%1/1
$count{$_->nodeName}++ || 0
$count{$_->nodeName}++
Truth table100%2/2
A
A= $count{$_->nodeName}++
Aresult
11
00
276 }
277  
278 4815 ▶ if ( ref($x) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $x eq "HASH") 831 3984 4815
279 831 my @out;
280 831 for my $k (keys %$x) {
281 3240 my $child = Data::ZPath::Node->_wrap($x->{$k}, $self, $k);
282 5 ▶ $child->with_slot(sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
283 5 ▶ if ( @_ ) { $x->{$k} = $_[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 3 2 5
284 5 return $x->{$k};
285 3240 ▶ }) unless ref($x->{$k});
Branch: 1 branch
BranchTrueFalseTotal
unless ref $x->{$k} 2156 1084 3240
286 3240 push @out, $child;
287 }
288 831 return @out;
289 }
290  
291 3984 ▶ if ( ref($x) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $x eq "ARRAY") 403 3581 3984
292 403 my @out;
293 403 ▶ for ( my $i = 0; $i < @$x; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$x) 1272 403 1675
294 1272 my $child = Data::ZPath::Node->_wrap($x->[$i], $self, $i, $i);
295 0 ▶ $child->with_slot(sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
296 0 ▶ if ( @_ ) { $x->[$i] = $_[0]; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
297 0 return $x->[$i];
298 1272 ▶ }) unless ref($x->[$i]);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $x->[$i] 863 409 1272
299 1272 push @out, $child;
300 }
301 403 return @out;
302 }
303  
304 3581 return ();
305 }
306  
307 93 ▶sub attributes {
Subroutine attributes: called CC=3 SCAR=11.0
Pod documented
308 93 my ( $self ) = @_;
309 93 my $x = $self->{raw};
310 93 ▶ return unless blessed($x) && $x->isa('XML::LibXML::Element');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($x) and $x->isa("XML::LibXML::Element") 39 54 93
Condition100%3/3
builtin::blessed($x) and $x->isa("XML::LibXML::Element")
!ll&&!rl&&r
33654
MC/DC100%2/2
builtin::blessed($x) and $x->isa("XML::LibXML::Element")
builtin::blessed($x) $x->isa("XML::LibXML::Element")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Element")
ABresult
0X0
100
111
311 54 my @attrs = $x->attributes;
312 54 return map { Data::ZPath::Node->_wrap($_, $self, '@' . $_->nodeName) } @attrs;
313 }
314  
315 8534 ▶sub name {
Subroutine name: called CC=7 SCAR=19.6
Pod documented
316 8534 my ( $self ) = @_;
317 8534 my $x = $self->{raw};
318  
319 8534 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Attr') ) { return '@' . $x->nodeName; }
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Attr")) 0 8534 8534
Condition66%2/3
builtin::blessed($x) and $x->isa("XML::LibXML::Attr")
!ll&&!rl&&r
525732770
MC/DC0%0/2
builtin::blessed($x) and $x->isa("XML::LibXML::Attr")
builtin::blessed($x) $x->isa("XML::LibXML::Attr")
Truth table66%2/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Attr")
ABresult
0X0
100
111
320 8534 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Element') ) { return $x->nodeName; }
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Element")) 2109 6425 8534
Condition100%3/3
builtin::blessed($x) and $x->isa("XML::LibXML::Element")
!ll&&!rl&&r
525711682109
MC/DC100%2/2
builtin::blessed($x) and $x->isa("XML::LibXML::Element")
builtin::blessed($x) $x->isa("XML::LibXML::Element")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Element")
ABresult
0X0
100
111
321 6425 ▶ if ( blessed($x) && $x->isa('XML::LibXML::Text') ) { return '#text'; }
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($x) and $x->isa("XML::LibXML::Text")) 1062 5363 6425
Condition100%3/3
builtin::blessed($x) and $x->isa("XML::LibXML::Text")
!ll&&!rl&&r
52571061062
MC/DC100%2/2
builtin::blessed($x) and $x->isa("XML::LibXML::Text")
builtin::blessed($x) $x->isa("XML::LibXML::Text")
Truth table100%3/3
A and B
A= builtin::blessed($x)B= $x->isa("XML::LibXML::Text")
ABresult
0X0
100
111
322  
323 5363 return $self->{key};
324 }
325  
326 2 ▶sub dump {
Subroutine dump: called CC=1 SCAR=0.0
Pod documented
327 2 my ( $self ) = @_;
328 return {
329 2 '@type' => $self->type,
330 '@id' => $self->id,
331 '@key' => $self->key,
332 '@index' => $self->index,
333 '@value' => $self->primitive_value,
334 children => [ map $_->dump, $self->children ],
335 attributes => [ map $_->dump, $self->attributes ],
336 };
337 }
338  
339 5 ▶sub find {
Subroutine find: called CC=2 SCAR=6.9
Pod documented
340 5 require Data::ZPath;
341 5 my ( $self, $zpath ) = @_;
342 5 ▶ $zpath = Data::ZPath->new( $zpath ) unless blessed($zpath);
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($zpath) 2 3 5
343 5 return $zpath->evaluate( $self );
344 }
345  
346 9 1;
347  
348 __END__
« Data/ZPath/_Parser.pm ↑ Summary Text/ZTemplate.pm »