Branch Coverage

blib/lib/HTML/TreeBuilder.pm
Criterion Covered Total %
branch 173 306 56.5


line true false branch
35 0 16 if (defined &HTML::TreeBuilder::DEBUG) { }
0 16 elsif ($] < 5.00404) { }
16 0 elsif (not $DEBUG) { }
0 0 elsif ($DEBUG =~ /^\d+$/s) { }
88 0 3 unless @_ == 1
90 0 3 if ref $class
93 1 2 unless defined $new->parse_file($_[0])
100 0 8 if ref $class
104 1 8 if (ref $whunk eq 'SCALAR') { }
110 0 9 if $new->{'_stunted'}
119 0 4 unless @_ == 1
121 0 4 if ref $class
131 1 3 unless $lwp_response->is_success
133 1 2 unless $lwp_response->content_is_html
147 1 9 if (ref $whunk eq 'SCALAR') { }
153 0 10 if $tree->{'_stunted'}
206 4 287 if (@_)
236 21 0 if defined $val
262 0 1 if $self->{'_warn'}
276 0 1005 if $_[0]{'_stunted'}
285 0 1005 if ($tag eq 'x-html')
294 0 1005 unless ($tag =~ /^[-_a-zA-Z0-9:%]+$/s)
326 0 503 if length $k and substr($k, 0, 1) eq '_'
338 983 22 if ($self->{'_implicit_tags'})
340 829 154 unless ($HTML::TreeBuilder::isTableElement{$tag})
341 0 829 if ($ptag eq 'table') { }
0 829 elsif ($ptag eq 'tr') { }
365 0 0 if ($self->{'_p_strict'} and $HTML::TreeBuilder::isKnown{$tag} and not $HTML::Tagset::is_Possible_Strict_P_Content{$tag})
372 0 0 if ($here_tag eq 'p')
386 0 0 if $HTML::TreeBuilder::isKnown{$here_tag} and not $HTML::Tagset::is_Possible_Strict_P_Content{$here_tag}
403 22 983 if (not $self->{'_implicit_tags'}) { }
1 982 elsif ($HTML::TreeBuilder::isHeadOrBodyElement{$tag}) { }
799 183 elsif ($HTML::TreeBuilder::isBodyElement{$tag}) { }
167 16 elsif ($HTML::TreeBuilder::isHeadElement{$tag}) { }
4 12 elsif ($tag eq 'html') { }
6 6 elsif ($tag eq 'head') { }
6 0 elsif ($tag eq 'body') { }
0 0 elsif ($tag eq 'frameset') { }
0 0 elsif ($tag eq 'frame') { }
0 0 elsif ($tag eq 'noframes') { }
411 0 1 if ($pos->is_inside('body')) { }
1 0 elsif ($pos->is_inside('head')) { }
425 0 0 if ($ptag eq 'html') { }
429 0 0 unless ref $self->{'_head'}
430 0 0 if ($self->{'_head'}{'_implicit'}) { }
464 352 447 if ($ptag eq 'body') { }
206 241 elsif ($HTML::TreeBuilder::isBodyElement{$ptag} and not $HTML::TreeBuilder::isHeadOrBodyElement{$ptag}) { }
164 77 elsif ($pos->is_inside('head')) { }
77 0 elsif (not $pos->is_inside('body')) { }
509 243 556 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 547 elsif ($tag eq 'ol' or $tag eq 'ul' or $tag eq 'dl') { }
12 535 elsif ($tag eq 'li') { }
0 535 elsif ($tag eq 'dt' or $tag eq 'dd') { }
1 534 elsif ($HTML::TreeBuilder::isFormElement{$tag}) { }
154 380 elsif ($HTML::TreeBuilder::isTableElement{$tag}) { }
347 33 elsif ($HTML::TreeBuilder::isPhraseMarkup{$tag}) { }
535 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')
553 0 12 unless (exists $HTML::TreeBuilder::isList{$ptag} or $self->end(\'*', keys %HTML::TreeBuilder::isList))
569 0 0 unless ($ptag eq 'dl' or $self->end(\'*', 'dl'))
578 0 1 if ($self->{'_ignore_formies_outside_form'} and not $pos->is_inside('form'))
588 0 1 if ($tag eq 'option')
593 0 0 unless ($ptag eq 'select' or $ptag eq 'optgroup')
605 3 151 unless ($pos->is_inside('table'))
611 96 58 if ($tag eq 'td' or $tag eq 'th') { }
614 2 94 unless ($ptag eq 'tr' or $self->end(\'*', 'tr', 'table'))
647 1 342 if ($ptag eq 'body' and $self->{'_implicit_body_p_tag'})
664 1 166 if ($pos->is_inside('body')) { }
164 2 elsif (not $pos->is_inside('head')) { }
684 4 0 if (delete $self->{'_implicit'}) { }
705 6 0 if (delete $head->{'_implicit'}) { }
725 6 0 if (delete $body->{'_implicit'}) { }
744 0 0 unless ($self->{'_frameset_seen'}++ or $self->{'_noframes_seen'} or $self->is_inside('body'))
761 0 0 if ($c->[$i] eq $body)
771 0 0 unless $already_inserted
790 0 0 if ($self->{'_noframes_seen'}++) { }
794 0 0 if ($pos->is_inside('body')) { }
814 0 0 if ($self->{'_ignore_unknown'}) { }
841 980 9 if ($self->{'_tighten'} and not $self->{'_ignore_text'})
844 34 163 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'))
874 989 0 unless $already_inserted
894 15 974 unless (($self->{'_pos'} || '') eq $e)
898 15 0 unless $$self{"_tweak_$tag"} or $self->{'_tweak_*'}
913 0 1400 if $_[0]{'_stunted'}
919 0 1400 if ($tag eq 'x-html')
926 0 1400 unless (ref $tag or $tag =~ /^[-_a-zA-Z0-9:%]+$/s)
947 336 1064 if (ref $tag) { }
951 93 243 if ref $tag eq 'SCALAR'
959 34 1030 $tag =~ /^t[hdr]\z/ ? :
999 35 1365 if ($tag eq '*') { }
243 1122 elsif (ref $tag) { }
1008 35 78 if ($ptag eq $_)
1021 0 35 unless (defined $p)
1043 23 3960 if ($ptag eq $_)
1049 0 6600 if ($ptag eq $_)
1059 220 23 unless defined $p
1071 1092 419 if ($ptag eq $tag)
1076 29 29 if ($ptag eq $_)
1086 1 1092 unless defined $p
1092 17 1133 if $self eq ($self->{'_pos'} || '')
1146 1535 0 unless $$self{"_tweak_$ptag"} or $self->{'_tweak_*'}
1150 0 0 if $self->{'_stunted'}
1162 0 2152 if $_[0]{'_stunted'}
1170 0 2152 unless length $text
1180 2150 2 unless $ignore_text or $is_cdata or $HTML::Tagset::isCDATA_Parent{$pos->{'_tag'}} or $no_expand_entities
1205 0 2152 if ($HTML::Tagset::isCDATA_Parent{$ptag = $pos->{'_tag'}} or $pos->is_inside('pre', 'textarea')) { }
1211 0 0 if $ignore_text
1218 895 1257 if (not $self->{'_implicit_tags'} && $text =~ /[^\n\r\f\t ]/) { }
0 1257 elsif ($ptag eq 'head' or $ptag eq 'noframes') { }
22 1235 elsif ($ptag eq 'html') { }
370 865 elsif ($ptag eq 'body') { }
8 857 elsif ($ptag eq 'table') { }
3 854 elsif ($ptag eq 'tr') { }
1223 0 0 if ($self->{'_implicit_body_p_tag'}) { }
1230 0 0 $self->{'_body'} ? :
1241 0 0 $self->{'_body'} ? :
1246 1 21 if ($self->{'_implicit_body_p_tag'}) { }
1252 1 0 $self->{'_body'} ? :
1262 21 0 $self->{'_body'} ? :
1269 0 370 if ($self->{'_implicit_body_p_tag'})
1302 0 2152 if $ignore_text
1303 2139 13 unless $no_space_compacting
1315 2152 0 unless $self->{'_tweak_~text'}
1334 0 188 if $_[0]{'_stunted'}
1342 187 1 unless $self->{'_store_comments'} or $HTML::Tagset::isCDATA_Parent{$pos->{'_tag'}}
1363 1 0 unless $self->{'_tweak_~comment'} or $self->{'_tweak_*'}
1370 0 2 if $_[0]{'_stunted'}
1399 0 0 if $_[0]{'_stunted'}
1403 0 0 unless $_[0]{'_store_pis'}
1424 0 0 unless $self->{'_tweak_~pi'} or $self->{'_tweak_*'}
1453 0 283 if $_[0]{'_done'}
1455 0 283 if $_[0]{'_stunted'}
1460 0 283 if (wantarray) { }
1470 263 20 unless $x eq ($x->{'_pos'} || $x)
1476 5 278 unless ($x->{'_implicit_tags'})
1485 10 0 if defined $node and ref $node and $node->{'_implicit'} and $node->{'_parent'}
1499 278 5 if $x->{'_tighten'} and not $x->{'_ignore_text'}
1502 0 283 if wantarray
1515 0 0 if ($HTML::Parser::VERSION < 3) { }
1522 0 0 if (defined $fh)
1562 0 250 unless delete $_[0]{'_content'}
1581 500 0 if defined $_ and ref $_ and $_ ne $_[0]
1586 0 0 if $_[0]{'_parent'} and $_[0]{'_parent'}{'_content'}
1605 51 6 if length $_ and substr($_, 0, 1) eq '_' and $_ ne '_tag' and $_ ne '_parent' and $_ ne '_content' and $_ ne '_implicit' and $_ ne '_pos'
1620 291 3780 unless ref $_[0]
1633 0 0 if (not ref $this) { }
0 0 elsif (not $this->{'_implicit'}) { }
1638 0 0 if $destructive
1643 0 0 if $destructive
1648 0 0 $destructive ? :
0 0 unless $destructive ? delete $this->{'_content'} : $this->{'_content'}
1658 0 0 if wantarray
1659 0 0 unless @out
1660 0 0 if @out == 1 and ref $out[0]