Branch Coverage

blib/lib/Data/TableReader.pm
Criterion Covered Total %
branch 178 322 55.2


line true false branch
40 4 19 if ($self->has_col_map)
45 3 20 if (defined(my $act = $args->{'on_validation_fail'}))
47 0 3 if defined $args->{'on_validation_error'}
54 3 0 if (@_)
58 1 2 if ref $act eq "CODE"
68 0 7 unless defined(my $f = $self->field_by_name->{$_})
79 22 0 if ref $i and builtin::blessed($i) && ($i->can('get_cell') || $i->can('worksheets')) || ref $i eq 'ARRAY'
83 0 0 if ref $i and ref $i eq 'GLOB' || ref($i)->can('read')
84 0 0 unless open my $fh, "<", $i
95 23 0 if (not $decoder_arg) { }
0 0 elsif (not $decoder_ref) { }
0 0 elsif ($decoder_ref eq 'HASH' or $decoder_ref eq 'ARRAY') { }
0 0 elsif ($decoder_ref->can('iterator')) { }
103 0 0 $decoder_ref eq 'ARRAY' ? :
107 0 0 unless ($class)
109 0 0 unless $input_class
120 23 0 unless $class =~ /::/
122 0 23 unless &require_module($class)
124 0 23 $self->input eq ($self->_file_handle || '') ? :
135 0 23 unless defined $list and ref $list eq "ARRAY"
138 13 55 if (not ref $_) { }
54 1 elsif (ref $_ eq 'HASH') { }
143 0 54 if defined $args{'isa'} and not defined $args{'type'}
146 0 1 unless builtin::blessed($_) and $_->isa("Data::TableReader::Field")
180 2 0 unless $level eq "warn" or $level eq "error"
181 0 0 if @args
186 229 34 unless $level eq "warn" or $level eq "error"
187 6 28 if @args
192 0 2 @args ? :
2 32 if $dest->can('is_' . $level)->($dest)
195 3 0 ref($dest)->can('info') ? :
19 3 ref $dest eq 'ARRAY' ? :
1 22 if (not $dest) { }
204 1 22 if ref $input and ref($input)->can("get_cell")
206 0 22 if ref $input and ref($input)->can("worksheets")
209 22 0 if (ref $input eq "ARRAY")
213 17 5 if @$input and ref $input->[0] eq "ARRAY" and @{$input->[0];} and ref $input->[0][0] ne "ARRAY"
219 0 0 unless (defined $magic)
222 0 0 if (seek $fh, 0, 1) { }
0 0 elsif ($fh->can('ungets')) { }
225 0 0 unless seek $fh, $fpos, 0
241 0 0 if $magic =~ /^PK(\x03\x04|\x05\x06|\x07\x08)/
242 0 0 if $magic =~ /^\xD0\xCF\x11\xE0/
248 0 0 unless (defined $filename)
250 0 0 if defined $input and !ref($input) || ref($input) =~ /path|file/i
252 0 0 if ($filename =~ /\.([^.]+)$/)
254 0 0 if $suffix eq "HTM"
260 0 0 !defined($fpos) ? :
0 0 unless length $magic
264 0 0 if $magic =~ /^(\xEF\xBB\xBF|\xFF\xFE|\xFE\xFF)?<(!DOCTYPE )HTML/i
267 0 0 if $magic =~ /^(\xEF\xBB\xBF|\xFF\xFE|\xFE\xFF)?["']?[\w ]+["']?,/
268 0 0 if $magic =~ /^(\xEF\xBB\xBF|\xFF\xFE|\xFE\xFF)?["']?[\w ]+["']?\t/
272 0 0 if $comma_count > $eol_count and $comma_count > $tab_count
273 0 0 if $tab_count > $eol_count and $tab_count > $comma_count
276 0 0 if $probably_csv and $probably_csv > $probably_tsv
277 0 0 if $probably_tsv and $probably_tsv > $probably_csv
286 0 6 unless ($result->{'found'})
311 25 140 unless defined $col_map->[$i]
312 46 94 if ($col_map->[$i]->array) { }
349 0 22 unless (defined $header_at)
350 0 0 unless ($self->static_field_order)
354 0 0 $self->has_col_map ? :
373 22 1 ref $header_at ? :
377 1 22 if ($start > 1)
392 2 33 unless ($vals)
396 5 28 if ($row_accum > 1) { }
406 0 33 $self->static_field_order ? :
414 21 12 if ($found) { }
423 0 12 if delete $attempt{'fatal'}
426 9 3 !$self->has_col_map ? :
427 2 10 if ($initial_colmap_count < scalar grep(defined($_), @{$attempt{"col_map"};}))
430 0 2 if ref $act eq "CODE"
432 0 2 if $act eq "last"
446 0 0 $self->has_col_map ? :
449 0 0 unless defined $col_map[$i]
450 0 0 if $header->[$i] =~ $col_map[$i]->header_regex
465 6 27 $self->has_col_map ? :
466 9 1 defined $_ ? :
474 5 92 $_->follows_list ? :
485 33 0 $self->on_ambiguous_columns eq 'error' ? :
495 0 68 if ($fieldname_cols{$f->name}{$idx}) { }
504 9 65 if (not @found_idx and $f->required)
513 2 31 if (@follows_fields and not $attempt->{'missing_required'})
517 5 12 if ($colmap[$idx] and 1 == @{$colmap[$idx];}) { }
522 9 9 unless grep $following{$_}, $f->follows_list
523 2 7 unless $val =~ $f->header_regex
526 0 7 if ($fieldname_cols{$f->name}{$idx}) { }
535 7 5 if ($colmap[$idx] and @{$colmap[$idx];} == 1) { }
545 0 2 if (my(@unfound) = grep(($_->required && !$found{builtin::refaddr($_)}), @follows_fields))
547 0 0 @unfound > 1 ? :
558 18 15 if @unmatched
565 50 7 unless keys %$cols > 1
566 7 0 unless grep((!$_->array), values %$cols)
573 0 33 if keys %ambiguous_fields
580 16 84 unless defined $colmap[$idx]
581 84 0 if (@{$colmap[$idx];} == 1) { }
584 0 84 $ambiguous_fields{$f->name} ? :
596 7 26 unless (grep defined($_), @colmap)
599 0 7 $attempt->{'ambiguous_columns'} || $attempt->{'ambiguous_fields'} ? :
608 2 24 if $attempt->{'missing_required'} or $self->on_ambiguous_columns ne "warn" and $attempt->{'ambiguous_columns'} || $attempt->{'ambiguous_fields'}
611 9 15 if (@unmatched)
614 0 9 if ref $act eq "CODE"
615 6 3 if ($act eq 'warn' or $act eq 'use') { }
3 0 elsif ($act eq 'error' or $act eq 'next') { }
621 0 0 $act eq 'die' ? :
633 25 0 if ref $_[0]
642 0 0 $colmap->{$_} ? :
652 0 24 unless $self->table_search_results->{'found'}
658 3 21 unless ($data_iter)
699 23 56 unless $vals = !$eof && &$data_iter(\@input_slice)
712 2 54 if ($n_blank == @$vals) { }
2 52 elsif ($first_blank) { }
717 0 2 unless ($self->_handle_blank_row($data_iter, $data_iter->row - $first_blank))
730 2 0 @output_slice ? :
52 2 @output_keys ? :
733 11 43 if (@failed)
734 3 7 unless $self->_handle_validation_error(\@failed, $out, $data_iter)
738 0 50 $class ? :
742 1 23 if ($self->record_class eq 'ARRAY') { }
750 3 1 if (defined $src) { }
1 0 elsif (not $need_output_slice) { }
751 0 3 if $need_output_slice
764 0 23 unless "HASH" eq $self->record_class
773 7 79 if (ref $col_idx eq 'ARRAY') { }
24 55 elsif (defined $array_lim) { }
780 6 18 if ($i >= $array_lim) { }
788 85 1 if (my $t = $field->trim_coderef)
795 10 76 if ($field->type)
801 0 0 @output_slice ? :
10 0 @output_keys ? :
806 2 8 if defined $array_start
832 11 19 defined $e ? :
837 0 0 if (defined $e)
839 0 0 unless defined &$t($tmp)
841 0 0 defined $e ? :
849 0 0 if (defined $e)
851 0 0 unless defined $t->validate($tmp)
853 0 0 defined $e ? :
858 5 0 if (defined $e)
860 4 1 unless defined $t->validate($tmp)
862 1 4 defined $e ? :
867 1 9 defined $e ? :
870 0 0 ref $c eq 'CODE' ? :
7 0 !$c ? :
1 2 $c && $t_can_coerce ? :
0 3 ref $c eq 'CODE' ? :
3 0 $t_can_validate ? :
7 3 if (ref $t eq 'CODE') { }
878 0 2 if ref $act eq "CODE"
880 2 0 if ($act eq "next")
881 2 0 $first == $last ? :
887 0 0 if ($act eq "last")
891 0 0 if ($act eq "die")
902 6 5 if (ref $act eq "CODE")
906 8 0 ref $output eq 'HASH' ? :
907 2 6 if @$path > 1
913 3 8 if ($act eq "next")
914 3 0 if $errors
917 7 1 if ($act eq "use")
918 3 4 if $errors
921 1 0 if ($act eq "die")