Branch Coverage

blib/lib/HTML/TreeBuilder.pm
Criterion Covered Total %
branch 204 348 58.6


line true false branch
37 0 20 if (defined &HTML::TreeBuilder::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 362 if (@_)
300 0 17 if @_ % 2
306 28 0 if ($allowed->{$attr}) { }
332 68 0 if defined $val
357 0 20 unless eval "$code 1"
359 0 20 if $err
387 0 3 if $self->{'_warn'}
401 0 1252 if $_[0]{'_stunted'}
408 8 1244 if $self_closed
414 0 1252 if ($tag eq 'x-html')
423 0 1252 unless ($tag =~ /^[-_a-zA-Z0-9:%]+$/s)
455 0 597 if length $k and substr($k, 0, 1) eq '_'
467 1214 38 if ($self->{'_implicit_tags'})
469 1036 178 unless ($HTML::TreeBuilder::isTableElement{$tag})
470 0 1036 if ($ptag eq 'table') { }
0 1036 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 1214 if (not $self->{'_implicit_tags'}) { }
2 1212 elsif ($HTML::TreeBuilder::isHeadOrBodyElement{$tag}) { }
943 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 531 if ($ptag eq 'body') { }
258 273 elsif ($HTML::TreeBuilder::isBodyElement{$ptag} and not $HTML::TreeBuilder::isHeadOrBodyElement{$ptag}) { }
169 104 elsif ($pos->is_inside('head')) { }
104 0 elsif (not $pos->is_inside('body')) { }
638 307 636 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 627 elsif ($tag eq 'ol' or $tag eq 'ul' or $tag eq 'dl') { }
12 615 elsif ($tag eq 'li') { }
0 615 elsif ($tag eq 'dt' or $tag eq 'dd') { }
1 614 elsif ($HTML::TreeBuilder::isFormElement{$tag}) { }
178 436 elsif ($HTML::TreeBuilder::isTableElement{$tag}) { }
387 49 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 9 358 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 1178 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 1187 0 unless ($already_inserted)
1004 8 1179 if ($self_closed) { }
1026 51 1136 unless (($self->{'_pos'} || '') eq $e)
1030 51 0 unless $$self{"_tweak_$tag"} or $self->{'_tweak_*'}
1045 0 1714 if $_[0]{'_stunted'}
1051 0 1714 if ($tag eq 'x-html')
1058 0 1714 unless (ref $tag or $tag =~ /^[-_a-zA-Z0-9:%]+$/s)
1079 415 1299 if (ref $tag) { }
1083 108 307 if ref $tag eq 'SCALAR'
1091 34 1265 $tag =~ /^t[hdr]\z/ ? :
1131 41 1673 if ($tag eq '*') { }
307 1366 elsif (ref $tag) { }
1140 41 90 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 1324 552 if ($ptag eq $tag)
1208 32 35 if ($ptag eq $_)
1218 10 1324 unless defined $p
1224 52 1344 if $self eq ($self->{'_pos'} || '')
1278 1885 0 unless $$self{"_tweak_$ptag"} or $self->{'_tweak_*'}
1282 0 0 if $self->{'_stunted'}
1294 0 2587 if $_[0]{'_stunted'}
1302 0 2587 unless length $text
1312 2585 2 unless $ignore_text or $is_cdata or $HTML::Tagset::isCDATA_Parent{$pos->{'_tag'}} or $no_expand_entities
1338 0 2587 if ($HTML::Tagset::isCDATA_Parent{$ptag = $pos->{'_tag'}} or $pos->is_inside('pre', 'textarea')) { }
1344 0 0 if $ignore_text
1351 1147 1440 if (not $self->{'_implicit_tags'} && $text =~ /[^\n\r\f\t ]/) { }
0 1440 elsif ($ptag eq 'head' or $ptag eq 'noframes') { }
54 1386 elsif ($ptag eq 'html') { }
400 986 elsif ($ptag eq 'body') { }
8 978 elsif ($ptag eq 'table') { }
3 975 elsif ($ptag eq 'tr') { }
1356 0 0 if ($self->{'_implicit_body_p_tag'}) { }
1363 0 0 $self->{'_body'} ? :
1374 0 0 $self->{'_body'} ? :
1379 9 45 if ($self->{'_implicit_body_p_tag'}) { }
1385 9 0 $self->{'_body'} ? :
1395 45 0 $self->{'_body'} ? :
1402 0 400 if ($self->{'_implicit_body_p_tag'})
1435 0 2587 if $ignore_text
1436 2574 13 unless $no_space_compacting
1448 2587 0 unless $self->{'_tweak_~text'}
1467 0 195 if $_[0]{'_stunted'}
1475 194 1 unless $self->{'_store_comments'} or $HTML::Tagset::isCDATA_Parent{$pos->{'_tag'}}
1497 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 373 if $_[0]{'_done'}
1591 0 373 if $_[0]{'_stunted'}
1596 0 373 if (wantarray) { }
1606 327 46 unless $x eq ($x->{'_pos'} || $x)
1612 9 364 unless ($x->{'_implicit_tags'})
1621 18 0 if defined $node and ref $node and $node->{'_implicit'} and $node->{'_parent'}
1635 368 5 if $x->{'_tighten'} and not $x->{'_ignore_text'}
1638 0 373 if wantarray
1651 0 0 if ($HTML::Parser::VERSION < 3) { }
1658 0 0 if (defined $fh)
1698 0 270 unless delete $_[0]{'_content'}
1717 540 0 if defined $_ and ref $_ and $_ ne $_[0]
1722 0 0 if $_[0]{'_parent'} and $_[0]{'_parent'}{'_content'}
1741 513 27 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 379 4258 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
1785 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]