Branch Coverage

blib/lib/HTML/TreeBuilder.pm
Criterion Covered Total %
branch 205 348 58.9


line true false branch
37 0 20 if (defined &DEBUG) { }
0 20 elsif ($] < 5.00404) { }
20 0 elsif (not $DEBUG) { }
0 0 elsif ($DEBUG =~ /^\d+$/s) { }
90 0 17 unless @_ % 2
92 0 17 if ref $class
96 1 16 unless defined $new->parse_file($file)
103 0 8 if ref $class
107 2 7 if (ref $whunk eq 'SCALAR') { }
113 0 9 if $$new{'_stunted'}
121 0 16 unless @_ % 2
123 0 16 if ref $class
134 0 4 unless @_ % 2
136 0 4 if ref $class
145 1 3 unless $lwp_response->is_success
147 1 2 unless $lwp_response->content_is_html
158 0 3 unless @_ % 2
160 0 3 if ref $class
168 0 3 if (defined $opt{'encoding'}) { }
177 0 3 if ($charset eq 'none') { }
181 3 0 if (my $encoding = Encode::find_encoding($charset)) { }
183 0 3 if $$cref =~ /^\x{FeFF}/
201 3 18 if (ref $whunk eq 'SCALAR') { }
207 0 21 if $$tree{'_stunted'}
217 0 20 unless defined $file
220 17 3 unless (defined $fh)
223 11 6 if (not defined $encoding) { }
230 3 7 if $bom
237 4 2 length $encoding ? :
0 6 unless open $fh, length $encoding ? "<:encoding($encoding):crlf" : '<:raw', $file
242 1 16 unless defined $fh
299 17 298 if (@_)
300 0 17 if @_ % 2
306 28 0 if ($$allowed{$attr}) { }
332 36 0 if defined $val
357 0 20 unless eval "$code 1"
359 0 20 if $err
387 0 3 if $$self{'_warn'}
401 0 1228 if $_[0]{'_stunted'}
408 8 1220 if $self_closed
414 0 1228 if ($tag eq 'x-html')
423 0 1228 unless ($tag =~ /^[-_a-zA-Z0-9:%]+$/s)
455 0 597 if length $k and substr($k, 0, 1) eq '_'
467 1190 38 if ($$self{'_implicit_tags'})
469 1012 178 unless ($HTML::TreeBuilder::isTableElement{$tag})
470 0 1012 if ($ptag eq 'table') { }
0 1012 elsif ($ptag eq 'tr') { }
494 0 0 if ($$self{'_p_strict'} and $HTML::TreeBuilder::isKnown{$tag} and not $HTML::Tagset::is_Possible_Strict_P_Content{$tag})
501 0 0 if ($here_tag eq 'p')
515 0 0 if $HTML::TreeBuilder::isKnown{$here_tag} and not $HTML::Tagset::is_Possible_Strict_P_Content{$here_tag}
532 38 1190 if (not $$self{'_implicit_tags'}) { }
2 1188 elsif ($HTML::TreeBuilder::isHeadOrBodyElement{$tag}) { }
919 269 elsif ($HTML::TreeBuilder::isBodyElement{$tag}) { }
204 65 elsif ($HTML::TreeBuilder::isHeadElement{$tag}) { }
21 44 elsif ($tag eq 'html') { }
22 22 elsif ($tag eq 'head') { }
22 0 elsif ($tag eq 'body') { }
0 0 elsif ($tag eq 'frameset') { }
0 0 elsif ($tag eq 'frame') { }
0 0 elsif ($tag eq 'noframes') { }
540 1 1 if ($pos->is_inside('body')) { }
1 0 elsif ($pos->is_inside('head')) { }
554 0 0 if ($ptag eq 'html') { }
558 0 0 unless ref $$self{'_head'}
559 0 0 if ($$self{'_head'}{'_implicit'}) { }
593 412 507 if ($ptag eq 'body') { }
258 249 elsif ($HTML::TreeBuilder::isBodyElement{$ptag} and not $HTML::TreeBuilder::isHeadOrBodyElement{$ptag}) { }
169 80 elsif ($pos->is_inside('head')) { }
80 0 elsif (not $pos->is_inside('body')) { }
638 307 612 if ($tag eq 'p' or $tag eq 'h1' or $tag eq 'h2' or $tag eq 'h3' or $tag eq 'h4' or $tag eq 'h5' or $tag eq 'h6' or $tag eq 'form') { }
9 603 elsif ($tag eq 'ol' or $tag eq 'ul' or $tag eq 'dl') { }
12 591 elsif ($tag eq 'li') { }
0 591 elsif ($tag eq 'dt' or $tag eq 'dd') { }
1 590 elsif ($HTML::TreeBuilder::isFormElement{$tag}) { }
178 412 elsif ($HTML::TreeBuilder::isTableElement{$tag}) { }
371 41 elsif ($HTML::TreeBuilder::isPhraseMarkup{$tag}) { }
664 0 9 if ($ptag eq 'h1' or $ptag eq 'h2' or $ptag eq 'h3' or $ptag eq 'h4' or $ptag eq 'h5' or $ptag eq 'h6')
682 0 12 unless (exists $HTML::TreeBuilder::isList{$ptag} or $self->end(\'*', keys %HTML::TreeBuilder::isList))
698 0 0 unless ($ptag eq 'dl' or $self->end(\'*', 'dl'))
707 0 1 if ($$self{'_ignore_formies_outside_form'} and not $pos->is_inside('form'))
717 0 1 if ($tag eq 'option')
722 0 0 unless ($ptag eq 'select' or $ptag eq 'optgroup')
734 3 175 unless ($pos->is_inside('table'))
740 111 67 if ($tag eq 'td' or $tag eq 'th') { }
743 2 109 unless ($ptag eq 'tr' or $self->end(\'*', 'tr', 'table'))
776 1 370 if ($ptag eq 'body' and $$self{'_implicit_body_p_tag'})
793 3 201 if ($pos->is_inside('body')) { }
167 34 elsif (not $pos->is_inside('head')) { }
813 21 0 if (delete $$self{'_implicit'}) { }
834 22 0 if (delete $$head{'_implicit'}) { }
854 22 0 if (delete $$body{'_implicit'}) { }
873 0 0 unless ($$self{'_frameset_seen'}++ or $$self{'_noframes_seen'} or $self->is_inside('body'))
890 0 0 if ($$c[$i] eq $body)
900 0 0 unless $already_inserted
919 0 0 if ($$self{'_noframes_seen'}++) { }
923 0 0 if ($pos->is_inside('body')) { }
943 0 0 if ($$self{'_ignore_unknown'}) { }
970 1154 9 if ($$self{'_tighten'} and not $$self{'_ignore_text'})
973 131 168 if ($sibs = ($par = $$self{'_pos'} || $self)->{'_content'} and @$sibs and not ref $$sibs[-1] and not $$sibs[-1] =~ /[^\n\r\f\t ]/s and $HTML::TreeBuilder::canTighten{$tag} || (@$sibs == 1 ? $HTML::TreeBuilder::canTighten{$$par{'_tag'}} : ref $$sibs[-2] && $HTML::TreeBuilder::canTighten{$$sibs[-2]{'_tag'}}) and not $par->is_inside('pre', 'xmp', 'textarea', 'plaintext'))
1003 1163 0 unless ($already_inserted)
1004 8 1155 if ($self_closed) { }
1026 43 1120 unless (($$self{'_pos'} || '') eq $e)
1029 43 0 unless $$self{"_tweak_$tag"} or $$self{'_tweak_*'}
1045 0 1634 if $_[0]{'_stunted'}
1051 0 1634 if ($tag eq 'x-html')
1058 0 1634 unless (ref $tag or $tag =~ /^[-_a-zA-Z0-9:%]+$/s)
1079 415 1219 if (ref $tag) { }
1083 108 307 if ref $tag eq 'SCALAR'
1091 34 1185 $tag =~ /^t[hdr]\z/ ? :
1131 41 1593 if ($tag eq '*') { }
307 1286 elsif (ref $tag) { }
1140 41 84 if ($ptag eq $_)
1153 0 41 unless (defined $p)
1175 31 4983 if ($ptag eq $_)
1181 0 8295 if ($ptag eq $_)
1191 276 31 unless defined $p
1203 1252 456 if ($ptag eq $tag)
1208 32 35 if ($ptag eq $_)
1218 2 1252 unless defined $p
1224 52 1272 if $self eq ($$self{'_pos'} || '')
1277 1741 0 unless $$self{"_tweak_$ptag"} or $$self{'_tweak_*'}
1282 0 0 if $$self{'_stunted'}
1294 0 2523 if $_[0]{'_stunted'}
1302 0 2523 unless length $text
1309 2521 2 unless $ignore_text or $is_cdata or $HTML::Tagset::isCDATA_Parent{$$pos{'_tag'}} or $no_expand_entities
1338 0 2523 if ($HTML::Tagset::isCDATA_Parent{$ptag = $$pos{'_tag'}} or $pos->is_inside('pre', 'textarea')) { }
1344 0 0 if $ignore_text
1351 1147 1376 if (not $$self{'_implicit_tags'} && $text =~ /[^\n\r\f\t ]/) { }
0 1376 elsif ($ptag eq 'head' or $ptag eq 'noframes') { }
22 1354 elsif ($ptag eq 'html') { }
376 978 elsif ($ptag eq 'body') { }
8 970 elsif ($ptag eq 'table') { }
3 967 elsif ($ptag eq 'tr') { }
1356 0 0 if ($$self{'_implicit_body_p_tag'}) { }
1361 0 0 $$self{'_body'} ? :
1372 0 0 $$self{'_body'} ? :
1379 1 21 if ($$self{'_implicit_body_p_tag'}) { }
1383 1 0 $$self{'_body'} ? :
1393 21 0 $$self{'_body'} ? :
1402 0 376 if ($$self{'_implicit_body_p_tag'})
1435 0 2523 if $ignore_text
1436 2510 13 unless $no_space_compacting
1448 2523 0 unless $$self{'_tweak_~text'}
1467 0 195 if $_[0]{'_stunted'}
1474 194 1 unless $$self{'_store_comments'} or $HTML::Tagset::isCDATA_Parent{$$pos{'_tag'}}
1496 1 0 unless $$self{'_tweak_~comment'} or $$self{'_tweak_*'}
1504 0 17 if $_[0]{'_stunted'}
1534 0 2 if $_[0]{'_stunted'}
1538 2 0 unless $_[0]{'_store_pis'}
1560 0 0 unless $$self{'_tweak_~pi'} or $$self{'_tweak_*'}
1589 0 309 if $_[0]{'_done'}
1591 0 309 if $_[0]{'_stunted'}
1596 0 309 if (wantarray) { }
1606 271 38 unless $x eq ($$x{'_pos'} || $x)
1612 9 300 unless ($$x{'_implicit_tags'})
1617 18 0 if defined $node and ref $node and $$node{'_implicit'} and $$node{'_parent'}
1635 304 5 if $$x{'_tighten'} and not $$x{'_ignore_text'}
1638 0 309 if wantarray
1651 0 0 if ($HTML::Parser::VERSION < 3) { }
1658 0 0 if (defined $fh)
1698 0 250 unless delete $_[0]{'_content'}
1717 500 0 if defined $_ and ref $_ and $_ ne $_[0]
1722 0 250 if $_[0]{'_parent'} and $_[0]{'_parent'}{'_content'}
1741 57 3 if length $_ and substr($_, 0, 1) eq '_' and $_ ne '_tag' and $_ ne '_parent' and $_ ne '_content' and $_ ne '_implicit' and $_ ne '_pos' and $_ ne '_element_class'
1757 315 4066 unless ref $_[0]
1770 0 0 if (not ref $this) { }
0 0 elsif (not $$this{'_implicit'}) { }
1775 0 0 if $destructive
1780 0 0 if $destructive
1781 0 0 $destructive ? :
0 0 unless $destructive ? delete $$this{'_content'} : $$this{'_content'}
1795 0 0 if wantarray
1796 0 0 unless @out
1797 0 0 if @out == 1 and ref $out[0]