Branch Coverage

lib/HTML/Object/Element.pm
Criterion Covered Total %
branch 158 644 24.5


line true false branch
50 2002 642 unless defined $opts->{$_}
54 1322 0 unless exists $self->{'attr'}
55 1322 0 unless exists $self->{'attr_seq'}
57 1322 0 unless exists $self->{'close_tag'}
60 1322 0 unless exists $self->{'is_closed'}
61 479 843 unless exists $self->{'is_empty'}
68 462 860 unless exists $self->{'tag'}
71 0 1322 unless $self->SUPER::init($opts)
78 986 336 unless exists $opts->{'is_empty'}
79 1001 321 unless exists $opts->{'attributes'}
81 4 1217 if (not $opts->{'is_empty'} and exists $attr->{'/'})
83 0 4 if warnings::enabled()
96 0 0 if (@_) { }
102 0 0 if (not length $path->[0]) { }
109 0 0 if $path->shift != 0
114 0 0 if $offset > $root->children->size
153 87 22 unless exists $opts->{'inside_collection'}
156 11 98 if $self->{'_cache_value'} and not length $self->{'_reset'}
162 48 50 if ($self->original->defined and $hash1 eq $hash2) { }
168 32 18 unless ($self->attributes_sequence->is_empty)
174 0 72 if $k eq "/"
183 55 43 if (not $self->children->is_empty) { }
185 0 55 if ($self->is_empty)
187 0 0 if warnings::enabled()
191 14 41 unless $self->original->defined and $hash1 eq $hash2
196 0 123 if ($opts->{'as_xml'}) { }
204 123 0 defined $v ? :
209 55 0 if (my $close = $self->close_tag)
212 55 0 unless ($parent and defined(my $pos = $parent->children->pos($close)))
220 1 42 if ($self->is_empty) { }
223 0 1 unless $hash1 eq $hash2
229 36 6 unless $self->original->defined and $hash1 eq $hash2
234 34 8 if (my $close = $self->close_tag)
237 30 4 unless ($parent and defined(my $pos = $parent->children->pos($close)))
254 1 11 if $self->{'_cache_text'} and not length $self->{'_reset'}
266 0 19 if exists $seen->{$addr}
268 18 1 if ($e->isa("HTML::Object::Text") or $e->isa("HTML::Object::Space"))
271 0 18 if (exists $opts->{'callback'} and ref $opts->{'callback'} eq "CODE")
274 0 0 unless $opts->{'callback'}->($e)
279 1 18 unless ($e->isa("HTML::Object::Text") or $e->isa("HTML::Object::Space"))
286 0 11 if ($self->isa('HTML::Object::Text') or $self->isa('HTML::Object::Space')) { }
325 0 339 unless $attr =~ /^\w+$/
326 61 278 if (@_) { }
330 61 0 if (defined $v) { }
336 37 24 unless ref $v
338 1 60 unless $self->attributes_sequence->has($attr)
349 3 58 if ref $callbacks ne "HASH"
350 3 58 if (exists $callbacks->{$attr} and ref $callbacks->{$attr} eq "CODE")
353 0 3 if ($INC{'threads.pm'} and not exists $INC{'forks.pm'})
357 2 1 if not defined $Nice::Try::WANTARRAY and scalar @Nice::Try::LAST_VAL
0 0 &$Nice::Try::TRY ? :
0 0 if scalar @Nice::Try::VOID
0 0 if ($Nice::Try::WANT eq 'OBJECT') { }
0 0 elsif ($Nice::Try::WANT eq 'CODE') { }
0 0 elsif ($Nice::Try::WANT eq 'HASH') { }
0 0 elsif ($Nice::Try::WANT eq 'ARRAY') { }
0 0 elsif ($Nice::Try::WANT eq 'REFSCALAR') { }
0 0 elsif ($Nice::Try::WANT eq 'GLOB') { }
0 0 elsif ($Nice::Try::WANT eq 'LIST') { }
0 0 elsif ($Nice::Try::WANT eq 'BOOLEAN') { }
0 0 elsif ($Nice::Try::WANT eq 'VOID') { }
0 0 elsif ($Nice::Try::WANT eq 'SCALAR') { }
0 3 if defined $Nice::Try::LAST_VAL
0 3 if ($Nice::Try::WANTARRAY) { }
0 3 elsif (defined $Nice::Try::WANTARRAY) { }
0 3 if (defined $Nice::Try::WANT and length $Nice::Try::WANT) { }
0 3 length $@ ? :
3 0 unless &Scalar::Util::blessed($@)
0 0 if ($Nice::Try::HAS_CATCH)
0 3 if ($Nice::Try::DIED)
360 0 0 if not defined $Nice::Try::WANTARRAY and scalar @Nice::Try::LAST_VAL
0 0 &$Nice::Try::CATCH ? :
0 0 if scalar @Nice::Try::VOID
0 0 if ($Nice::Try::WANT eq 'OBJECT') { }
0 0 elsif ($Nice::Try::WANT eq 'CODE') { }
0 0 elsif ($Nice::Try::WANT eq 'HASH') { }
0 0 elsif ($Nice::Try::WANT eq 'ARRAY') { }
0 0 elsif ($Nice::Try::WANT eq 'REFSCALAR') { }
0 0 elsif ($Nice::Try::WANT eq 'GLOB') { }
0 0 elsif ($Nice::Try::WANT eq 'LIST') { }
0 0 elsif ($Nice::Try::WANT eq 'BOOLEAN') { }
0 0 elsif ($Nice::Try::WANT eq 'VOID') { }
0 0 elsif ($Nice::Try::WANT eq 'SCALAR') { }
0 0 if ($Nice::Try::WANTARRAY) { }
0 0 elsif (defined $Nice::Try::WANTARRAY) { }
0 0 if (defined $Nice::Try::WANT and length $Nice::Try::WANT) { }
0 0 if $@
0 3 if (defined $Nice::Try::CATCH_DIED)
0 0 if (defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq '__NEXT__') { }
0 0 elsif (defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq '__LAST__') { }
0 0 elsif (defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq '__REDO__') { }
0 0 elsif (defined $Nice::Try::BREAK and $Nice::Try::BREAK eq 'return') { }
0 0 if ($Nice::Try::WANT eq 'LIST') { }
0 0 elsif ($Nice::Try::WANT eq 'VOID') { }
0 0 elsif ($Nice::Try::WANT eq 'OBJECT') { }
0 0 elsif ($Nice::Try::WANT eq 'REFSCALAR') { }
0 0 elsif ($Nice::Try::WANT eq 'SCALAR') { }
0 0 elsif ($Nice::Try::WANT eq 'BOOLEAN') { }
0 0 elsif ($Nice::Try::WANT eq 'CODE') { }
0 0 elsif ($Nice::Try::WANT eq 'HASH') { }
0 0 elsif ($Nice::Try::WANT eq 'ARRAY') { }
0 0 elsif ($Nice::Try::WANT eq 'GLOB') { }
0 0 $Nice::Try::WANTARRAY ? :
0 0 if (defined $Nice::Try::WANT and length $Nice::Try::WANT) { }
0 0 if (not defined $Nice::Try::BREAK or $Nice::Try::BREAK eq "return")
0 0 scalar @Nice::Try::VOID > 1 ? :
0 3 if (defined $Nice::Try::WANTARRAY || defined $Nice::Try::BREAK && $Nice::Try::BREAK eq 'return' and !&Scalar::Util::blessed($Nice::Try::RETVAL[0]) || &Scalar::Util::blessed($Nice::Try::RETVAL[0]) && !$Nice::Try::RETVAL[0]->isa('Nice::Try::SENTINEL')) { }
0 3 elsif (scalar @Nice::Try::VOID and !&Scalar::Util::blessed($Nice::Try::VOID[0]) || &Scalar::Util::blessed($Nice::Try::VOID[0]) && !$Nice::Try::VOID[0]->isa('Nice::Try::SENTINEL')) { }
0 0 if ($Nice::Try::BREAK eq 'next') { }
0 0 elsif ($Nice::Try::BREAK eq 'last') { }
0 0 elsif ($Nice::Try::BREAK eq 'redo') { }
0 3 if (defined $Nice::Try::BREAK)
0 3 scalar @Nice::Try::LAST_VAL > 1 ? :
377 817 321 unless (@_)
379 47 770 if ($self->_set_get_array_as_object("attr_seq")->sort != $self->attributes->keys->sort)
428 1 46 if $self->is_empty
445 6 40 if ($parent)
448 0 6 unless defined $pos
472 0 0 if (want('LIST')) { }
524 0 0 unless $class eq "HTML::Object::Element"
540 12 0 unless $parent
543 0 0 if (defined $pos)
572 0 0 if $self->children->length
591 0 0 if not $e->is_empty or $e->children->length
624 0 0 if exists $$HTML::Object::LINK_ELEMENTS{"$tag"}
627 0 0 if (defined $def and !$has_expectation || $has_expectation && !exists($$wants{"$tag"}))
636 0 0 if ($e->attributes->exists($attr) and length($val = $e->attributes->get($attr)))
648 0 0 if (++$seen->{$addr} > 1)
669 0 0 unless length $att
671 0 0 if $self->attributes->exists($att) and $self->attributes->get($att) eq $val
679 0 0 if $e->class ne "HTML::Object::Element"
680 0 0 if $e->attributes->exists($att) and $e->attributes->get($att) eq $val
681 0 0 if $e->children->length > 0
684 0 0 if $self->children->length > 0
699 0 0 if exists $$tags{$self->tag}
708 0 0 unless $self->_is_a($e, "HTML::Object::Element")
709 0 0 if exists $$tags{$e->tag}
710 0 0 if $e->children->length > 0
713 0 0 if $self->children->length > 0
717 0 0 (shift())->children->is_empty ? :
726 0 0 unless $self->_is_object($e)
727 0 0 unless $e->isa("HTML::Object::Element")
741 4 0 $_[1] =~ /^$HTML::Object::Element::ATTRIBUTE_NAME_RE$/ ? :
749 0 122 @_ ? :
753 4 118 if not defined $pos or $offset > $pos
756 0 118 if $kids->length == 1
792 3 0 if ref $_[-1] eq "HASH"
796 0 3 if (ref $_[$i]) { }
798 0 0 if ref $_[$i] ne "CODE"
821 0 107 if (ref $this eq 'CODE') { }
825 0 0 unless $rc
829 107 0 if ($this->{'key'} eq '_tag') { }
0 0 elsif (not $attr->exists($this->{'key'})) { }
831 0 107 if (ref $this->{'val'} eq 'Regexp') { }
833 0 0 unless $e->tag =~ /$this->{'val'}/
837 97 10 if $e->tag ne $this->{'val'}
842 0 0 if (not defined $this->{'val'}) { }
855 0 0 if (defined $val) { }
857 0 0 if (ref $this->{'val'} eq 'Regexp') { }
0 0 elsif (ref $this->{'val'} and ref $this->{'val'} ne ref $val or !ref($val) || overload::Method($val . '""') and lc "$val" ne lc "$this->{'val'}") { }
859 0 0 unless $val =~ /$this->{'val'}/
875 0 0 if defined $this->{'val'}
882 10 97 if $ok
884 0 107 if exists $opts->{'max_match'} and $a->length >= $opts->{'max_match'}
886 7 100 if exists $opts->{'max_level'} and $def->{'level'} + 1 > $opts->{'max_level'}
888 100 0 if ($opts->{'direction'} eq 'down') { }
0 0 elsif ($opts->{'direction'} eq 'up') { }
890 22 78 if $e->children->length > 0
894 0 0 if $e->parent
921 1 2 if ref $_[-1] eq "HASH"
930 0 0 if ref $_[-1] eq "HASH"
935 0 0 $_[1] =~ /$HTML::Object::Element::LOOK_LIKE_HTML/ ? :
941 1 1 $_[0] =~ /$HTML::Object::Element::LOOK_LIKE_IT_HAS_HTML/ ? :
949 0 0 unless $self->_load_class("HTML::Object::Attribute")
958 0 0 unless $self->_load_class("HTML::Object::Closing")
967 0 0 unless $self->_load_class("HTML::Object::Document")
996 0 0 if scalar @_
1000 0 0 if ($self->_is_array($this)) { }
0 0 elsif ($self->_is_hash($this)) { }
0 0 elsif ($self->_is_object($this) and $this->isa('HTML::Object::Element')) { }
1003 0 0 if (defined $elem or defined $parent)
1011 0 0 unless defined $elem
1017 0 0 $this->parent ? :
1018 0 0 unless defined $custodian
1024 0 0 if $self->_is_object($this) and !overload::Overloaded($this) || overload::Overloaded($this) && !overload::Method($this, '""')
1026 0 0 if (not defined $elem and "$this" =~ /^\w+$/) { }
1029 0 0 if (defined $parent)
1039 0 0 unless defined $custodian
1051 0 0 unless $self->_is_array($this)
1054 0 0 if (scalar @$this > 0) { }
1057 0 0 unless &$crawl($this, $doc)
1072 0 0 unless $self->_load_class("HTML::Object")
1082 0 0 if (scalar @_ == 1 and ref $_[0] eq 'HASH') { }
1091 0 0 unless $self->_load_class("HTML::Object::Text")
1106 0 0 if (defined $_ and $self->_is_a($_, "HTML::Object::Text") and defined $prev and $self->_is_a($prev, "HTML::Object::Text") or defined $_ and $self->_is_a($_, "HTML::Object::Space") and defined $prev and $self->_is_a($prev, "HTML::Object::Space"))
1132 4 224 unless $parent
1149 0 0 unless $parent
1151 0 0 unless defined $pos
1155 0 0 if $_->parent
1168 0 0 unless $parent
1170 0 0 unless defined $pos
1174 0 0 if $_->parent
1186 0 0 unless @_
1191 0 0 if $_->parent
1204 0 0 unless $parent
1206 0 0 unless defined $pos
1210 0 0 if $_->parent
1223 0 0 unless $parent
1225 0 0 unless defined $pos
1239 1364 757 if (not length $self->{'_reset'} and scalar @_)
1242 278 1086 if (my $parent = $self->parent)
1255 2 106 unless $parent
1258 0 106 @_ ? :
1259 0 106 if not defined $pos or $offset < $pos
1260 0 106 if $kids->length == 1
1284 0 0 unless $self->_is_object($elem)
1285 0 0 unless $elem->isa("HTML::Object::Element")
1288 0 0 unless $my_attr eq $her_attr
1291 0 0 if $self->attributes->get($_) ne $elem->attributes->get($_)
1293 0 0 if $self->children->length != $elem->children->length
1298 0 0 if not $e->same_as($her_kids->[$i])
1322 0 0 unless @_
1323 0 0 unless $self->_is_integer($offset)
1324 0 0 unless $self->_is_integer($length)
1329 0 0 if $_->parent
1344 0 0 if ref $code ne "CODE"
1354 0 0 if ++$seen->{$addr} > 1
1356 0 0 unless $opts->{'bottom_up'}
1361 0 0 if $opts->{'bottom_up'}
1371 0 0 unless @_
1389 0 0 unless defined $elt_or_text
1390 0 0 unless (ref $elt_or_text)
1399 0 0 if ref $rank and not $self->_is_a($rank, "Module::Generic::Number")
1419 0 0 if defined $parent
1422 0 0 unless $self->_is_a($_, "HTML::Object::Element")
1424 0 0 if (++$seen->{$addr} > 1)
1426 0 0 if warnings::enabled("HTML::Object")
1429 0 0 if $self_addr eq $addr
1430 0 0 if defined $parent_addr and $addr eq $parent_addr
1431 0 0 if ($_->isa("HTML::Object::Text") and defined $prev and $prev->isa("HTML::Object::Text") or $_->isa("HTML::Object::Space") and defined $prev and $prev->isa("HTML::Object::Space"))
1451 11 5 if ($self->_is_a($this, 'HTML::Object::Element')) { }
1453 0 11 if ($self->_is_a($this, 'HTML::Object::DOM::DocumentFragment')) { }
0 11 elsif ($self->_is_a($this, 'HTML::Object::Text')) { }
1462 0 0 if (defined $prev and $self->_is_a($prev, 'HTML::Object::Text')) { }
1483 0 0 if (ref $this and !$self->_is_object($this) || $self->_is_object($this) && !overload::Method($this, '""'))
1491 1 4 if ("$this" =~ /$HTML::Object::Element::LOOK_LIKE_IT_HAS_HTML/) { }
1496 1 0 unless $res->children->is_empty
1501 0 4 if (defined $prev and $self->_is_a($prev, 'HTML::Object::Text')) { }
1521 101 1038 unless defined $data and length "$data"
1522 0 1038 if ($INC{'threads.pm'} and not exists $INC{'forks.pm'})
1526 0 0 if not defined $Nice::Try::WANTARRAY and scalar @Nice::Try::LAST_VAL
0 0 &$Nice::Try::TRY ? :
0 0 if scalar @Nice::Try::VOID
0 0 if ($Nice::Try::WANT eq 'OBJECT') { }
0 0 elsif ($Nice::Try::WANT eq 'CODE') { }
0 0 elsif ($Nice::Try::WANT eq 'HASH') { }
0 0 elsif ($Nice::Try::WANT eq 'ARRAY') { }
0 0 elsif ($Nice::Try::WANT eq 'REFSCALAR') { }
0 0 elsif ($Nice::Try::WANT eq 'GLOB') { }
0 0 elsif ($Nice::Try::WANT eq 'LIST') { }
0 0 elsif ($Nice::Try::WANT eq 'BOOLEAN') { }
0 0 elsif ($Nice::Try::WANT eq 'VOID') { }
0 0 elsif ($Nice::Try::WANT eq 'SCALAR') { }
0 0 if defined $Nice::Try::LAST_VAL
940 98 if ($Nice::Try::WANTARRAY) { }
98 0 elsif (defined $Nice::Try::WANTARRAY) { }
0 1038 if (defined $Nice::Try::WANT and length $Nice::Try::WANT) { }
0 1038 length $@ ? :
1038 0 unless &Scalar::Util::blessed($@)
0 0 if ($Nice::Try::HAS_CATCH)
0 1038 if ($Nice::Try::DIED)
1529 0 0 if not defined $Nice::Try::WANTARRAY and scalar @Nice::Try::LAST_VAL
0 0 &$Nice::Try::CATCH ? :
0 0 if scalar @Nice::Try::VOID
0 0 if ($Nice::Try::WANT eq 'OBJECT') { }
0 0 elsif ($Nice::Try::WANT eq 'CODE') { }
0 0 elsif ($Nice::Try::WANT eq 'HASH') { }
0 0 elsif ($Nice::Try::WANT eq 'ARRAY') { }
0 0 elsif ($Nice::Try::WANT eq 'REFSCALAR') { }
0 0 elsif ($Nice::Try::WANT eq 'GLOB') { }
0 0 elsif ($Nice::Try::WANT eq 'LIST') { }
0 0 elsif ($Nice::Try::WANT eq 'BOOLEAN') { }
0 0 elsif ($Nice::Try::WANT eq 'VOID') { }
0 0 elsif ($Nice::Try::WANT eq 'SCALAR') { }
0 0 if ($Nice::Try::WANTARRAY) { }
0 0 elsif (defined $Nice::Try::WANTARRAY) { }
0 0 if (defined $Nice::Try::WANT and length $Nice::Try::WANT) { }
0 0 if $@
0 1038 if (defined $Nice::Try::CATCH_DIED)
0 0 if (defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq '__NEXT__') { }
0 0 elsif (defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq '__LAST__') { }
0 0 elsif (defined $Nice::Try::RETVAL[0] and $Nice::Try::RETVAL[0] eq '__REDO__') { }
0 0 elsif (defined $Nice::Try::BREAK and $Nice::Try::BREAK eq 'return') { }
0 0 if ($Nice::Try::WANT eq 'LIST') { }
0 0 elsif ($Nice::Try::WANT eq 'VOID') { }
0 0 elsif ($Nice::Try::WANT eq 'OBJECT') { }
0 0 elsif ($Nice::Try::WANT eq 'REFSCALAR') { }
0 0 elsif ($Nice::Try::WANT eq 'SCALAR') { }
0 0 elsif ($Nice::Try::WANT eq 'BOOLEAN') { }
0 0 elsif ($Nice::Try::WANT eq 'CODE') { }
0 0 elsif ($Nice::Try::WANT eq 'HASH') { }
0 0 elsif ($Nice::Try::WANT eq 'ARRAY') { }
0 0 elsif ($Nice::Try::WANT eq 'GLOB') { }
940 98 $Nice::Try::WANTARRAY ? :
0 1038 if (defined $Nice::Try::WANT and length $Nice::Try::WANT) { }
1038 0 if (not defined $Nice::Try::BREAK or $Nice::Try::BREAK eq "return")
0 0 scalar @Nice::Try::VOID > 1 ? :
1038 0 if (defined $Nice::Try::WANTARRAY || defined $Nice::Try::BREAK && $Nice::Try::BREAK eq 'return' and !&Scalar::Util::blessed($Nice::Try::RETVAL[0]) || &Scalar::Util::blessed($Nice::Try::RETVAL[0]) && !$Nice::Try::RETVAL[0]->isa('Nice::Try::SENTINEL')) { }
0 0 elsif (scalar @Nice::Try::VOID and !&Scalar::Util::blessed($Nice::Try::VOID[0]) || &Scalar::Util::blessed($Nice::Try::VOID[0]) && !$Nice::Try::VOID[0]->isa('Nice::Try::SENTINEL')) { }
0 0 if ($Nice::Try::BREAK eq 'next') { }
0 0 elsif ($Nice::Try::BREAK eq 'last') { }
0 0 elsif ($Nice::Try::BREAK eq 'redo') { }
0 0 if (defined $Nice::Try::BREAK)
0 0 scalar @Nice::Try::LAST_VAL > 1 ? :
1550 0 8 if (not defined $id && length $id) { }
1552 0 0 if ($self->attributes->exists("id"))
1574 0 215 if not defined $this or defined $this and not $self->_is_a($this, "HTML::Object::Element")
1575 101 114 $self->eid eq $this->eid ? :
1582 0 58 if ref $self->{'_internal_attribute_callbacks'} ne "HASH"
1585 0 58 if (scalar @_ == 1) { }
58 0 elsif (scalar @_) { }
1592 0 58 if @_ % 2