Branch Coverage

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


line true false branch
518 4 134 if (ref $file eq 'HASH') { }
126 8 elsif (ref $_[0] eq 'HASH') { }
8 0 elsif (not ref $_[0]) { }
524 7 1 if ($#_ % 2 == 1) { }
536 0 133 if (ref $file eq 'GLOB') { }
127 6 elsif (ref $file eq 'SCALAR') { }
2 4 elsif ($file) { }
542 1 1 if (not ref $file) { }
543 1 0 if (-r $file) { }
0 0 elsif ($self->{'options'}{'strict'} & STRICT_READ()) { }
556 128 4 if ($file) { }
557 0 124 unless ($self->read_headers)
558 0 0 unless ($self->{'options'}{'strict'} & STRICT_READ())
593 259 138 if (ref $_[0] eq 'HASH') { }
137 1 elsif (ref $_[0] eq 'ARRAY') { }
1 0 elsif (not ref $_[0]) { }
600 11 2559 if ($_ =~ /^\s*!/) { }
2 2557 elsif ($strict and not $_ =~ m[^/]) { }
613 0 1 if ($_ =~ /^\s*!/) { }
0 1 elsif ($strict and not $_ =~ m[^/]) { }
667 21 4 if (not @_) { }
1 3 elsif (ref $_[0] eq 'HASH') { }
1 2 elsif (ref $_[0] eq 'ARRAY') { }
676 1 0 if (wantarray) { }
684 4 0 if (not ref $_) { }
686 4 0 defined $value ? :
691 1 1 if (wantarray) { }
0 1 elsif ($#ret == 0) { }
749 81 52 if (defined $index) { }
750 12 69 if ($index < 0)
754 63 6 if ($self->{'options'}{'cache'}) { }
755 39 24 if ($index > $self->{'max_dataidx'})
758 4 69 unless ($self->next)
766 0 59 if (wantarray) { }
772 3 3 if ($index <= $self->{'dataidx'})
777 0 7 unless ($self->next)
784 45 7 if ($self->{'options'}{'cache'}) { }
788 7 38 if (wantarray) { }
799 6 1 if (wantarray) { }
835 0 429 if (@_)
839 73 356 if ($self->{'options'}{'cache'} and $self->{'dataidx'} < $self->{'max_dataidx'}) { }
344 12 elsif ($self->{'handle'}) { }
842 0 73 if (wantarray) { }
854 266 0 if ($line)
857 204 62 if ($self->{'options'}{'cache'})
861 238 28 if ($self->{'dataidx'} > $self->{'max_dataidx'})
864 0 266 if (wantarray) { }
887 31 30 if ($self->{'dataidx'} != -1)
888 9 22 unless ($self->{'options'}{'cache'})
925 1 11 if (not $self->{'options'}{'cache'}) { }
1 10 elsif ($self->{'dataidx'} == -1) { }
931 2 8 unless (defined $new_row)
957 0 3 unless ($self->{'options'}{'cache'})
960 1 2 if ($index < 0)
964 0 2 unless (defined $new_row)
968 2 0 if ($index > $self->{'max_dataidx'})
973 1 1 if ($index > $self->{'max_dataidx'})
1015 0 16 unless ($self->{'options'}{'cache'})
1018 1 15 if ($index < INSERT_END())
1022 0 15 unless (defined $new_row)
1026 10 5 if ($index == INSERT_END()) { }
2 3 elsif ($index > $self->{'max_dataidx'}) { }
1035 0 2 if ($index == $self->{'max_dataidx'} + 1) { }
1 1 elsif ($index > $self->{'max_dataidx'}) { }
1042 3 11 if ($index <= $self->{'dataidx'} and $index != INSERT_END())
1048 2 12 if ($index == INSERT_BEGINNING()) { }
10 2 elsif ($index == INSERT_END()) { }
1089 1 5 if (not $self->{'options'}{'cache'}) { }
0 8 elsif (not defined $index and $self->{'dataidx'} < 0) { }
1095 2 3 unless (defined $index)
1099 0 5 if ($index < 0) { }
2 3 elsif ($index > $self->{'max_dataidx'}) { }
1106 1 1 if ($index > $self->{'max_dataidx'})
1111 3 1 if ($index <= $self->{'dataidx'})
1164 1 6 if (ref $function ne 'CODE')
1175 12 7 if (defined $ret and defined wantarray)
1178 2 17 unless (defined $row)
1179 1 1 if ($self->{'dataidx'} <= $currentidx)
1214 5 8 if (ref $_[$#_] eq 'HASH')
1217 0 13 unless (@_)
1221 3 10 $self->{'options'}{'missing_data_to_undef'} ? :
1229 4 17 if (&firstidx(sub { $_ eq $field; } , @{$$self{'actual_fields'};}) < 0)
1230 3 1 if (not $self->{'options'}{'fill_ancillary_data'} or &firstidx(sub { $_ eq $field; } , keys %{$$self{'ancillary'};}) < 0)
1239 20 20 if ($options{'delete_missing'})
1242 4 32 unless (defined $row->{$field} and !defined($missing) || $row->{$field} != $missing)
1247 4 16 unless ($has_all)
1259 3 7 if ($#_ == 0) { }
4 3 elsif (wantarray) { }
1260 1 2 if (wantarray) { }
1282 1 7 unless (@_)
1290 1 8 if ($field_idx < 0) { }
1314 0 25 if (not $self->{'options'}{'cache'}) { }
1 24 elsif (not $field) { }
1322 3 21 if ($field_idx >= 0)
1325 15 6 unless (defined $position)
1331 17 4 if ($position == INSERT_END()) { }
2 2 elsif ($position == INSERT_BEGINNING()) { }
1364 0 10 if ($#_ < 0)
1372 13 0 if (defined $find)
1373 7 6 if (not ref $find) { }
6 0 elsif (ref $find eq 'Regexp') { }
1382 23 69 if ($field =~ /$regex/)
1390 7 3 if ($#_ == 0) { }
1393 2 1 if (wantarray) { }
1413 1 2 if ($c =~ /^!/) { }
1431 2 4 if (@_) { }
1436 0 6 if (wantarray) { }
1456 1 1 if ($c =~ /^!/) { }
1484 1 14 $self->{'options'}{'keep_slashes'} ? :
1487 3 12 if ($strict_write)
1490 0 65 if (&firstidx(sub { $_ eq $header_no_slash; } , @ALL_HEADERS) < 0 and &firstidx(sub { $_ eq $header_no_slash; } , @HIDDEN_HEADERS) < 0)
1497 20 46 unless (exists $self->{'headers'}{$header})
1504 14 1 if (not $error) { }
1508 0 14 if (not $write_to_h and exists $self->{'default_write_to'})
1512 0 14 if (defined $write_to_h)
1513 0 0 if (ref $write_to_h eq 'GLOB') { }
0 0 elsif (not ref $write_to_h) { }
1518 0 0 unless open $write_to_h, '>', $write_to
1528 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') { }
1541 14 0 exists $self->{'missing'} ? :
1542 14 0 exists $self->{'below_detection_limit'} ? :
1543 14 0 exists $self->{'above_detection_limit'} ? :
1545 1 13 if ($self->{'options'}{'preserve_header'}) { }
1548 3 10 unless (exists $self->{'headers'}{"${slash}begin_header"})
1553 1 12 if ($add_missing_headers and $add_missing_headers eq '1')
1556 1 12 unless ($self->{'options'}{'preserve_case'})
1563 12 1 if ($missing eq $adl or $self->{'options'}{'missing_data_to_undef'} and not $self->{'options'}{'preserve_detection_limits'})
1566 12 1 if ($missing eq $bdl or $self->{'options'}{'missing_data_to_undef'} and not $self->{'options'}{'preserve_detection_limits'})
1570 6 7 unless (grep(($_ ne 'unitless'), @{$$self{'actual_units'};}))
1575 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) { }
1578 0 152 if (&firstidx(sub { $_ eq $header_no_slash; } , @ALL_HEADERS) < 0)
1586 1 12 if (not @{$self->{'comments'};} and $add_missing_headers)
1589 3 10 if (not exists $self->{'headers'}{"$slash$header"}) { }
1599 20 90 if ($header =~ /_header/) { }
65 25 elsif (length $self->{'headers'}{"$slash$header"}) { }
25 0 elsif ($add_missing_headers) { }
1603 8 57 if ($header =~ /_latitude|_longitude/) { }
4 53 elsif ($header =~ /_time/) { }
1612 4 21 if ($header =~ /_latitude|_longitude/) { }
2 19 elsif ($header =~ /_time/) { }
1621 0 0 if ($header =~ /_latitude|_longitude/) { }
0 0 elsif ($header =~ /_time/) { }
1631 3 10 unless (exists $self->{'headers'}{"${slash}end_header"})
1641 102 16 defined $row->{$field} ? :
1647 0 14 if ($close_write_to)
1666 128 10 if ($self->{'handle'}) { }
1699 0 31 unless ($self->{'delim'} or $self->guess_delim($line))
1706 0 266 if ($num_expected != $num_got)
1714 958 911 if ($self->{'options'}{'missing_data_to_undef'}) { }
1715 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'}) { }
1731 0 266 if (wantarray) { }
1790 0 109 unless (ref $self)
1795 109 0 if ($name)
1798 1 108 unless (defined $value)
1801 104 4 if (ref $value eq 'ARRAY' and wantarray) { }
0 8 elsif (ref $value eq 'HASH' and wantarray) { }
1832 2 1760 if (not exists $DEFAULT_OPTIONS{$k}) { }
2 1758 elsif (&firstidx(sub { $_ eq ref $v; } , @{$OPTION_TYPES{$k};}) < 0) { }
1836 1 1 $expected_ref ? :
1839 1 132 if ($self->{'options'}{'add_empty_headers'})
1882 1 3 $self->{'options'}{'keep_slashes'} ? :
1883 1 3 if ($self->{'options'}{'add_empty_headers'})
1885 33 0 unless (exists $self->{'headers'}{"$slash$_"})
1887 1 32 if ($_ eq 'missing')
1895 4 0 if ($self->{'options'}{'default_headers'})
1898 4 0 if ($self->{'options'}{'headers'})
1901 0 4 unless ($success)
1918 0 128 if ($self->{'headers'})
1922 7 121 $self->{'options'}{'keep_slashes'} ? :
1929 128 0 if ($self->{'options'}{'default_headers'})
1942 3263 0 if ($line)
1943 113 3150 if ($line =~ m[^(/end_header)\@?$]i) { }
2439 711 elsif ($line =~ m[^/]) { }
696 15 elsif ($line =~ /^!/) { }
1951 10 686 if ($self->{'options'}{'preserve_header'})
1956 0 15 if ($strict & STRICT_READ())
1966 5 123 if ($strict & STRICT_READ()) { }
1972 1 127 if ($self->{'options'}{'preserve_header'})
1981 128 0 if ($self->{'options'}{'headers'})
1987 127 1 if ($self->{'options'}{'preserve_comments'})
1992 1 127 if ($self->{'options'}{'delete_missing_headers'})
1994 3 28 if ($k =~ m[/?(?:end|begin)_header$|^/?missing$])
1997 7 21 if (not defined $v or $v =~ m(^n/?a(?:\[.*?\])?$)i or lc $v eq lc $missing)
2003 5 123 if ($strict & STRICT_READ())
2005 58 52 unless (exists $headers{"$slash$_"})
2011 0 72 if ($slash)
2014 0 72 if (&firstidx(sub { $_ eq $header; } , @ALL_HEADERS) < 0 and &firstidx(sub { $_ eq $header; } , @HIDDEN_HEADERS) < 0)
2019 0 5 if ($headers{"${slash}begin_header"} or $headers{"${slash}end_header"})
2025 1 127 unless (exists $headers{"$slash$_"})
2027 1 0 if ($strict & STRICT_READ())
2036 79 49 if ($headers{"${slash}units"}) { }
2050 1 127 if (@{$self->{'fields'};} != @{$self->{'units'};})
2051 1 0 if ($strict & STRICT_READ()) { }
2064 4 124 unless ($success)
2065 4 0 if ($strict & STRICT_READ()) { }
2079 114 10 if ($self->{'options'}{'cache'})
2087 16 108 if ($self->{'options'}{'fill_ancillary_data'})
2101 77 66 if ($idx >= 0)
2105 29 114 if (ref $value) { }
2125 145 6 if ($idx >= 0)
2134 0 143 if ($field ne $new_field)
2172 201 2365 if (not defined $v) { }
2182 0 2566 if (length $v == 0 and not $k =~ /_header/)
2183 0 0 if ($strict) { }
2191 1308 1258 if (not $self->{'options'}{'preserve_case'} or $k =~ /fields|units/)
2195 139 2427 if ($self->{'options'}{'keep_slashes'}) { }
2196 2 137 if ($k =~ m[^[^/]])
2200 0 6 if ($strict and &firstidx(sub { "/$_" eq $k; } , @ALL_HEADERS) < 0 and &firstidx(sub { "/$_" eq $k; } , @HIDDEN_HEADERS) < 0)
2205 2425 2 if ($k =~ m[^/])
2209 0 80 if ($strict and &firstidx(sub { $_ eq $k; } , @ALL_HEADERS) < 0 and &firstidx(sub { $_ eq $k; } , @HIDDEN_HEADERS) < 0)
2215 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]) { }
2220 1 89 unless ($self->set_delim($strict, $v))
2221 0 1 if ($strict)
2226 111 0 length $v ? :
2229 4 0 length $v ? :
2232 4 0 length $v ? :
2253 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) { }
2264 0 1 $self->{'options'}{'keep_slashes'} ? :
2269 89 1 $delim ? :
2282 4 24 if ($self->{'options'}{'cache'} and $self->{'max_dataidx'} >= 0)
2288 2 26 $self->{'options'}{'keep_slashes'} ? :
2310 21 1895 if (&firstidx(sub { $_ eq $field; } , @{$$self{'actual_fields'};}) < 0)
2311 21 0 unless ($self->{'options'}{'fill_ancillary_data'} and &firstidx(sub { $_ eq $field; } , keys %{$$self{'ancillary'};}) >= 0)
2317 140 137 $self->{'options'}{'missing_data_to_undef'} ? :
2320 57 0 if (defined $hash->{$case_var} and !defined($missing) || $hash->{$case_var} != $missing)
2325 19 258 if (defined $self->{'ancillary'})
2328 173 74 if (defined $self->{'ancillary'}{$variable})
2330 173 0 if (defined $value)
2338 61 1911 unless (exists $hash->{$field})
2358 2 33 if ($line =~ /,/) { }
0 33 elsif ($line =~ /\t/) { }
33 0 elsif ($line =~ /\s+/) { }
0 0 elsif ($line =~ /;/) { }
2378 1 34 $self->{'options'}{'keep_slashes'} ? :
2405 1 26 if ($#_ < 0)
2410 14 12 if (ref $_[0] eq 'HASH') { }
3 9 elsif (ref $_[0] eq 'ARRAY') { }
9 0 elsif (not ref $_[0]) { }
2415 7 2 if ($#_ == 0) { }
1 1 elsif ($#_ % 2 == 1) { }
2416 0 4 unless ($self->{'delim'} or $self->guess_delim($_[0]))
2431 10 15 if ($arrayref)
2433 8 2 if (scalar @{$self->{'actual_fields'};} == scalar @{$arrayref;}) { }
2 0 elsif (scalar @{$self->{'fields'};} == scalar @{$arrayref;}) { }
2441 0 0 if ($actual_fields == $fields) { }
2455 0 25 if (wantarray) { }
2493 95 282 if ($self->{'ancillary'}{$field})
2497 77 205 if ($idx >= 0)
2502 0 205 $self->{'options'}{'keep_slashes'} ? :
2503 8 197 unless $ANCILLARY{$field}
2504 242 107 if (ref $attempt eq 'HASH') { }
64 43 elsif (ref $attempt eq 'ARRAY') { }
43 0 elsif (not ref $attempt) { }
2507 101 141 if ($where =~ /^\$/) { }
12 129 elsif (defined $self->{'headers'}{"$slash$where"} and $self->{'headers'}{"$slash$where"} =~ /$regex/ and lc $1 ne 'na') { }
2508 15 86 if (&firstidx(sub { "\$$_" eq $where; } , $self->fields) >= 0)
2521 30 34 if (ref $attempt[0] eq 'Regexp')
2531 36 50 if ($success) { }
2532 0 36 if (ref $self->{'ancillary'}{$variable}) { }
2545 14 50 if ($success)
2546 8 6 if ($regex)
2558 65 18 if ($success) { }
2559 6 59 if (ref $self->{'ancillary'}{$variable}) { }
2570 25 18 if ($success)
2595 47 173 if (ref $expression) { }
2602 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}) { }
2609 0 0 unless (defined $value)
2638 41 6 if (ref $args[0] eq 'Regexp')
2643 0 47 unless (defined $_)
2648 41 6 if ($regex)
2649 41 0 if ($value =~ /$regex/)
2695 14 0 if ($yyyyjjj =~ /^(\d{4})(\d{3})$/)