Branch Coverage

blib/lib/YAML/Loader.pm
Criterion Covered Total %
branch 231 268 86.1


line true false branch
36 1 318 if $self->stream =~ /$ESCAPE_CHAR/
49 280 38 unless ($self->eos)
50 36 244 unless ($self->lines->[0] =~ /^---(\s|$)/)
64 318 0 if ($self->lines->[0] =~ /^---\s*(.*)$/) { }
68 17 110 if ($words[0] =~ /^#(\w+):(\S.*)$/) { }
0 110 elsif ($words[0] eq '') { }
71 2 15 if (defined $directives{$key})
91 318 0 unless ($self->done)
94 60 256 if ($self->done)
104 1 315 if $self->major_version ne '1'
106 1 314 if $self->minor_version ne '0'
108 1 314 unless $directives{'TAB'} =~ /^(NONE|\d+)(:HARD)?$/
112 151 134 wantarray ? :
126 20 1992 if ($anchor)
131 65 1282 if ($preface =~ s/^($FOLD_CHAR|$LIT_CHAR_RX)//) { }
133 23 42 if ($preface =~ s/^([+-])[0-9]*//) { }
6 36 elsif ($preface =~ s/^[0-9]+([+-]?)//) { }
139 64 1 if ($preface =~ s/^(?:\s+#.*$|\s*)$//) { }
150 21 1990 if ($alias) { }
1282 708 elsif (length $self->inline) { }
44 664 elsif ($indicator eq $LIT_CHAR) { }
20 644 elsif ($indicator eq $FOLD_CHAR) { }
152 1 20 unless defined $self->anchor2node->{$alias}
153 20 0 if (ref $self->anchor2node->{$alias} ne 'YAML-anchor2node') { }
164 1 1273 if (length $self->inline)
171 0 44 if $implicit
177 1 19 if $implicit
183 629 15 if ($self->indent == $self->offset->[$self->level]) { }
184 155 474 if ($self->content =~ /^-( |$)/) { }
474 0 elsif ($self->content =~ /(^\?|\:( |$))/) { }
0 0 elsif ($preface =~ /^\s*$/) { }
204 84 1888 if ($explicit)
205 57 27 unless $parsed_inline
207 20 1951 if ($anchor)
208 10 10 if (ref $self->anchor2node->{$anchor} eq 'YAML-anchor2node')
228 90 56 if ($preface =~ s/^\!(\S+)\s*//) { }
5 51 elsif ($preface =~ s/^\!\s*//) { }
25 26 elsif ($preface =~ s/^\&([^ ,:]*)\s*//) { }
26 0 elsif ($preface =~ s/^\*([^ ,:]*)\s*//) { }
229 1 89 if $explicit
233 1 4 if $implicit
238 2 23 unless $token =~ m[^[a-zA-Z0-9_./-]+$]
240 1 22 if $anchor
241 0 22 if $alias
246 2 24 unless $token =~ m[^[a-zA-Z0-9_./-]+$]
248 1 23 if $alias
249 1 22 if $anchor
261 44 44 if ($explicit =~ m[^\!?perl/(hash|array|ref|scalar)(?:\:(\w(\w|\:\:)*)?)?$])
266 22 22 if ($type eq 'ref')
268 1 21 unless exists $node->{"\aYAML\aVALUE\a"} and scalar keys %$node == 1
274 4 2 if ($type eq 'scalar' and length $class and not ref $node)
279 9 10 if (length $class and $YAML::LoadBlessed)
285 22 22 if ($explicit =~ m[^!?perl/(glob|regexp|code)(?:\:(\w(\w|\:\:)*)?)?$]) { }
15 7 elsif ($YAML::TagClass->{$explicit} or $explicit =~ m[^perl/(\@|\$)?([a-zA-Z](\w|::)+)$]) { }
5 2 elsif (ref $node) { }
289 22 0 if ($type_class->can('yaml_load')) { }
301 4 11 if ($class->can('yaml_load')) { }
5 6 elsif ($YAML::LoadBlessed) { }
306 5 0 if (ref $node) { }
332 1 512 $self->preserve ? :
337 5 1381 if ($self->{'content'} =~ s/^\?\s*//) { }
23 1358 elsif ($self->{'content'} =~ s/^\=\s*(?=:)//) { }
0 1358 elsif ($self->{'content'} =~ s/^\=\s*(?=:)//) { }
360 1 1385 unless ($self->{'content'} =~ s/^:(?:\s+#.*$|\s*)//)
373 2 1377 if (exists $mapping->{$key}) { }
390 365 3 if ($self->content =~ /^-(?: (.*))?$/) { }
391 349 16 defined $1 ? :
394 2 1 if ($self->zero_indent->[$self->level])
405 4 361 if ($preface =~ /^ (\s*) ( - (?: \ .* | $ ) ) /x) { }
39 322 elsif ($preface =~ /^ (\s*) ((') (?:''|[^'])*? ' \s* \: (?:\ |$).*) $/x or $preface =~ /^ (\s*) ((") (?:\\\\|[^"])*? " \s* \: (?:\ |$).*) $/x or $preface =~ /^ (\s*) (\?.*$)/x or $preface =~ /^ (\s*) ([^'"\s:#&!\[\]\{\},*|>].*\:(\ .*|$))/x) { }
447 0 2758 if ($anchor)
453 0 2758 if ($alias) { }
27 2731 elsif ($self->inline =~ /^\{/) { }
33 2698 elsif ($self->inline =~ /^\[/) { }
27 2671 elsif ($self->inline =~ /^"/) { }
56 2615 elsif ($self->inline =~ /^'/) { }
455 0 0 unless defined $self->anchor2node->{$alias}
456 0 0 if (ref $self->anchor2node->{$alias} ne 'YAML-anchor2node') { }
473 2 23 if $implicit
477 0 54 if $implicit
480 1174 1441 if ($top) { }
487 2598 16 unless $explicit
489 3 3 if ($self->numify and defined $node and not ref $node and length $node and $node =~ /\A-?(?:0|[1-9][0-9]*)?(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?\z/)
494 31 2718 if ($explicit)
497 0 2749 if ($anchor)
498 0 0 if (ref $self->anchor2node->{$anchor} eq 'YAML-anchor2node')
518 0 27 unless $self->{'inline'} =~ s/^\{\s*//
522 1 29 unless $self->{'inline'} =~ s/^\: \s*//
524 0 29 if (exists $node->{$key}) { }
530 17 12 if $self->inline =~ /^\s*\}/
532 0 12 unless $self->{'inline'} =~ s/^\,\s*//
545 0 33 unless $self->{'inline'} =~ s/^\[\s*//
549 22 36 if $self->inline =~ /^\s*\]/
551 1 35 unless $self->{'inline'} =~ s/^\,\s*//
560 27 0 if ($inline =~ s/^"//)
567 2 160059 unless length $inline
569 25 2 if ($inline =~ s/^"(?:\s+#.*|\s*)//)
582 56 0 if ($inline =~ s/^'//)
588 2 50 unless length $inline
590 54 2 if ($inline =~ s/^'(?:\s+#.*|\s*)//)
602 1440 1 if ($self->inline =~ /^(|[^!\@#%^&*].*?)(?=[\[\]\{\},]|, |: |- |:\s*$|$)/) { }
619 5 2596 if $value eq ''
620 4 2592 if $value =~ /^~$/
621 2590 2 unless $value =~ /^[\@\`]/ or $value =~ /^[\-\?]\s/
639 17 3 unless $chomp eq '+'
640 15 5 unless $chomp
653 3 41 if '+' eq $chomp
655 17 24 if $chomp eq '-'
687 0 2228 unless defined $offset
690 258 1970 if ($self->eos)
698 62 1908 if ($self->preface =~ qr/(?:^|\s)(?:$FOLD_CHAR|$LIT_CHAR_RX)(?:[+-]([0-9]*)|([0-9]*)[+-]?)(?:\s+#.*|\s*)$/) { }
644 1436 elsif ($type == 2 and $self->preface =~ /^(\s*(\!\S*|\&\S+))*\s*$/) { }
701 42 0 defined $2 ? :
20 42 defined $1 ? :
702 1 61 if length $explicit_indent and $explicit_indent == 0
705 8 53 if (length $explicit_indent) { }
712 1 0 unless length $1 <= $offset
717 0 53 if $self->eos
718 52 1 if ($self->lines->[0] =~ /^( *)\S/ and length $1 > $offset) { }
732 0 644 if ($self->eos) { }
49 595 elsif (defined $zero_indent->[$level] and not $zero_indent->[$level] and $self->lines->[0] =~ /^( {$offset,})-(?: |$)/) { }
743 3 46 if ($new_offset == $offset)
748 1 594 unless $self->lines->[0] =~ /^( *)\S/
750 585 9 if (length $1 > $offset) { }
760 233 1735 if ($type == 1) { }
761 5 228 if (@{$self->lines;} and $self->lines->[0] =~ /^( *)(\#)/ and length $1 < $offset)
765 5 0 if (length $1 < $offset)
783 7 1961 if $self->eos
785 38 1923 if ($self->lines->[0] =~ /^---(\s|$)/)
789 183 1740 if ($type == 1 and $self->lines->[0] =~ /^ {$offset}(.*)$/) { }
15 1725 elsif ($self->lines->[0] =~ /^\s*$/) { }
804 5 1720 if $self->offset->[$level] != length $1
809 0 1918 if $self->indent - $offset > 1
835 0 22 length $1 > 1 ? :