Branch Coverage

blib/lib/SeaBASS/File.pm
Criterion Covered Total %
branch 467 586 79.6


line true false branch
519 4 134 if (ref $file eq 'HASH') { }
126 8 elsif (ref $_[0] eq 'HASH') { }
8 0 elsif (not ref $_[0]) { }
525 7 1 if ($#_ % 2 == 1) { }
537 0 133 if (ref $file eq 'GLOB') { }
127 6 elsif (ref $file eq 'SCALAR') { }
2 4 elsif ($file) { }
543 1 1 if (not ref $file) { }
544 1 0 if (-r $file) { }
0 0 elsif ($self->{'options'}{'strict'} & STRICT_READ()) { }
557 128 4 if ($file) { }
558 0 124 unless ($self->read_headers)
559 0 0 unless ($self->{'options'}{'strict'} & STRICT_READ())
594 259 138 if (ref $_[0] eq 'HASH') { }
137 1 elsif (ref $_[0] eq 'ARRAY') { }
1 0 elsif (not ref $_[0]) { }
601 11 2559 if ($_ =~ /^\s*!/) { }
2 2557 elsif ($strict and not $_ =~ m[^/]) { }
614 0 1 if ($_ =~ /^\s*!/) { }
0 1 elsif ($strict and not $_ =~ m[^/]) { }
668 21 4 if (not @_) { }
1 3 elsif (ref $_[0] eq 'HASH') { }
1 2 elsif (ref $_[0] eq 'ARRAY') { }
677 1 0 if (wantarray) { }
685 4 0 if (not ref $_) { }
687 4 0 defined $value ? :
692 1 1 if (wantarray) { }
0 1 elsif ($#ret == 0) { }
750 81 52 if (defined $index) { }
751 12 69 if ($index < 0)
755 63 6 if ($self->{'options'}{'cache'}) { }
756 39 24 if ($index > $self->{'max_dataidx'})
759 4 69 unless ($self->next)
767 0 59 if (wantarray) { }
773 3 3 if ($index <= $self->{'dataidx'})
778 0 7 unless ($self->next)
785 45 7 if ($self->{'options'}{'cache'}) { }
789 7 38 if (wantarray) { }
800 6 1 if (wantarray) { }
836 0 429 if (@_)
840 73 356 if ($self->{'options'}{'cache'} and $self->{'dataidx'} < $self->{'max_dataidx'}) { }
344 12 elsif ($self->{'handle'}) { }
843 0 73 if (wantarray) { }
855 266 0 if ($line)
858 204 62 if ($self->{'options'}{'cache'})
862 238 28 if ($self->{'dataidx'} > $self->{'max_dataidx'})
865 0 266 if (wantarray) { }
888 31 30 if ($self->{'dataidx'} != -1)
889 9 22 unless ($self->{'options'}{'cache'})
926 1 11 if (not $self->{'options'}{'cache'}) { }
1 10 elsif ($self->{'dataidx'} == -1) { }
932 2 8 unless (defined $new_row)
958 0 3 unless ($self->{'options'}{'cache'})
961 1 2 if ($index < 0)
965 0 2 unless (defined $new_row)
969 2 0 if ($index > $self->{'max_dataidx'})
974 1 1 if ($index > $self->{'max_dataidx'})
1016 0 16 unless ($self->{'options'}{'cache'})
1019 1 15 if ($index < INSERT_END())
1023 0 15 unless (defined $new_row)
1027 10 5 if ($index == INSERT_END()) { }
2 3 elsif ($index > $self->{'max_dataidx'}) { }
1036 0 2 if ($index == $self->{'max_dataidx'} + 1) { }
1 1 elsif ($index > $self->{'max_dataidx'}) { }
1043 3 11 if ($index <= $self->{'dataidx'} and $index != INSERT_END())
1049 2 12 if ($index == INSERT_BEGINNING()) { }
10 2 elsif ($index == INSERT_END()) { }
1090 1 5 if (not $self->{'options'}{'cache'}) { }
0 8 elsif (not defined $index and $self->{'dataidx'} < 0) { }
1096 2 3 unless (defined $index)
1100 0 5 if ($index < 0) { }
2 3 elsif ($index > $self->{'max_dataidx'}) { }
1107 1 1 if ($index > $self->{'max_dataidx'})
1112 3 1 if ($index <= $self->{'dataidx'})
1165 1 6 if (ref $function ne 'CODE')
1176 12 7 if (defined $ret and defined wantarray)
1179 2 17 unless (defined $row)
1180 1 1 if ($self->{'dataidx'} <= $currentidx)
1215 5 8 if (ref $_[$#_] eq 'HASH')
1218 0 13 unless (@_)
1222 3 10 $self->{'options'}{'missing_data_to_undef'} ? :
1230 4 17 if (&firstidx(sub { $_ eq $field; } , @{$$self{'actual_fields'};}) < 0)
1231 3 1 if (not $self->{'options'}{'fill_ancillary_data'} or &firstidx(sub { $_ eq $field; } , keys %{$$self{'ancillary'};}) < 0)
1240 20 20 if ($options{'delete_missing'})
1243 4 32 unless (defined $row->{$field} and !defined($missing) || $row->{$field} != $missing)
1248 4 16 unless ($has_all)
1260 3 7 if ($#_ == 0) { }
4 3 elsif (wantarray) { }
1261 1 2 if (wantarray) { }
1283 1 7 unless (@_)
1291 1 8 if ($field_idx < 0) { }
1315 0 25 if (not $self->{'options'}{'cache'}) { }
1 24 elsif (not $field) { }
1323 3 21 if ($field_idx >= 0)
1326 15 6 unless (defined $position)
1332 17 4 if ($position == INSERT_END()) { }
2 2 elsif ($position == INSERT_BEGINNING()) { }
1365 0 10 if ($#_ < 0)
1373 13 0 if (defined $find)
1374 7 6 if (not ref $find) { }
6 0 elsif (ref $find eq 'Regexp') { }
1383 23 69 if ($field =~ /$regex/)
1391 7 3 if ($#_ == 0) { }
1394 2 1 if (wantarray) { }
1414 1 2 if ($c =~ /^!/) { }
1432 2 4 if (@_) { }
1437 0 6 if (wantarray) { }
1457 1 1 if ($c =~ /^!/) { }
1485 1 14 $self->{'options'}{'keep_slashes'} ? :
1488 3 12 if ($strict_write)
1491 0 65 if (&firstidx(sub { $_ eq $header_no_slash; } , @ALL_HEADERS) < 0 and &firstidx(sub { $_ eq $header_no_slash; } , @HIDDEN_HEADERS) < 0)
1498 20 46 unless (exists $self->{'headers'}{$header})
1505 14 1 if (not $error) { }
1509 0 14 if (not $write_to_h and exists $self->{'default_write_to'})
1513 0 14 if (defined $write_to_h)
1514 0 0 if (ref $write_to_h eq 'GLOB') { }
0 0 elsif (not ref $write_to_h) { }
1519 0 0 unless open $write_to_h, '>', $write_to
1529 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') { }
1542 14 0 exists $self->{'missing'} ? :
1543 14 0 exists $self->{'below_detection_limit'} ? :
1544 14 0 exists $self->{'above_detection_limit'} ? :
1546 1 13 if ($self->{'options'}{'preserve_header'}) { }
1549 3 10 unless (exists $self->{'headers'}{"${slash}begin_header"})
1554 1 12 if ($add_missing_headers and $add_missing_headers eq '1')
1557 1 12 unless ($self->{'options'}{'preserve_case'})
1564 12 1 if ($missing eq $adl or $self->{'options'}{'missing_data_to_undef'} and not $self->{'options'}{'preserve_detection_limits'})
1567 12 1 if ($missing eq $bdl or $self->{'options'}{'missing_data_to_undef'} and not $self->{'options'}{'preserve_detection_limits'})
1571 6 7 unless (grep(($_ ne 'unitless'), @{$$self{'actual_units'};}))
1576 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) { }
1579 0 152 if (&firstidx(sub { $_ eq $header_no_slash; } , @ALL_HEADERS) < 0)
1587 1 12 if (not @{$self->{'comments'};} and $add_missing_headers)
1590 3 10 if (not exists $self->{'headers'}{"$slash$header"}) { }
1600 20 90 if ($header =~ /_header/) { }
65 25 elsif (length $self->{'headers'}{"$slash$header"}) { }
25 0 elsif ($add_missing_headers) { }
1604 8 57 if ($header =~ /_latitude|_longitude/) { }
4 53 elsif ($header =~ /_time/) { }
1613 4 21 if ($header =~ /_latitude|_longitude/) { }
2 19 elsif ($header =~ /_time/) { }
1622 0 0 if ($header =~ /_latitude|_longitude/) { }
0 0 elsif ($header =~ /_time/) { }
1632 3 10 unless (exists $self->{'headers'}{"${slash}end_header"})
1642 102 16 defined $row->{$field} ? :
1648 0 14 if ($close_write_to)
1667 128 10 if ($self->{'handle'}) { }
1700 0 31 unless ($self->{'delim'} or $self->guess_delim($line))
1707 0 266 if ($num_expected != $num_got)
1715 958 911 if ($self->{'options'}{'missing_data_to_undef'}) { }
1716 68 890 if ($self->{'missing_is_number'} and &looks_like_number($v) and $v == $self->{'missing'}) { }
1 889 elsif (not $self->{'options'}{'preserve_detection_limits'} and $self->{'adl_is_number'} and &looks_like_number($v) and $v == $self->{'above_detection_limit'}) { }
1 888 elsif (not $self->{'options'}{'preserve_detection_limits'} and $self->{'bdl_is_number'} and &looks_like_number($v) and $v == $self->{'below_detection_limit'}) { }
8 880 elsif ($v eq $self->{'missing'} or not $self->{'options'}{'preserve_detection_limits'} and $v eq $self->{'below_detection_limit'} || $v eq $self->{'above_detection_limit'}) { }
1732 0 266 if (wantarray) { }
1791 0 130 unless (ref $self)
1796 130 0 if ($name)
1799 1 129 unless (defined $value)
1802 125 4 if (ref $value eq 'ARRAY' and wantarray) { }
0 8 elsif (ref $value eq 'HASH' and wantarray) { }
1833 2 1750 if (not exists $DEFAULT_OPTIONS{$k}) { }
2 1748 elsif (&firstidx(sub { $_ eq ref $v; } , @{$OPTION_TYPES{$k};}) < 0) { }
1837 1 1 $expected_ref ? :
1840 1 132 if ($self->{'options'}{'add_empty_headers'})
1883 1 3 $self->{'options'}{'keep_slashes'} ? :
1884 1 3 if ($self->{'options'}{'add_empty_headers'})
1886 33 0 unless (exists $self->{'headers'}{"$slash$_"})
1888 1 32 if ($_ eq 'missing')
1896 4 0 if ($self->{'options'}{'default_headers'})
1899 4 0 if ($self->{'options'}{'headers'})
1902 0 4 unless ($success)
1919 0 128 if ($self->{'headers'})
1923 7 121 $self->{'options'}{'keep_slashes'} ? :
1930 128 0 if ($self->{'options'}{'default_headers'})
1943 3263 0 if ($line)
1944 113 3150 if ($line =~ m[^(/end_header)\@?$]i) { }
2439 711 elsif ($line =~ m[^/]) { }
696 15 elsif ($line =~ /^!/) { }
1952 10 686 if ($self->{'options'}{'preserve_header'})
1957 0 15 if ($strict & STRICT_READ())
1967 5 123 if ($strict & STRICT_READ()) { }
1973 1 127 if ($self->{'options'}{'preserve_header'})
1982 128 0 if ($self->{'options'}{'headers'})
1988 127 1 if ($self->{'options'}{'preserve_comments'})
1993 1 127 if ($self->{'options'}{'delete_missing_headers'})
1995 3 28 if ($k =~ m[/?(?:end|begin)_header$|^/?missing$])
1998 7 21 if (not defined $v or $v =~ m(^n/?a(?:\[.*?\])?$)i or lc $v eq lc $missing)
2004 5 123 if ($strict & STRICT_READ())
2006 58 52 unless (exists $headers{"$slash$_"})
2012 0 72 if ($slash)
2015 0 72 if (&firstidx(sub { $_ eq $header; } , @ALL_HEADERS) < 0 and &firstidx(sub { $_ eq $header; } , @HIDDEN_HEADERS) < 0)
2020 0 5 if ($headers{"${slash}begin_header"} or $headers{"${slash}end_header"})
2026 1 127 unless (exists $headers{"$slash$_"})
2028 1 0 if ($strict & STRICT_READ())
2037 79 49 if ($headers{"${slash}units"}) { }
2051 1 127 if (@{$self->{'fields'};} != @{$self->{'units'};})
2052 1 0 if ($strict & STRICT_READ()) { }
2065 4 124 unless ($success)
2066 4 0 if ($strict & STRICT_READ()) { }
2080 114 10 if ($self->{'options'}{'cache'})
2088 16 108 if ($self->{'options'}{'fill_ancillary_data'})
2102 77 66 if ($idx >= 0)
2106 29 114 if (ref $value) { }
2126 145 6 if ($idx >= 0)
2135 0 143 if ($field ne $new_field)
2173 201 2365 if (not defined $v) { }
2183 0 2566 if (length $v == 0 and not $k =~ /_header/)
2184 0 0 if ($strict) { }
2192 1308 1258 if (not $self->{'options'}{'preserve_case'} or $k =~ /fields|units/)
2196 139 2427 if ($self->{'options'}{'keep_slashes'}) { }
2197 2 137 if ($k =~ m[^[^/]])
2201 0 6 if ($strict and &firstidx(sub { "/$_" eq $k; } , @ALL_HEADERS) < 0 and &firstidx(sub { "/$_" eq $k; } , @HIDDEN_HEADERS) < 0)
2206 2425 2 if ($k =~ m[^/])
2210 0 80 if ($strict and &firstidx(sub { $_ eq $k; } , @ALL_HEADERS) < 0 and &firstidx(sub { $_ eq $k; } , @HIDDEN_HEADERS) < 0)
2216 308 2258 if ($k =~ /_latitude|_longitude/) { }
158 2100 elsif ($k =~ /_time/) { }
90 2010 elsif ($k =~ m[^/?delimiter$]) { }
111 1899 elsif ($k =~ m[^/?missing$]) { }
4 1895 elsif ($k =~ m[^/?above_detection_limit]) { }
4 1891 elsif ($k =~ m[^/?below_detection_limit]) { }
2221 1 89 unless ($self->set_delim($strict, $v))
2222 0 1 if ($strict)
2227 111 0 length $v ? :
2230 4 0 length $v ? :
2233 4 0 length $v ? :
2254 0 90 if ($delim eq 'comma') { }
0 90 elsif ($delim eq 'semicolon') { }
88 2 elsif ($delim eq 'space') { }
0 2 elsif ($delim eq 'tab') { }
1 1 elsif ($strict) { }
2265 0 1 $self->{'options'}{'keep_slashes'} ? :
2270 89 1 $delim ? :
2283 4 24 if ($self->{'options'}{'cache'} and $self->{'max_dataidx'} >= 0)
2289 2 26 $self->{'options'}{'keep_slashes'} ? :
2311 21 1895 if (&firstidx(sub { $_ eq $field; } , @{$$self{'actual_fields'};}) < 0)
2312 21 0 unless ($self->{'options'}{'fill_ancillary_data'} and &firstidx(sub { $_ eq $field; } , keys %{$$self{'ancillary'};}) >= 0)
2318 140 137 $self->{'options'}{'missing_data_to_undef'} ? :
2321 57 0 if (defined $hash->{$case_var} and !defined($missing) || $hash->{$case_var} != $missing)
2326 19 258 if (defined $self->{'ancillary'})
2329 173 74 if (defined $self->{'ancillary'}{$variable})
2331 173 0 if (defined $value)
2339 61 1911 unless (exists $hash->{$field})
2359 2 33 if ($line =~ /,/) { }
0 33 elsif ($line =~ /\t/) { }
33 0 elsif ($line =~ /\s+/) { }
0 0 elsif ($line =~ /;/) { }
2379 1 34 $self->{'options'}{'keep_slashes'} ? :
2406 1 26 if ($#_ < 0)
2411 14 12 if (ref $_[0] eq 'HASH') { }
3 9 elsif (ref $_[0] eq 'ARRAY') { }
9 0 elsif (not ref $_[0]) { }
2416 7 2 if ($#_ == 0) { }
1 1 elsif ($#_ % 2 == 1) { }
2417 0 4 unless ($self->{'delim'} or $self->guess_delim($_[0]))
2432 10 15 if ($arrayref)
2434 8 2 if (scalar @{$self->{'actual_fields'};} == scalar @{$arrayref;}) { }
2 0 elsif (scalar @{$self->{'fields'};} == scalar @{$arrayref;}) { }
2442 0 0 if ($actual_fields == $fields) { }
2456 0 25 if (wantarray) { }
2494 99 307 if ($self->{'ancillary'}{$field})
2498 77 230 if ($idx >= 0)
2503 0 230 $self->{'options'}{'keep_slashes'} ? :
2504 12 218 unless $ANCILLARY{$field}
2505 284 132 if (ref $attempt eq 'HASH') { }
89 43 elsif (ref $attempt eq 'ARRAY') { }
43 0 elsif (not ref $attempt) { }
2508 122 162 if ($where =~ /^\$/) { }
12 150 elsif (defined $self->{'headers'}{"$slash$where"} and $self->{'headers'}{"$slash$where"} =~ /$regex/ and lc $1 ne 'na') { }
2509 15 107 if (&firstidx(sub { "\$$_" eq $where; } , $self->fields) >= 0)
2522 41 48 if (ref $attempt[0] eq 'Regexp')
2532 40 75 if ($success) { }
2533 0 40 if (ref $self->{'ancillary'}{$variable}) { }
2546 14 75 if ($success)
2547 8 6 if ($regex)
2559 65 18 if ($success) { }
2560 6 59 if (ref $self->{'ancillary'}{$variable}) { }
2571 25 18 if ($success)
2596 47 173 if (ref $expression) { }
2603 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}) { }
2610 0 0 unless (defined $value)
2639 41 6 if (ref $args[0] eq 'Regexp')
2644 0 47 unless (defined $_)
2649 41 6 if ($regex)
2650 41 0 if ($value =~ /$regex/)
2696 14 0 if ($yyyyjjj =~ /^(\d{4})(\d{3})$/)