blib/lib/XML/Struct/Reader.pm

filter: Statementstmt 91.7% 145 / 158 Branchbran 81.9% 95 / 116 Conditioncond 76.9% 50 / 65 MC/DCmcdc 57.5% 23 / 40 Subroutinesub 96.5% 28 / 29 Podpod 83.3% 5 / 6 totaltotal 83.5% 346 / 414 SCAR 46.1
CC
81
Cov
86%
_trigger_from
37.8
BUILD
15.1
readContent
9.1
CRAP 100.8
↑ Summary blib/lib/XML/Struct/Writer.pm »
1 package XML::Struct::Reader;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 5 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 our @CARP_NOT = qw(XML::Struct);
7 5 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use XML::Struct;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 our $VERSION = '0.26';
11  
12 43 ▶has whitespace => (is => 'ro', default => sub { 0 });
Subroutine __ANON__: called CC=1 SCAR=0.0
13 33 ▶has attributes => (is => 'ro', default => sub { 1 });
Subroutine __ANON__: called CC=1 SCAR=0.0
14 33 ▶has path => (is => 'ro', default => sub { '*' }, isa => \&_checkPath);
Subroutine __ANON__: called CC=1 SCAR=0.0
15 has stream => (is => 'rw',
16 lazy => 1,
17 builder => 1,
18 isa => sub {
19 42 ▶ die 'stream must be an XML::LibXML::Reader'
Subroutine __ANON__: called CC=3 SCAR=14.2
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($_[0]) and $_[0]->isa("XML::LibXML::Reader") 0 42 42
Condition33%1/3
builtin::blessed($_[0]) and $_[0]->isa("XML::LibXML::Reader")
!ll&&!rl&&r
0042
MC/DC0%0/2
builtin::blessed($_[0]) and $_[0]->isa("XML::LibXML::Reader")
builtin::blessed($_[0]) $_[0]->isa("XML::LibXML::Reader")
Truth table33%1/3
A and B
A= builtin::blessed($_[0])B= $_[0]->isa("XML::LibXML::Reader")
ABresult
0X0
100
111
20 unless blessed $_[0] && $_[0]->isa('XML::LibXML::Reader');
21 }
22 5 );
23 5 has from => (is => 'ro', trigger => 1);
24 39 ▶has ns => (is => 'ro', default => sub { 'keep' }, trigger => 1);
Subroutine __ANON__: called CC=1 SCAR=0.0
25 has depth => (is => 'ro', coerce => sub {
26 11 ▶ (defined $_[0] and $_[0] =~ /^\+?\d+/) ? $_[0] : undef
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && $_[0] =~ /^\+?\d+/ ? : 9 2 11
Condition100%3/3
defined $_[0] and $_[0] =~ /^\+?\d+/
!ll&&!rl&&r
119
MC/DC100%2/2
defined $_[0] and $_[0] =~ /^\+?\d+/
defined $_[0] $_[0] =~ /^\+?\d+/
Truth table100%3/3
A and B
A= defined $_[0]B= $_[0] =~ /^\+?\d+/
ABresult
0X0
100
111
27 5 });
28 39 ▶has deep => (is => 'ro', default => sub { '' } );
Subroutine __ANON__: called CC=1 SCAR=0.0
29 25 ▶has simple => (is => 'ro', default => sub { 0 });
Subroutine __ANON__: called CC=1 SCAR=0.0
30 33 ▶has root => (is => 'ro', default => sub { 0 });
Subroutine __ANON__: called CC=1 SCAR=0.0
31 43 ▶has content => (is => 'ro', default => sub { 'content' });
Subroutine __ANON__: called CC=1 SCAR=0.0
32  
33 5 use XML::LibXML::Reader qw(
34 XML_READER_TYPE_ELEMENT
35 XML_READER_TYPE_TEXT
36 XML_READER_TYPE_CDATA
37 XML_READER_TYPE_SIGNIFICANT_WHITESPACE
38 XML_READER_TYPE_END_ELEMENT
39 5 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 sub BUILD {
42 44 ▶ my ($self) = @_;
Subroutine BUILD: called CC=13 SCAR=27.1
Pod undocumented
43
44 # make sure that option 'deep' and 'depth' are only set if it makes sense
45
46 44 ▶ if ($self->deep eq 'simple') {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->deep eq 'simple') { } 3 41 44
elsif ($self->deep eq 'struct') { } 0 41 41
elsif ($self->deep eq '') { } 39 2 41
elsif (not $self->deep =~ /^(dom|raw)$/) { } 0 2 2
47 3 ▶ if ($self->simple or (defined $self->depth and $self->depth == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->simple or defined $self->depth and $self->depth == 0) 3 0 3
Condition50%3/6
$self->simple or defined $self->depth and $self->depth == 0
l!l&&r!l&&!r
120
defined $self->depth and $self->depth == 0
!ll&&!rl&&r
002
MC/DC0%0/3
$self->simple or defined $self->depth and $self->depth == 0
$self->simple defined $self->depth $self->depth == 0
Truth table50%2/4
A or B and C
A= $self->simpleB= defined $self->depthC= $self->depth == 0
ABCresult
1XX1
0111
00X0
0100
48 # (deep = simple, simple = 1) or (deep = simple, depth = 0)
49 3 $self->{simple} = 1;
50 3 delete $self->{depth};
51 3 $self->{deep} = '';
52 }
53 } elsif ($self->deep eq 'struct') {
54 0 $self->{deep} = '';
55 } elsif ($self->deep eq '') {
56 39 ▶ $self->{deep} = $self->simple ? '' : 'simple';
Branch: 1 branch
BranchTrueFalseTotal
$self->simple ? : 18 21 39
57 } elsif ($self->deep !~ /^(dom|raw)$/) {
58 0 croak "option deep must be simple, struct, dom, or raw!";
59 }
60  
61 44 ▶ if (($self->depth || 0) and $self->root and $self->simple) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->depth || 0 and $self->root and $self->simple) 2 42 44
Condition87%7/8
$self->depth || 0 and $self->root and $self->simple
!ll&&!rl&&r
4202
$self->depth || 0 and $self->root
!ll&&!rl&&r
4022
$self->depth or 0
l!l
440
MC/DC66%2/3
$self->depth || 0 and $self->root and $self->simple
$self->depth $self->root $self->simple
Truth table75%3/4
A and B and C
A= $self->depthB= $self->rootC= $self->simple
ABCresult
0XX0
10X0
1100
1111
62 2 $self->{depth} = $self->{depth}-1;
63 }
64 }
65  
66 sub _build_stream {
67 0 ▶ XML::LibXML::Reader->new( { IO => \*STDIN } )
Subroutine _build_stream: not called CC=1 SCAR=6.9
68 }
69
70 sub _trigger_from {
71 42 ▶ my ($self, $from) = @_;
Subroutine _trigger_from: called CC=22 SCAR=36.3
72  
73 42 ▶ unless (blessed $from and $from->isa('XML::LibXML::Reader')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($from) and $from->isa("XML::LibXML::Reader")) 33 9 42
Condition100%3/3
builtin::blessed($from) and $from->isa("XML::LibXML::Reader")
!ll&&!rl&&r
2949
MC/DC100%2/2
builtin::blessed($from) and $from->isa("XML::LibXML::Reader")
builtin::blessed($from) $from->isa("XML::LibXML::Reader")
Truth table100%3/3
A and B
A= builtin::blessed($from)B= $from->isa("XML::LibXML::Reader")
ABresult
0X0
100
111
74 33 my %options;
75  
76 33 ▶ if (ref $from and ref $from eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $from and ref $from eq "HASH") 0 33 33
Condition66%2/3
ref $from and ref $from eq "HASH"
!ll&&!rl&&r
2850
MC/DC0%0/2
ref $from and ref $from eq "HASH"
ref $from ref $from eq "HASH"
Truth table66%2/3
A and B
A= ref $fromB= ref $from eq "HASH"
ABresult
0X0
100
111
77 0 %options = %$from;
78 0 ▶ $from = delete $options{from} if exists $options{from};
Branch: 1 branch
BranchTrueFalseTotal
if exists $options{"from"} 0 0 0
79 }
80  
81 33 ▶ if (!defined $from or $from eq '-') {
Branch: 9 branches
BranchTrueFalseTotal
if (not defined $from or $from eq '-') { } 0 33 33
elsif (not ref $from and $from =~ /^</) { } 9 24 33
elsif (ref $from and ref $from eq 'SCALAR') { } 1 23 24
elsif (ref $from and ref $from eq 'GLOB') { } 0 23 23
elsif (builtin::blessed($from) and $from->isa('XML::LibXML::Document')) { } 3 20 23
elsif (builtin::blessed($from) and $from->isa('XML::LibXML::Element')) { } 1 19 20
elsif (builtin::blessed($from)) { } 0 19 19
elsif (not ref $from) { } 19 0 19
elsif (not grep({$_ =~ /^(IO|string|location|FD|DOM)$/;} keys %options)) { } 0 0 0
Condition33%1/3
not defined $from or $from eq "-"
l!l&&r!l&&!r
0033
MC/DC0%0/2
not defined $from or $from eq "-"
not defined $from $from eq "-"
Truth table33%1/3
not(A) or B
A= not defined $fromB= $from eq "-"
ABresult
1X1
011
000
82 0 $options{IO} = \*STDIN
83 ▶ } elsif( !ref $from and $from =~ /^</ ) {
Condition100%3/3
not ref $from and $from =~ /^</
!ll&&!rl&&r
5199
MC/DC100%2/2
not ref $from and $from =~ /^</
not ref $from $from =~ /^</
Truth table100%3/3
not(A) and B
A= not ref $fromB= $from =~ /^</
ABresult
0X0
100
111
84 9 $options{string} = $from;
85 ▶ } elsif( ref $from and ref $from eq 'SCALAR' ) {
Condition100%3/3
ref $from and ref $from eq "SCALAR"
!ll&&!rl&&r
1941
MC/DC100%2/2
ref $from and ref $from eq "SCALAR"
ref $from ref $from eq "SCALAR"
Truth table100%3/3
A and B
A= ref $fromB= ref $from eq "SCALAR"
ABresult
0X0
100
111
86 1 $options{string} = $$from;
87 ▶ } elsif( ref $from and ref $from eq 'GLOB' ) {
Condition66%2/3
ref $from and ref $from eq "GLOB"
!ll&&!rl&&r
1940
MC/DC0%0/2
ref $from and ref $from eq "GLOB"
ref $from ref $from eq "GLOB"
Truth table66%2/3
A and B
A= ref $fromB= ref $from eq "GLOB"
ABresult
0X0
100
111
88 0 $options{FD} = $from;
89 ▶ } elsif( blessed $from and $from->isa('XML::LibXML::Document') ) {
Condition100%3/3
builtin::blessed($from) and $from->isa("XML::LibXML::Document")
!ll&&!rl&&r
1913
MC/DC100%2/2
builtin::blessed($from) and $from->isa("XML::LibXML::Document")
builtin::blessed($from) $from->isa("XML::LibXML::Document")
Truth table100%3/3
A and B
A= builtin::blessed($from)B= $from->isa("XML::LibXML::Document")
ABresult
0X0
100
111
90 3 $options{DOM} = $from;
91 ▶ } elsif( blessed $from and $from->isa('XML::LibXML::Element') ) {
Condition66%2/3
builtin::blessed($from) and $from->isa("XML::LibXML::Element")
!ll&&!rl&&r
1901
MC/DC50%1/2
builtin::blessed($from) and $from->isa("XML::LibXML::Element")
builtin::blessed($from) $from->isa("XML::LibXML::Element")
Truth table66%2/3
A and B
A= builtin::blessed($from)B= $from->isa("XML::LibXML::Element")
ABresult
0X0
100
111
92 1 my $doc = XML::LibXML->createDocument;
93 1 $doc->setDocumentElement($from);
94 1 $options{DOM} = $doc;
95 } elsif( blessed $from ) {
96 0 $options{IO} = $from;
97 } elsif( !ref $from ) {
98 19 $options{location} = $from; # filename or URL
99 0 } elsif( ! grep { $_ =~ /^(IO|string|location|FD|DOM)$/} keys %options ) {
100 0 croak "invalid option 'from': $from";
101 }
102
103 $from = XML::LibXML::Reader->new( %options )
104 or die "failed to create XML::LibXML::Reader with "
105 33 ▶ . join(', ',map { "$_=".$options{$_} } keys %options )."\n";
Branch: 1 branch
BranchTrueFalseTotal
$from = "XML::LibXML::Reader"->new(%options) or die 'failed to create XML::LibXML::Reader with ' . join(", ", map({"$_=" . $options{$_};} keys %options)) . "\n" 0 33 33
106 }
107  
108 42 $self->stream($from);
109 }
110  
111  
112 sub _trigger_ns {
113 5 ▶ my ($self, $ns) = @_;
Subroutine _trigger_ns: called CC=4 SCAR=18.9
114  
115 5 ▶ if (!defined $ns or $ns eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $ns or $ns eq '') { } 0 5 5
elsif (not $ns =~ /^(keep|strip|disallow)?$/) { } 0 5 5
Condition33%1/3
not defined $ns or $ns eq ""
l!l&&r!l&&!r
005
MC/DC0%0/2
not defined $ns or $ns eq ""
not defined $ns $ns eq ""
Truth table33%1/3
not(A) or B
A= not defined $nsB= $ns eq ""
ABresult
1X1
011
000
116 0 $self->{ns} = 'keep';
117 } elsif ($ns !~ /^(keep|strip|disallow)?$/) {
118 0 croak "invalid option 'ns': $ns";
119 }
120 }
121  
122  
123 sub _checkPath {
124 50 ▶ my $path = shift;
Subroutine _checkPath: called CC=3 SCAR=11.4
125  
126 50 ▶ die "invalid path: $path" if $path =~ qr{\.\.|.//|^\.};
Branch: 1 branch
BranchTrueFalseTotal
if $path =~ qr"\.\.|.//|^\." 0 50 50
127 50 ▶ die "relative path not supported: $path" if $path =~ qr{^[^/]+/};
Branch: 1 branch
BranchTrueFalseTotal
if $path =~ qr"^[^/]+/" 0 50 50
128  
129 50 return $path;
130 }
131  
132 sub _nameMatch {
133 79 ▶ return ($_[0] eq '*' or $_[0] eq $_[1]);
Subroutine _nameMatch: called CC=2 SCAR=6.9
Condition100%3/3
$_[0] eq '*' || $_[0] eq $_[1]
l!l&&r!l&&!r
401722
MC/DC100%2/2
$_[0] eq '*' || $_[0] eq $_[1]
$_[0] eq '*' $_[0] eq $_[1]
Truth table100%3/3
A || B
A= $_[0] eq '*'B= $_[0] eq $_[1]
ABresult
1X1
011
000
134 }
135  
136 # read to the next element
137 # TODO: use XML::LibXML->nextPatternMatch
138 sub _nextPatternMatch {
139 68 ▶ my ($self, $stream, $path) = @_;
Subroutine _nextPatternMatch: called CC=8 SCAR=20.8
140  
141 68 $path =~ s{^//}{};
142 68 ▶ $path .= '*' if $path =~ qr{^$|/$};
Branch: 1 branch
BranchTrueFalseTotal
if $path =~ qr"^$|/$" 2 66 68
143  
144 68 my @parts = split '/', $path;
145 68 my $relative = $parts[0] ne '';
146  
147 68 while(1) {
148 157 ▶ return if !$stream->read; # end or error
Branch: 1 branch
BranchTrueFalseTotal
unless $stream->read 20 137 157
149 137 ▶ next if $stream->nodeType != XML_READER_TYPE_ELEMENT;
Branch: 1 branch
BranchTrueFalseTotal
if $stream->nodeType != 1 58 79 137
150  
151 # printf " %d=%d %s:%s==%s\n", $stream->depth, scalar @parts, $stream->nodePath, $stream->name, join('/', @parts);
152  
153 79 my $name = $self->_name($stream);
154  
155 79 ▶ if ($relative) {
Branch: 1 branch
BranchTrueFalseTotal
if ($relative) { } 51 28 79
156 51 ▶ if (_nameMatch($parts[0], $name)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_nameMatch($parts[0], $name)) 35 16 51
157 35 last;
158 }
159 } else {
160 28 ▶ if (!_nameMatch($parts[$stream->depth+1], $name)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not _nameMatch($parts[$stream->depth + 1], $name)) { } 6 22 28
elsif ($stream->depth == scalar @parts - 2) { } 13 9 22
161 6 $stream->nextSibling();
162 } elsif ($stream->depth == scalar @parts - 2) {
163 13 last;
164 }
165 }
166 }
167  
168 48 return 1;
169 }
170  
171 sub readNext {
172 68 ▶ my $self = shift;
Subroutine readNext: called CC=5 SCAR=16.1
Pod documented
173 68 ▶ my $stream = blessed $_[0] ? shift() : $self->stream;
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_[0]) ? : 2 66 68
174 68 ▶ my $path = defined $_[0] ? _checkPath($_[0]) : $self->path;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 6 62 68
175  
176 68 ▶ return unless $self->_nextPatternMatch($stream, $path);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_nextPatternMatch($stream, $path) 20 48 68
177  
178 48 my $xml = $self->readElement($stream);
179  
180 46 ▶ return $self->simple ? XML::Struct::Simple->new(
Branch: 1 branch
BranchTrueFalseTotal
$self->simple ? : 25 21 46
181 root => $self->root,
182 attributes => $self->attributes,
183 depth => $self->depth,
184 content => $self->content,
185 )->transform($xml) : $xml;
186 }
187  
188 5 *read = \&readNext;
189  
190  
191 sub readDocument {
192 32 ▶ my $self = shift;
Subroutine readDocument: called CC=3 SCAR=11.0
Pod documented
193 32 my @document;
194
195 32 ▶ while(my $element = $self->read(@_)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $element = $self->read(@_)) 32 16 48
196 32 ▶ return $element unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 14 18 32
197 18 push @document, $element;
198 }
199  
200 16 return @document;
201 }
202  
203 sub _name {
204 292 ▶ my ($self, $stream) = @_;
Subroutine _name: called CC=4 SCAR=13.9
205  
206 292 ▶ if ($self->ns eq 'strip') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->ns eq 'strip') { } 10 282 292
elsif ($self->ns eq 'disallow') { } 15 267 282
207 10 return $stream->localName;
208 } elsif( $self->ns eq 'disallow' ) {
209 15 ▶ if ( $stream->name =~ /^xmlns(:.*)?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->name =~ /^xmlns(:.*)?$/) 2 13 15
210 2 croak "namespaces not allowed at line ".$stream->lineNumber;
211 }
212 }
213  
214 280 return $stream->name;
215 }
216  
217  
218 sub readElement {
219 185 ▶ my $self = shift;
Subroutine readElement: called CC=9 SCAR=22.0
Pod documented
220 185 ▶ my $stream = @_ ? shift : $self->stream;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 185 0 185
221  
222 185 my @element = ($self->_name($stream));
223  
224 # TODO: dom or raw
225 185 ▶ if (defined $self->depth and $stream->depth >= $self->depth) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->depth and $stream->depth >= $self->depth) 28 157 185
Condition100%3/3
defined $self->depth and $stream->depth >= $self->depth
!ll&&!rl&&r
151628
MC/DC100%2/2
defined $self->depth and $stream->depth >= $self->depth
defined $self->depth $stream->depth >= $self->depth
Truth table100%3/3
A and B
A= defined $self->depthB= $stream->depth >= $self->depth
ABresult
0X0
100
111
226 28 ▶ if ($self->deep eq 'dom') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->deep eq 'dom') { } 1 27 28
elsif ($self->deep eq 'raw') { } 1 26 27
227 1 my $dom = $stream->copyCurrentNode(1);
228 1 $stream->next;
229 1 return $dom;
230 } elsif ($self->deep eq 'raw') {
231 1 my $xml = $stream->readOuterXml();
232 1 $stream->next;
233 1 return $xml;
234 }
235 #copyCurrentNode
236 #if (defined $self->depth and $self->depth == $stream->depth ) {
237 #print $stream->depth." ".$self->deep."!".$element[0]."\n";
238 #}
239 }
240  
241 183 ▶ if ($self->attributes) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->attributes) { } 133 50 183
elsif (not $stream->isEmptyElement) { } 38 12 50
242 133 my $attr = $self->readAttributes($stream);
243 131 ▶ my $children = $stream->isEmptyElement ? [ ] : $self->readContent($stream);
Branch: 1 branch
BranchTrueFalseTotal
$stream->isEmptyElement ? : 33 98 131
244 131 push @element, $attr, $children;
245 } elsif( !$stream->isEmptyElement ) {
246 38 push @element, $self->readContent($stream);
247 }
248  
249 181 return \@element;
250 }
251  
252  
253 sub readAttributes {
254 133 ▶ my $self = shift;
Subroutine readAttributes: called CC=6 SCAR=17.9
Pod documented
255 133 ▶ my $stream = @_ ? shift : $self->stream;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 133 0 133
256  
257 133 ▶ return { } if $stream->moveToFirstAttribute != 1;
Branch: 1 branch
BranchTrueFalseTotal
if $stream->moveToFirstAttribute != 1 107 26 133
258  
259 26 my $attr = { };
260 26 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$stream->moveToNextAttribute and do { do { if ($self->ns ne "strip" or not $stream->name =~ /^xmlns(:.*)?$/) { $$attr{$self->_name($stream)} = $stream->value; } } } 4 24 28
261 30 ▶ if ($self->ns ne 'strip' or $stream->name !~ /^xmlns(:.*)?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->ns ne "strip" or not $stream->name =~ /^xmlns(:.*)?$/) 28 2 30
Condition100%3/3
$self->ns ne "strip" or not $stream->name =~ /^xmlns(:.*)?$/
l!l&&r!l&&!r
2532
MC/DC100%2/2
$self->ns ne "strip" or not $stream->name =~ /^xmlns(:.*)?$/
$self->ns ne "strip" not $stream->name =~ /^xmlns(:.*)?$/
Truth table100%3/3
A or not(B)
A= $self->ns ne "strip"B= not $stream->name =~ /^xmlns(:.*)?$/
ABresult
1X1
011
000
262 28 $attr->{ $self->_name($stream) } = $stream->value;
263 }
264 } while ($stream->moveToNextAttribute);
265 24 $stream->moveToElement;
266  
267 24 return $attr;
268 }
269  
270  
271 sub readContent {
272 136 ▶ my $self = shift;
Subroutine readContent: called CC=9 SCAR=22.1
Pod documented
273 136 ▶ my $stream = @_ ? shift : $self->stream;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 136 0 136
274  
275 136 my @children;
276 136 while(1) {
277 505 $stream->read;
278 505 my $type = $stream->nodeType;
279  
280 505 ▶ last if !$type or $type == XML_READER_TYPE_END_ELEMENT;
Branch: 1 branch
BranchTrueFalseTotal
if not $type or $type == 15 136 369 505
Condition66%2/3
not $type or $type == 15
l!l&&r!l&&!r
0136369
MC/DC50%1/2
not $type or $type == 15
not $type $type == 15
Truth table66%2/3
not(A) or B
A= not $typeB= $type == 15
ABresult
1X1
011
000
281  
282 369 ▶ if ($type == XML_READER_TYPE_ELEMENT) {
Branch: 3 branches
BranchTrueFalseTotal
if ($type == 1) { } 137 232 369
elsif ($type == 3 or $type == 4) { } 60 172 232
elsif ($type == 14 and $self->whitespace) { } 1 171 172
283 137 push @children, $self->readElement($stream);
284 ▶ } elsif ($type == XML_READER_TYPE_TEXT or $type == XML_READER_TYPE_CDATA ) {
Condition100%3/3
$type == 3 or $type == 4
l!l&&r!l&&!r
582172
MC/DC100%2/2
$type == 3 or $type == 4
$type == 3 $type == 4
Truth table100%3/3
A or B
A= $type == 3B= $type == 4
ABresult
1X1
011
000
285 60 push @children, $stream->value;
286 ▶ } elsif ($type == XML_READER_TYPE_SIGNIFICANT_WHITESPACE && $self->whitespace) {
Condition66%2/3
$type == 14 and $self->whitespace
!ll&&!rl&&r
01711
MC/DC50%1/2
$type == 14 and $self->whitespace
$type == 14 $self->whitespace
Truth table66%2/3
A and B
A= $type == 14B= $self->whitespace
ABresult
0X0
100
111
287 1 push @children, $stream->value;
288 }
289 }
290
291 136 return \@children;
292 }
293  
294 5 1;
295 __END__
↑ Summary blib/lib/XML/Struct/Writer.pm »