Branch Coverage

blib/lib/HTML/Form.pm
Criterion Covered Total %
branch 289 358 80.7


line true false branch
46 23 11 if @_ == 1
50 3 31 ref $html ? :
51 0 34 unless $p
58 0 34 if ($^W)
62 3 31 unless (defined $base_uri)
63 3 0 if (ref $html) { }
70 34 0 unless (defined $charset)
71 2 32 if (ref $html and $html->can("content_charset"))
74 33 1 unless ($charset)
86 38 22 if ($tag eq 'form') { }
0 22 elsif ($form_tags{$tag}) { }
88 25 13 unless defined $action
93 1 37 if $attr->{'accept-charset'}
96 5 33 if $strict
102 36 172 if $tag eq "/form"
104 169 3 if ($tag ne "textarea")
107 13 156 if (defined $current_label)
109 26 0 if defined $_
115 66 106 if ($tag eq "input")
118 5 60 defined $current_label ? :
1 65 exists $attr->{'id'} && exists $labels{$attr->{'id'}} ? :
122 7 165 if ($tag eq 'label') { }
7 158 elsif ($tag eq '/label') { }
66 92 elsif ($tag eq 'input') { }
2 90 elsif ($tag eq 'button') { }
3 87 elsif ($tag eq 'textarea') { }
29 58 elsif ($tag eq 'select') { }
1 57 elsif ($tag eq 'keygen') { }
125 1 6 if exists $attr->{'for'}
140 0 3 if exists $attr->{'value'}
149 1 57 if exists $attr->{$_}
153 4 25 unless defined $name
158 25 101 if $tag eq "/select"
159 0 101 if $tag =~ m[/?optgroup]
160 25 76 if $tag eq "/option"
161 71 5 if ($tag eq 'option') { }
165 31 25 if $_ eq "value"
173 40 31 unless defined $a{'value'}
178 0 5 if $verbose
179 0 1 if ($tag eq "/form" or $tag eq "input" or $tag eq "textarea" or $tag eq "select" or $tag eq "keygen")
190 2 2 $tag =~ s[^/][] ? :
203 0 0 if $verbose
210 5 29 wantarray ? :
231 1 153 unless ($class)
232 1 0 if $verbose
237 7 147 if $type eq "hidden"
238 43 111 if $self->{'strict'}
239 2 11 if ($type eq "file" and exists $attr->{'value'})
258 7 79 if @_
269 0 2 unless defined $name
272 0 2 if @_
280 6 0 if (@_)
302 2 177 if defined $no and $no < 1
304 4 173 if (wantarray) { }
305 1 3 if defined $no
310 9 2 if (defined $selector)
313 4 5 if (ref $selector eq 'SCALAR') { }
315 1 3 if not defined $$selector and $_->{'name'}
321 3 2 unless $_->selected($selector)
324 0 7 if $type and $type ne $_->{'type'}
326 0 7 if $no and $no != $c
335 594 0 if (defined $selector)
338 19 575 if (ref $selector eq 'SCALAR') { }
340 5 14 if not defined $$selector and $_->{'name'}
346 419 156 unless $_->selected($selector)
349 8 162 if $type and $type ne $_->{'type'}
350 22 140 if --$no
372 0 41 unless ($input)
373 0 0 if $self->{'strict'}
374 0 0 unless @_
384 30 2 if (@_) { }
389 135 51 if not defined $n or $n ne $name
393 8 22 if (@_) { }
395 0 8 unless @inputs
397 3 5 if @v == 1 and ref $v[0]
405 7 9 unless ($@)
412 2 7 if $err
424 22 13 if (defined(my $v = $_->value))
428 15 7 wantarray ? :
437 6 8 if not defined $n or $seen{$n}++
452 0 0 unless @not_tried_yet
455 0 0 unless @try
465 0 0 if $i + 1 < @$try
479 38 4 $self->accept_charset eq 'UNKNOWN' ? :
481 130 12 unless ref $fi
484 21 21 if ($method eq 'GET') { }
21 0 elsif ($method eq 'POST') { }
506 0 31 if @_ % 2 == 1
510 52 7 unless $_->can("click")
511 0 7 if $name and not $_->selected($name)
512 1 6 if $_->disabled
515 0 25 if $name
536 0 2 if $enctype ne "application/x-www-form-urlencoded"
539 1 1 if exists $self->{'attr'}{'name'}
544 0 2 unless defined wantarray
570 8 2 if (@_)
590 1 233 if @_
598 0 1 if @_
606 0 1 if @_
612 0 580 unless defined $sel
613 14 540 $sel =~ s/^\.// ? :
20 554 $sel =~ s/^#// ? :
6 574 $sel =~ s/^\^// ? :
618 5 575 unless defined $self->{$attr}
626 1 10 if @_
634 2 4 if @_
659 1 5 if @_
667 1 59 if @_
676 8 68 unless defined $name
677 3 65 if $self->disabled
679 5 60 unless defined $value
687 0 1 unless defined $name
689 0 1 unless defined $value
694 0 1 if $self->disabled
695 0 1 if $self->readonly
696 1 0 unless $self->{'menu'}
702 0 0 unless defined $opt
704 0 0 if defined $_->{'name'} and length $_->{'name'} and $_->{'name'} ne $opt
705 0 0 if $_->{'disabled'}
706 0 0 if (exists $self->{'current'} and $self->{'current'} == $i) { }
707 0 0 unless $_->{'seen'}
711 0 0 if $_->{'seen'}
734 36 80 unless defined $old
735 24 92 if (@_)
737 2 4 if $self->{'strict'} and $self->{'readonly'}
739 4 18 exists $self->{'maxlength'} ? :
741 1 1 if $self->{'strict'} and defined $n and defined $new and length $new > $n
775 7 86 if ($type eq 'checkbox') { }
776 2 5 unless defined $value
781 5 2 delete $self->{'checked'} ? :
786 4 11 if $type eq "radio" and delete $self->{'disabled'}
793 16 70 if (exists $self->{'multiple'}) { }
795 2 14 $checked ? :
798 13 57 if $checked
809 7 86 if $type eq "checkbox"
812 16 55 if ($type eq "option" and exists $self->{'multiple'})
817 0 70 if @{$self->{'menu'};} != 1
819 9 61 if delete $self->{'option_disabled'}
824 32 38 unless $prev
827 4 34 if exists $self->{'current'}
834 11 44 if ($self->{'type'} eq "option" and not exists $self->{'current'})
837 47 8 if exists $self->{'current'}
846 5 41 if (@_)
858 32 6 unless $_->{'disabled'}
867 92 4 if exists $self->{'current'}
868 0 96 if exists $self->{'value'}
869 41 55 if (@_)
875 27 52 if (defined $val and defined $_->{'value'} and $val eq $_->{'value'} or not defined $val || defined $_->{'value'})
881 20 7 unless $disabled
885 21 20 if (not defined $cur or $disabled)
886 20 1 if (defined $val) { }
1 0 elsif ($self->{'strict'}) { }
892 35 8 if (defined $_->{'name'})
893 4 31 if ($val eq $_->{'name'})
896 3 1 unless $disabled
898 3 29 if (not defined $cur_ignorecase and $lc_val eq lc $_->{'name'})
904 10 10 unless (defined $cur)
906 2 8 if (defined $cur) { }
8 0 elsif ($self->{'strict'}) { }
920 7 25 if ($self->{'strict'} and $disabled)
924 25 0 if (defined $cur) { }
962 1 9 unless defined $n
980 12 0 unless defined $_
982 3 3 unless defined $self->value
989 3 4 unless $self->{'clicked'}
1002 0 2 unless $clicked
1003 0 2 if $self->{'disabled'}
1005 1 1 defined $name && length $name ? :
1025 3 13 if @_
1026 13 3 unless defined $old
1034 2 13 if @_
1042 0 13 if @_
1048 1 13 if $form->method ne "POST" or $form->enctype ne "multipart/form-data"
1053 0 13 unless defined $name
1054 0 13 if $self->{'disabled'}
1061 2 11 if (defined $content or grep /^Content$/i, keys %headers) { }
1 10 elsif (not defined $file or length $file == 0) { }
1062 0 2 unless defined $filename
1071 7 5 if (ref $file eq "ARRAY")