Branch Coverage

blib/lib/YAML/Tiny.pm
Criterion Covered Total %
branch 171 202 84.6


line true false branch
34 54 60 if (wantarray) { }
57 1 0 if (wantarray) { }
171 3 12 ref $_[0] ? :
174 1 14 unless my $file = shift()
175 1 13 unless -e $file
177 1 12 unless -f _
179 0 12 unless -r _
184 0 12 unless ($fh)
189 12 0 if (_can_flock())
190 0 12 unless flock $fh, 1
200 2 10 if (my $err = $@)
205 0 10 unless (close $fh)
214 1 342 ref $_[0] ? :
218 1 342 unless (defined $string)
224 1 341 if (utf8::is_utf8($string) and not utf8::valid($string))
238 4 337 unless length $string
245 3 334 if @lines and $lines[0] =~ /^\%YAML[: ][\d\.]+.*\z/
251 278 83 if ($lines[0] =~ /^---\s*(?:(.+)\s*)?\z/)
254 43 235 if (defined $1 and not $1 =~ /^(?:\#.+|\%YAML[: ][\d\.]+)\z/)
262 12 306 if (not @lines or $lines[0] =~ /^(?:---|\.\.\.)/) { }
2 304 elsif (not $in_document and @$self) { }
66 238 elsif ($lines[0] =~ /^\s*\-(?:\s|$|-+$)/) { }
238 0 elsif ($lines[0] =~ /^(\s*)\S/) { }
299 15 328 if (ref $err eq 'SCALAR') { }
0 328 elsif ($err) { }
310 5 227 unless length $string
317 1 86 unless length $string
320 13 61 length $1 > 1 ? :
332 38 892 if $string eq '~'
335 185 707 if ($string =~ /^$re_capture_single_quoted$re_trailing_comment\z/)
340 58 649 if ($string =~ /^$re_capture_double_quoted$re_trailing_comment\z/)
345 2 647 if ($string =~ /^[\'\"!&]/)
348 10 637 if $string =~ /^{}(?:\s+\#.*)?\z/
349 10 627 if $string =~ /^\[\](?:\s+\#.*)?\z/
352 614 13 unless ($string =~ /^[>|]/)
353 8 606 if $string =~ /^(?:-(?:\s|$)|[\@\%\`])/ or $string =~ /:(?:\s|$)/
361 0 13 unless @$lines
366 0 13 if (defined $indent->[-2] and $indent->[-1] <= $indent->[-2])
374 7 28 unless length $1 >= $indent->[-1]
378 2 11 substr($string, 0, 1) eq '>' ? :
379 2 11 substr($string, 1, 1) eq '-' ? :
389 15 272 if ($lines->[0] =~ /^(?:---|\.\.\.)/)
398 24 248 if (length $1 < $indent->[-1]) { }
0 248 elsif (length $1 > $indent->[-1]) { }
404 26 222 if ($lines->[0] =~ /^(\s*\-\s+)[^\'\"]\S*\s*:(?:\s+|$)/) { }
38 184 elsif ($lines->[0] =~ /^\s*\-\s*\z/) { }
180 4 elsif ($lines->[0] =~ /^\s*\-(\s*)(.+?)\s*\z/) { }
4 0 elsif (defined $indent->[-2] and $indent->[-1] == $indent->[-2]) { }
413 2 36 unless (@$lines)
417 4 32 if ($lines->[0] =~ /^(\s*)\-/) { }
32 0 elsif ($lines->[0] =~ /^(\s*)\S/) { }
419 4 0 if ($indent->[-1] == $indent2) { }
471 3 1036 if ($lines->[0] =~ /^(?:---|\.\.\.)/)
480 155 881 if (length $1 < $indent->[-1]) { }
0 881 elsif (length $1 > $indent->[-1]) { }
490 47 834 if ($lines->[0] =~ s/^\s*$re_capture_single_quoted$re_key_value_separator//) { }
29 805 elsif ($lines->[0] =~ s/^\s*$re_capture_double_quoted$re_key_value_separator//) { }
804 1 elsif ($lines->[0] =~ s/^\s*$re_capture_unquoted_key$re_key_value_separator//) { }
0 1 elsif ($lines->[0] =~ /^\s*\?/) { }
513 1 879 if (exists $hash->{$key})
518 707 173 if (length $lines->[0]) { }
526 1 172 unless (@$lines)
530 44 128 if ($lines->[0] =~ /^(\s*)-/) { }
128 0 elsif ($lines->[0] =~ /^(\s*)./) { }
537 6 122 if ($indent->[-1] >= $indent2) { }
564 1 4 unless my $file = shift()
568 4 0 if (_can_flock()) { }
571 0 4 unless sysopen $fh, $file, $flags
577 0 4 unless flock $fh, 2
592 0 4 unless (close $fh)
602 4 265 unless ref $self and @$self
613 7 271 if (not defined $cursor) { }
19 252 elsif (not ref $cursor) { }
33 219 elsif (ref $cursor eq 'ARRAY') { }
219 0 elsif (ref $cursor eq 'HASH') { }
622 1 32 unless (@$cursor)
630 1 218 unless (%$cursor)
641 1 264 if (ref $@ eq 'SCALAR') { }
0 264 elsif ($@) { }
661 24 1081 unless defined $string
662 3 1078 unless length $string
663 90 988 if (&Scalar::Util::looks_like_number($string))
665 56 34 if ($is_key or $has_string_flag) { }
672 98 890 if ($string =~ /[\x00-\x09\x0b-\x0d\x0e-\x1f\x7f-\x9f\'\n]/)
681 193 697 if ($string =~ /(?:^[~!\@#%&*|>?:,'"`{}\[\]]|^-+$|\s|:\z)/ or $QUOTE{$string})
691 0 55 if ($$seen{&refaddr($array)}++)
698 94 33 if (not $type) { }
1 32 elsif ($type eq 'ARRAY') { }
32 0 elsif ($type eq 'HASH') { }
703 0 1 if (@$el) { }
712 31 1 if (keys %$el) { }
730 1 309 if ($$seen{&refaddr($hash)}++)
738 452 90 if (not $type) { }
26 64 elsif ($type eq 'ARRAY') { }
64 0 elsif ($type eq 'HASH') { }
743 23 3 if (@$el) { }
752 61 3 if (keys %$el) { }
788 0 0 unless $errstr_warned++
810 13 3 if (defined $HAS_FLOCK) { }
817 3 0 if $HAS_FLOCK
831 12 0 if (eval { do { 'Scalar::Util'->VERSION(1.18) } }) { }