Branch Coverage

blib/lib/SeaBASS/File.pm
Criterion Covered Total %
branch 469 586 80.0


line true false branch
508 4 133 if (ref $file eq 'HASH') { }
125 8 elsif (ref $_[0] eq 'HASH') { }
8 0 elsif (not ref $_[0]) { }
514 7 1 if ($#_ % 2 == 1) { }
526 0 132 if (ref $file eq 'GLOB') { }
126 6 elsif (ref $file eq 'SCALAR') { }
2 4 elsif ($file) { }
532 1 1 if (not ref $file) { }
533 1 0 if (-r $file) { }
0 0 elsif ($self->{'options'}{'strict'} & STRICT_READ()) { }
546 127 4 if ($file) { }
547 0 123 unless ($self->read_headers)
548 0 0 unless ($self->{'options'}{'strict'} & STRICT_READ())
583 257 137 if (ref $_[0] eq 'HASH') { }
136 1 elsif (ref $_[0] eq 'ARRAY') { }
1 0 elsif (not ref $_[0]) { }
590 11 2552 if ($_ =~ /^\s*!/) { }
2 2550 elsif ($strict and not $_ =~ m[^/]) { }
603 0 1 if ($_ =~ /^\s*!/) { }
0 1 elsif ($strict and not $_ =~ m[^/]) { }
657 21 4 if (not @_) { }
1 3 elsif (ref $_[0] eq 'HASH') { }
1 2 elsif (ref $_[0] eq 'ARRAY') { }
666 1 0 if (wantarray) { }
674 4 0 if (not ref $_) { }
676 4 0 defined $value ? :
681 1 1 if (wantarray) { }
0 1 elsif ($#ret == 0) { }
739 78 52 if (defined $index) { }
740 12 66 if ($index < 0)
744 60 6 if ($self->{'options'}{'cache'}) { }
745 36 24 if ($index > $self->{'max_dataidx'})
748 4 66 unless ($self->next)
756 0 56 if (wantarray) { }
762 3 3 if ($index <= $self->{'dataidx'})
767 0 7 unless ($self->next)
774 45 7 if ($self->{'options'}{'cache'}) { }
778 7 38 if (wantarray) { }
789 6 1 if (wantarray) { }
825 0 426 if (@_)
829 73 353 if ($self->{'options'}{'cache'} and $self->{'dataidx'} < $self->{'max_dataidx'}) { }
341 12 elsif ($self->{'handle'}) { }
832 0 73 if (wantarray) { }
844 263 0 if ($line)
847 201 62 if ($self->{'options'}{'cache'})
851 235 28 if ($self->{'dataidx'} > $self->{'max_dataidx'})
854 0 263 if (wantarray) { }
877 31 30 if ($self->{'dataidx'} != -1)
878 9 22 unless ($self->{'options'}{'cache'})
915 1 11 if (not $self->{'options'}{'cache'}) { }
1 10 elsif ($self->{'dataidx'} == -1) { }
921 2 8 unless (defined $new_row)
947 0 3 unless ($self->{'options'}{'cache'})
950 1 2 if ($index < 0)
954 0 2 unless (defined $new_row)
958 2 0 if ($index > $self->{'max_dataidx'})
963 1 1 if ($index > $self->{'max_dataidx'})
1005 0 16 unless ($self->{'options'}{'cache'})
1008 1 15 if ($index < INSERT_END())
1012 0 15 unless (defined $new_row)
1016 10 5 if ($index == INSERT_END()) { }
2 3 elsif ($index > $self->{'max_dataidx'}) { }
1025 0 2 if ($index == $self->{'max_dataidx'} + 1) { }
1 1 elsif ($index > $self->{'max_dataidx'}) { }
1032 3 11 if ($index <= $self->{'dataidx'} and $index != INSERT_END())
1038 2 12 if ($index == INSERT_BEGINNING()) { }
10 2 elsif ($index == INSERT_END()) { }
1079 1 5 if (not $self->{'options'}{'cache'}) { }
0 8 elsif (not defined $index and $self->{'dataidx'} < 0) { }
1085 2 3 unless (defined $index)
1089 0 5 if ($index < 0) { }
2 3 elsif ($index > $self->{'max_dataidx'}) { }
1096 1 1 if ($index > $self->{'max_dataidx'})
1101 3 1 if ($index <= $self->{'dataidx'})
1154 1 6 if (ref $function ne 'CODE')
1165 12 7 if (defined $ret and defined wantarray)
1168 2 17 unless (defined $row)
1169 1 1 if ($self->{'dataidx'} <= $currentidx)
1204 5 8 if (ref $_[$#_] eq 'HASH')
1207 0 13 unless (@_)
1211 3 10 $self->{'options'}{'missing_data_to_undef'} ? :
1219 4 17 if (&firstidx(sub { $_ eq $field; } , @{$$self{'actual_fields'};}) < 0)
1220 3 1 if (not $self->{'options'}{'fill_ancillary_data'} or &firstidx(sub { $_ eq $field; } , keys %{$$self{'ancillary'};}) < 0)
1229 20 20 if ($options{'delete_missing'})
1232 4 32 unless (defined $row->{$field} and !defined($missing) || $row->{$field} != $missing)
1237 4 16 unless ($has_all)
1249 3 7 if ($#_ == 0) { }
4 3 elsif (wantarray) { }
1250 1 2 if (wantarray) { }
1272 1 7 unless (@_)
1280 1 8 if ($field_idx < 0) { }
1304 0 25 if (not $self->{'options'}{'cache'}) { }
1 24 elsif (not $field) { }
1312 3 21 if ($field_idx >= 0)
1315 15 6 unless (defined $position)
1321 17 4 if ($position == INSERT_END()) { }
2 2 elsif ($position == INSERT_BEGINNING()) { }
1354 0 10 if ($#_ < 0)
1362 13 0 if (defined $find)
1363 7 6 if (not ref $find) { }
6 0 elsif (ref $find eq 'Regexp') { }
1372 23 69 if ($field =~ /$regex/)
1380 7 3 if ($#_ == 0) { }
1383 2 1 if (wantarray) { }
1403 1 2 if ($c =~ /^!/) { }
1421 2 4 if (@_) { }
1426 0 6 if (wantarray) { }
1446 1 1 if ($c =~ /^!/) { }
1474 1 14 $self->{'options'}{'keep_slashes'} ? :
1477 3 12 if ($strict_write)
1480 0 65 if (&firstidx(sub { $_ eq $header_no_slash; } , @ALL_HEADERS) < 0 and &firstidx(sub { $_ eq $header_no_slash; } , @HIDDEN_HEADERS) < 0)
1487 20 46 unless (exists $self->{'headers'}{$header})
1494 14 1 if (not $error) { }
1498 0 14 if (not $write_to_h and exists $self->{'default_write_to'})
1502 0 14 if (defined $write_to_h)
1503 0 0 if (ref $write_to_h eq 'GLOB') { }
0 0 elsif (not ref $write_to_h) { }
1508 0 0 unless open $write_to_h, '>', $write_to
1518 2 12 if ($actual_delim eq 'comma') { }
12 0 elsif ($actual_delim eq 'space') { }
0 0 elsif ($actual_delim eq 'tab') { }
0 0 elsif ($actual_delim eq 'semicolon') { }
1531 14 0 exists $self->{'missing'} ? :
1532 10 4 exists $self->{'below_detection_limit'} ? :
1533 10 4 exists $self->{'above_detection_limit'} ? :
1535 1 13 if ($self->{'options'}{'preserve_header'}) { }
1538 3 10 unless (exists $self->{'headers'}{"${slash}begin_header"})
1543 1 12 if ($add_missing_headers and $add_missing_headers eq '1')
1546 1 12 unless ($self->{'options'}{'preserve_case'})
1553 12 1 if ($missing eq $adl or $self->{'options'}{'missing_data_to_undef'})
1556 12 1 if ($missing eq $bdl or $self->{'options'}{'missing_data_to_undef'})
1560 6 7 unless (grep(($_ ne 'unitless'), @{$$self{'actual_units'};}))
1565 13 386 if ($header eq 'missing') { }
13 373 elsif ($header eq 'fields') { }
7 366 elsif ($header eq 'units') { }
110 256 elsif (exists $self->{'headers'}{"$slash$header"}) { }
0 256 elsif ($add_missing_headers) { }
1568 0 152 if (&firstidx(sub { $_ eq $header_no_slash; } , @ALL_HEADERS) < 0)
1576 1 12 if (not @{$self->{'comments'};} and $add_missing_headers)
1579 3 10 if (not exists $self->{'headers'}{"$slash$header"}) { }
1589 20 90 if ($header =~ /_header/) { }
65 25 elsif (length $self->{'headers'}{"$slash$header"}) { }
25 0 elsif ($add_missing_headers) { }
1593 8 57 if ($header =~ /_latitude|_longitude/) { }
4 53 elsif ($header =~ /_time/) { }
1602 4 21 if ($header =~ /_latitude|_longitude/) { }
2 19 elsif ($header =~ /_time/) { }
1611 0 0 if ($header =~ /_latitude|_longitude/) { }
0 0 elsif ($header =~ /_time/) { }
1621 3 10 unless (exists $self->{'headers'}{"${slash}end_header"})
1631 102 16 defined $row->{$field} ? :
1637 0 14 if ($close_write_to)
1656 127 10 if ($self->{'handle'}) { }
1689 0 31 unless ($self->{'delim'} or $self->guess_delim($line))
1696 0 263 if ($num_expected != $num_got)
1704 937 911 if ($self->{'options'}{'missing_data_to_undef'}) { }
1705 67 870 if ($self->{'missing_is_number'} and &looks_like_number($v) and $v == $self->{'missing'}) { }
1 869 elsif ($self->{'adl_is_number'} and &looks_like_number($v) and $v == $self->{'above_detection_limit'}) { }
1 868 elsif ($self->{'bdl_is_number'} and &looks_like_number($v) and $v == $self->{'below_detection_limit'}) { }
8 860 elsif ($v eq $self->{'missing'} or $v eq $self->{'below_detection_limit'} or $v eq $self->{'above_detection_limit'}) { }
1721 0 263 if (wantarray) { }
1780 0 109 unless (ref $self)
1785 109 0 if ($name)
1788 1 108 unless (defined $value)
1791 104 4 if (ref $value eq 'ARRAY' and wantarray) { }
0 8 elsif (ref $value eq 'HASH' and wantarray) { }
1822 2 1610 if (not exists $DEFAULT_OPTIONS{$k}) { }
2 1608 elsif (&firstidx(sub { $_ eq ref $v; } , @{$OPTION_TYPES{$k};}) < 0) { }
1826 1 1 $expected_ref ? :
1829 1 131 if ($self->{'options'}{'add_empty_headers'})
1870 1 3 $self->{'options'}{'keep_slashes'} ? :
1871 1 3 if ($self->{'options'}{'add_empty_headers'})
1873 33 0 unless (exists $self->{'headers'}{"$slash$_"})
1875 1 32 if ($_ eq 'missing')
1883 4 0 if ($self->{'options'}{'default_headers'})
1886 4 0 if ($self->{'options'}{'headers'})
1889 0 4 unless ($success)
1906 0 127 if ($self->{'headers'})
1910 7 120 $self->{'options'}{'keep_slashes'} ? :
1917 127 0 if ($self->{'options'}{'default_headers'})
1930 3256 0 if ($line)
1931 112 3144 if ($line =~ m[^(/end_header)\@?$]i) { }
2433 711 elsif ($line =~ m[^/]) { }
696 15 elsif ($line =~ /^!/) { }
1939 10 686 if ($self->{'options'}{'preserve_header'})
1944 0 15 if ($strict & STRICT_READ())
1954 5 122 if ($strict & STRICT_READ()) { }
1960 1 126 if ($self->{'options'}{'preserve_header'})
1969 127 0 if ($self->{'options'}{'headers'})
1975 126 1 if ($self->{'options'}{'preserve_comments'})
1980 1 126 if ($self->{'options'}{'delete_missing_headers'})
1982 3 28 if ($k =~ m[/?(?:end|begin)_header$|^/?missing$])
1985 7 21 if (not defined $v or $v =~ m(^n/?a(?:\[.*?\])?$)i or lc $v eq lc $missing)
1991 5 122 if ($strict & STRICT_READ())
1993 58 52 unless (exists $headers{"$slash$_"})
1999 0 72 if ($slash)
2002 0 72 if (&firstidx(sub { $_ eq $header; } , @ALL_HEADERS) < 0 and &firstidx(sub { $_ eq $header; } , @HIDDEN_HEADERS) < 0)
2007 0 5 if ($headers{"${slash}begin_header"} or $headers{"${slash}end_header"})
2013 1 126 unless (exists $headers{"$slash$_"})
2015 1 0 if ($strict & STRICT_READ())
2024 79 48 if ($headers{"${slash}units"}) { }
2038 1 126 if (@{$self->{'fields'};} != @{$self->{'units'};})
2039 1 0 if ($strict & STRICT_READ()) { }
2052 4 123 unless ($success)
2053 4 0 if ($strict & STRICT_READ()) { }
2067 113 10 if ($self->{'options'}{'cache'})
2075 16 107 if ($self->{'options'}{'fill_ancillary_data'})
2089 77 66 if ($idx >= 0)
2093 29 114 if (ref $value) { }
2113 145 6 if ($idx >= 0)
2122 0 143 if ($field ne $new_field)
2160 199 2360 if (not defined $v) { }
2170 0 2559 if (length $v == 0 and not $k =~ /_header/)
2171 0 0 if ($strict) { }
2179 1307 1252 if (not $self->{'options'}{'preserve_case'} or $k =~ /fields|units/)
2183 139 2420 if ($self->{'options'}{'keep_slashes'}) { }
2184 2 137 if ($k =~ m[^[^/]])
2188 0 6 if ($strict and &firstidx(sub { "/$_" eq $k; } , @ALL_HEADERS) < 0 and &firstidx(sub { "/$_" eq $k; } , @HIDDEN_HEADERS) < 0)
2193 2418 2 if ($k =~ m[^/])
2197 0 80 if ($strict and &firstidx(sub { $_ eq $k; } , @ALL_HEADERS) < 0 and &firstidx(sub { $_ eq $k; } , @HIDDEN_HEADERS) < 0)
2203 308 2251 if ($k =~ /_latitude|_longitude/) { }
158 2093 elsif ($k =~ /_time/) { }
89 2004 elsif ($k =~ m[^/?delimiter$]) { }
110 1894 elsif ($k =~ m[^/?missing$]) { }
3 1891 elsif ($k =~ m[^/?above_detection_limit]) { }
3 1888 elsif ($k =~ m[^/?below_detection_limit]) { }
2208 1 88 unless ($self->set_delim($strict, $v))
2209 0 1 if ($strict)
2214 110 0 length $v ? :
2217 3 0 length $v ? :
2220 3 0 length $v ? :
2241 0 89 if ($delim eq 'comma') { }
0 89 elsif ($delim eq 'semicolon') { }
87 2 elsif ($delim eq 'space') { }
0 2 elsif ($delim eq 'tab') { }
1 1 elsif ($strict) { }
2252 0 1 $self->{'options'}{'keep_slashes'} ? :
2257 88 1 $delim ? :
2270 4 24 if ($self->{'options'}{'cache'} and $self->{'max_dataidx'} >= 0)
2276 2 26 $self->{'options'}{'keep_slashes'} ? :
2298 21 1874 if (&firstidx(sub { $_ eq $field; } , @{$$self{'actual_fields'};}) < 0)
2299 21 0 unless ($self->{'options'}{'fill_ancillary_data'} and &firstidx(sub { $_ eq $field; } , keys %{$$self{'ancillary'};}) >= 0)
2305 137 137 $self->{'options'}{'missing_data_to_undef'} ? :
2308 57 0 if (defined $hash->{$case_var} and !defined($missing) || $hash->{$case_var} != $missing)
2313 19 255 if (defined $self->{'ancillary'})
2316 173 74 if (defined $self->{'ancillary'}{$variable})
2318 173 0 if (defined $value)
2326 61 1890 unless (exists $hash->{$field})
2346 2 33 if ($line =~ /,/) { }
0 33 elsif ($line =~ /\t/) { }
33 0 elsif ($line =~ /\s+/) { }
0 0 elsif ($line =~ /;/) { }
2366 1 34 $self->{'options'}{'keep_slashes'} ? :
2393 1 26 if ($#_ < 0)
2398 14 12 if (ref $_[0] eq 'HASH') { }
3 9 elsif (ref $_[0] eq 'ARRAY') { }
9 0 elsif (not ref $_[0]) { }
2403 7 2 if ($#_ == 0) { }
1 1 elsif ($#_ % 2 == 1) { }
2404 0 4 unless ($self->{'delim'} or $self->guess_delim($_[0]))
2419 10 15 if ($arrayref)
2421 8 2 if (scalar @{$self->{'actual_fields'};} == scalar @{$arrayref;}) { }
2 0 elsif (scalar @{$self->{'fields'};} == scalar @{$arrayref;}) { }
2429 0 0 if ($actual_fields == $fields) { }
2443 0 25 if (wantarray) { }
2481 95 282 if ($self->{'ancillary'}{$field})
2485 77 205 if ($idx >= 0)
2490 0 205 $self->{'options'}{'keep_slashes'} ? :
2491 8 197 unless $ANCILLARY{$field}
2492 242 107 if (ref $attempt eq 'HASH') { }
64 43 elsif (ref $attempt eq 'ARRAY') { }
43 0 elsif (not ref $attempt) { }
2495 101 141 if ($where =~ /^\$/) { }
12 129 elsif (defined $self->{'headers'}{"$slash$where"} and $self->{'headers'}{"$slash$where"} =~ /$regex/ and lc $1 ne 'na') { }
2496 15 86 if (&firstidx(sub { "\$$_" eq $where; } , $self->fields) >= 0)
2509 30 34 if (ref $attempt[0] eq 'Regexp')
2519 36 50 if ($success) { }
2520 0 36 if (ref $self->{'ancillary'}{$variable}) { }
2533 14 50 if ($success)
2534 8 6 if ($regex)
2546 65 18 if ($success) { }
2547 6 59 if (ref $self->{'ancillary'}{$variable}) { }
2558 25 18 if ($success)
2583 47 173 if (ref $expression) { }
2590 123 98 if ($self->{'ancillary_tmp'}{$variable}) { }
98 0 elsif (defined $row->{$variable} and !defined($missing) || $row->{$variable} != $missing) { }
0 0 elsif (ref $self->{'ancillary'}{$variable}) { }
2597 0 0 unless (defined $value)
2626 41 6 if (ref $args[0] eq 'Regexp')
2631 0 47 unless (defined $_)
2636 41 6 if ($regex)
2637 41 0 if ($value =~ /$regex/)
2683 14 0 if ($yyyyjjj =~ /^(\d{4})(\d{3})$/)