Branch Coverage

blib/lib/YAML/Perl/Emitter.pm
Criterion Covered Total %
branch 241 440 54.7


line true false branch
77 0 0 if ($p{'indent'} and $p{'indent'} > 1 and $p{'indent'} < 10)
80 0 30 if ($p{'width'} and $p{'width'} > ($p{'best_indent'} || 2) * 2)
83 0 30 if ($p{'line_break'} and $p{'line_break'} =~ /^(\r|\n|\r\n)$/)
105 126 325 unless (@{$self->events;})
109 52 273 if ($event->isa('YAML::Perl::Event::DocumentStart')) { }
46 227 elsif ($event->isa('YAML::Perl::Event::SequenceStart')) { }
44 183 elsif ($event->isa('YAML::Perl::Event::MappingStart')) { }
128 44 144 if ($event->isa('YAML::Perl::Event::DocumentStart') or $event->isa('YAML::Perl::Event::CollectionStart')) { }
37 107 elsif ($event->isa('YAML::Perl::Event::DocumentEnd') or $event->isa('YAML::Perl::Event::CollectionEnd')) { }
0 107 elsif ($event->isa('YAML::Perl::Event::StreamEnd')) { }
141 24 164 if ($level < 0)
150 105 0 @_ ? :
151 14 91 @_ ? :
153 29 76 if (not defined $self->indent) { }
76 0 elsif (not $indentless) { }
154 5 24 if ($flow) { }
168 29 0 if ($self->event->isa('YAML::Perl::Event::StreamStart')) { }
169 0 29 if ($self->event->encoding)
197 29 16 @_ ? :
198 29 16 if ($self->event->isa('YAML::Perl::Event::DocumentStart')) { }
16 0 elsif ($self->event->isa('YAML::Perl::Event::StreamEnd')) { }
199 1 28 if ($self->event->version)
204 0 29 if ($self->event->tags)
221 28 1 unless ($implicit)
224 0 28 if ($self->canonical)
243 29 0 if ($self->event->isa('YAML::Perl::Event::DocumentEnd')) { }
245 0 29 if ($self->event->explicit)
272 4 105 if ($self->event->isa('YAML::Perl::Event::Alias')) { }
105 0 elsif ($self->event->isa('YAML::Perl::Event::Scalar') or $self->event->isa('YAML::Perl::Event::CollectionStart')) { }
280 68 37 if ($self->event->isa('YAML::Perl::Event::Scalar')) { }
17 20 elsif ($self->event->isa('YAML::Perl::Event::SequenceStart')) { }
20 0 elsif ($self->event->isa('YAML::Perl::Event::MappingStart')) { }
284 3 14 if ($self->flow_level or $self->canonical or $self->event->flow_style or $self->check_empty_sequence) { }
296 6 14 if ($self->flow_level or $self->canonical or $self->event->flow_style or $self->check_empty_mapping) { }
317 0 4 unless ($self->event->anchor)
344 3 0 if ($self->event->isa('YAML::Perl::Event::SequenceEnd')) { }
351 0 0 if ($self->canonical or $self->column > $self->best_width)
362 0 0 if ($self->event->isa('YAML::Perl::Event::SequenceEnd')) { }
365 0 0 if ($self->canonical)
374 0 0 if ($self->canonical or $self->column > $self->best_width)
392 6 0 if ($self->event->isa('YAML::Perl::Event::MappingEnd')) { }
399 0 0 if ($self->canonical or $self->column > $self->best_width)
402 0 0 if (not $self->canonical and $self->check_simple_key) { }
416 0 0 if ($self->event->isa('YAML::Perl::Event::MappingEnd')) { }
419 0 0 if ($self->canonical)
428 0 0 if ($self->canonical or $self->column > $self->best_width)
431 0 0 if (not $self->canonical and $self->check_simple_key) { }
452 0 0 if ($self->canonical or $self->column > $self->best_width)
474 14 36 @_ ? :
475 14 36 if (not $first and $self->event->isa('YAML::Perl::Event::SequenceEnd')) { }
500 14 22 @_ ? :
501 14 22 if (not $first and $self->event->isa('YAML::Perl::Event::MappingEnd')) { }
507 22 0 if ($self->check_simple_key) { }
550 0 1 unless ($self->event->isa('YAML::Perl::Event::DocumentStart') and $self->events)
568 0 22 if ($self->event->isa('YAML::Perl::Event::Node') and defined $self->event->anchor)
571 0 0 unless ($self->prepared_anchor)
576 0 22 if ($self->event->isa('YAML::Perl::Event::Scalar') || $self->event->isa('YAML::Perl::Event::CollectionStart') and $self->event->tag)
581 0 0 unless ($self->prepared_tag)
586 22 0 if ($self->event->isa('YAML::Perl::Event::Scalar'))
587 22 0 unless ($self->analysis)
610 101 8 unless (defined $self->event->anchor)
614 8 0 unless (defined $self->prepared_anchor)
617 8 0 if ($self->prepared_anchor)
625 68 37 if ($self->event->isa('YAML::Perl::Event::Scalar')) { }
626 68 0 unless ($self->style)
629 65 3 if (not $self->canonical && $tag and $self->style eq '' && $self->event->implicit->[0] || $self->style ne '' && $self->event->implicit->[1])
638 0 3 if ($self->event->implicit->[0] and not $tag)
644 31 6 if (not $self->canonical && $tag and $self->event->implicit)
649 0 9 unless ($tag)
652 9 0 unless ($self->prepared_tag)
655 9 0 if ($self->prepared_tag)
663 46 82 unless ($self->analysis)
666 1 127 if ($self->event->style and $self->event->style eq '"' or $self->canonical)
671 1 126 if ($self->event->value =~ /\n/ and length $self->event->value >= 16)
676 120 6 if (not $self->event->style and $self->event->implicit->[0])
677 120 0 if (not $self->simple_key_context && ($self->analysis->empty || $self->analysis->multiline) and $self->flow_level && $self->analysis->allow_flow_plain || !$self->flow_level && $self->analysis->allow_block_plain)
690 3 3 if ($self->event->style and $self->event->style =~ /^[\|\>]$/)
691 3 0 if (not $self->flow_level || $self->simple_key_context and $self->analysis->allow_block)
699 3 0 if (not $self->event->style or $self->event->style eq q['])
700 3 0 if ($self->analysis->allow_single_quoted and not $self->simple_key_context && $self->analysis->multiline)
712 0 68 unless ($self->analysis)
715 60 8 unless ($self->style)
722 1 67 if ($self->style eq '"') { }
3 64 elsif ($self->style eq q[']) { }
0 64 elsif ($self->style eq '>') { }
4 60 elsif ($self->style eq '|') { }
745 0 1 if ($major != 1)
754 0 0 unless ($handle)
757 0 0 if (substr($handle, 0, 1) ne '!' or substr($handle, -1, 1) ne '!')
764 0 0 unless ($ch ge '0' and $ch le '9' or $ch ge 'A' and $ch le 'Z' or $ch ge 'a' and $ch le 'z' or $ch =~ /^[\-\_]$/)
782 0 0 unless (length $prefix)
788 0 0 if (substr($prefix, 0, 1) eq '!')
793 0 0 if ($ch ge '0' and $ch le '9' or $ch ge 'A' and $ch le 'Z' or $ch ge 'a' and $ch le 'z' or $ch =~ m<^[\-\;/\?\!\:\@\&\=\+\$\,\_\.\~\*\\\'\(\)\[\]]$>) { }
801 0 0 if ($start < $end)
811 0 0 if ($start < $end)
821 0 9 unless ($tag)
824 0 9 if ($tag eq '!')
830 9 0 if ($tag =~ /^\Q$prefix\E/ and $prefix eq '!' || length $prefix < length $tag)
843 126 0 if ($ch ge '0' and $ch le '9' or $ch ge 'A' and $ch le 'Z' or $ch ge 'a' and $ch le 'z' or $ch =~ m<^[\-\;/\?\:\@\&\=\+\$\,\_\.\~\*\\\'\(\)\[\]]$> or $ch eq '!' and $handle ne '!') { }
853 0 0 if ($start < $end)
863 9 0 if ($start < $end)
867 9 0 if ($handle) { }
878 0 8 unless ($anchor)
882 0 24 unless ($ch =~ /[0-9A-Za-z-_]/)
894 0 68 unless (length $scalar)
924 8 60 if ($scalar =~ /^---/ or $scalar =~ /^.../)
956 68 161 if ($index == 0) { }
958 0 68 if ($ch =~ /^[\#\,\[\]\{\}\&\*\!\|\>\'\"\%\@\`]$/)
962 0 68 if ($ch =~ /^[\?\:]$/)
964 0 0 if ($followed_by_space)
968 0 68 if ($ch eq '-' and $followed_by_space)
975 0 161 if ($ch =~ /^[\,\?\[\]\{\}]$/)
978 0 161 if ($ch eq ':')
980 0 0 if ($followed_by_space)
984 0 161 if ($ch eq '#' and $preceeded_by_space)
992 11 218 if ($ch =~ /^[\n\x85\x{2028}\x{2029}]$/)
995 0 218 unless ($ch eq "\n" or $ch ge ' ' and $ch le '~')
996 0 0 if ($ch eq "\205" || $ch ge "\240" && $ch le "\x{d7ff}" || $ch ge '' && $ch le '�' and $ch ne '') { }
1004 0 0 unless ($self->allow_unicode)
1016 24 205 if ($ch =~ /^[\ \n\x85\x{2028}\x{2029}]$/) { }
19 186 elsif ($spaces or $breaks) { }
1017 0 24 if ($spaces and $breaks) { }
0 24 elsif ($spaces) { }
0 24 elsif ($breaks) { }
1018 0 0 if ($ch ne ' ')
1023 0 0 if ($ch ne ' ')
1029 0 0 if ($ch eq ' ')
1035 13 11 if ($ch eq ' ') { }
1046 0 19 if ($leading) { }
1047 0 0 if ($spaces and $breaks) { }
0 0 elsif ($spaces) { }
0 0 elsif ($breaks) { }
1058 0 19 if ($mixed) { }
0 19 elsif ($spaces and $breaks) { }
13 6 elsif ($spaces) { }
6 0 elsif ($breaks) { }
1075 5 224 if ($spaces || $breaks and $index == length($scalar) - 1)
1076 0 5 if ($spaces and $breaks) { }
0 5 elsif ($spaces) { }
5 0 elsif ($breaks) { }
1081 0 0 if ($leading)
1087 0 5 if ($leading)
1112 0 68 if ($leading_spaces or $leading_breaks or $trailing_spaces)
1118 5 63 if ($trailing_breaks)
1124 0 68 if ($inline_breaks_spaces)
1130 0 68 if ($mixed_breaks_spaces or $special_characters)
1136 5 63 if ($line_breaks)
1141 8 60 if ($flow_indicators)
1146 8 60 if ($block_indicators)
1164 0 45 if ($self->writer->stream->can('flush'))
1171 0 29 if ($self->encoding and $self->encoding =~ /^utf-16/)
1186 124 9 unless defined $whitespace
1187 97 36 unless defined $indention
1190 100 33 if ($self->whitespace or not $need_whitespace) { }
1199 0 133 if ($self->encoding)
1208 0 41 if (not $self->indention or $self->column > $indent or $self->column == $indent and not $self->whitespace)
1214 17 107 if ($self->column < $indent)
1218 0 17 if ($self->encoding)
1228 97 0 unless (defined $data)
1235 0 97 if ($self->encoding)
1245 0 1 if ($self->encoding)
1259 3 0 @_ ? :
1268 36 3 if ($end < length $text)
1271 3 36 if ($spaces) { }
0 36 elsif ($breaks) { }
1272 3 0 if (not defined $ch or $ch ne ' ')
1273 0 3 if ($start + 1 == $end and $self->column > $self->best_width and $split and $start != 0 and $end != length $text) { }
1284 0 3 if ($self->encoding)
1293 0 0 unless (defined $ch and $ch =~ /^[\n\x85\x{2028}\x{2029}]$/)
1294 0 0 if (substr($text, $start, 1) eq "\n")
1298 0 0 if ($br eq "\n") { }
1310 3 30 if (not defined $ch or $ch =~ /^[\ \n\x85\x{2028}\x{2029}]$/ or $ch eq q['])
1314 6 0 if ($start < $end)
1317 0 6 if ($self->encoding)
1325 0 39 if ($ch and $ch eq q['])
1328 0 0 if ($self->encoding)
1334 36 3 if (defined $ch)
1364 1 0 @_ ? :
1371 8 1 if ($end < length $text)
1374 2 6 if (not defined $ch or $ch =~ /^[\"\\\x85\x{2028}\x{2029}\x{FEFF}]$/ or not $ch ge ' ' && $ch le '~' || $self->allow_unicode && ($ch ge "\240" && $ch le "\x{d7ff}" || $ch ge '' && $ch le '�'))
1385 2 1 if ($start < $end)
1388 0 2 if ($self->encoding)
1394 2 1 if (defined $ch)
1396 2 0 if (defined { => '0',  => 'a',  => 'b', => 't', => 'n', => 'v', => 'f', => 'r',  => 'e', " => '"', \ => '\\', … => 'N',   => '_', 
 => 'L', 
 => 'P'}->{$ch}) { }
0 0 elsif ($ch le "\377") { }
1409 0 2 if ($self->encoding)
1416 0 2 if ($end > 0 and $end < length($text) - 1 and $ch eq ' ' || $start >= $end and $self->column + ($end - $start) > $self->best_width and $split)
1422 0 0 if ($start < $end)
1426 0 0 if ($self->encoding)
1433 0 0 if (substr($text, $start, 1) eq ' ')
1436 0 0 if ($self->encoding)
1451 4 0 if ($text)
1452 0 4 if ($text =~ /^[ \n\x85\x{2028}\x{2029}]/)
1455 0 4 if (not $text =~ /[\n\x85\x{2028}\x{2029}]\z/) { }
0 4 elsif (length $text == 1 or $text =~ /[\n\x85\x{2028}\x{2029}].\z/s) { }
1479 99 4 if ($end < length $text)
1482 13 90 if ($breaks) { }
1483 13 0 unless (defined $ch and $ch =~ /^[\n\x85\x{2028}\x{2029}]$/)
1485 9 0 if ($br eq "\n") { }
1492 9 4 if (defined $ch)
1499 9 81 if (not defined $ch or $ch =~ /^[\n\x85\x{2028}\x{2029}]$/)
1501 0 9 if ($self->encoding)
1505 0 9 unless (defined $ch)
1511 99 4 if (defined $ch)
1512 9 90 $ch =~ /^[\n\x85\x{2028}\x{2029}]$/ ? :
1522 0 60 unless (length $text)
1525 38 22 unless ($self->whitespace)
1528 0 38 if ($self->encoding)
1540 86 60 if ($end < length $text)
1543 0 146 if ($spaces) { }
0 146 elsif ($breaks) { }
1544 0 0 if ($ch ne ' ')
1545 0 0 if ($start + 1 == $end and $self->column > $self->best_width and $split) { }
1556 0 0 if ($self->encoding)
1565 0 0 unless ($ch =~ /^[\n\x85\x{2028}\x{2029}]$/)
1566 0 0 if (substr($text, $start, 1) eq "\n")
1570 0 0 if ($br eq "\n") { }
1584 60 86 if (not defined $ch or $ch =~ /^[\ \n\x85\x{2028}\x{2029}]$/)
1587 0 60 if ($self->encoding)
1594 86 60 if (defined $ch)