Branch Coverage

blib/lib/Data/SeaBASS.pm
Criterion Covered Total %
branch 480 600 80.0


line true false branch
535 4 139 if (ref $file eq 'HASH') { }
129 10 elsif (ref $_[0] eq 'HASH') { }
10 0 elsif (not ref $_[0]) { }
541 9 1 if ($#_ % 2 == 1) { }
553 0 138 if (ref $file eq 'GLOB') { }
132 6 elsif (ref $file eq 'SCALAR') { }
2 4 elsif ($file) { }
559 1 1 if (not ref $file) { }
560 1 0 if (-r $file) { }
0 0 elsif ($self->{'options'}{'strict'} & STRICT_READ()) { }
573 133 4 if ($file) { }
574 0 129 unless ($self->read_headers)
575 0 0 unless ($self->{'options'}{'strict'} & STRICT_READ())
610 269 143 if (ref $_[0] eq 'HASH') { }
142 1 elsif (ref $_[0] eq 'ARRAY') { }
1 0 elsif (not ref $_[0]) { }
617 11 2588 if ($_ =~ /^\s*!/) { }
2 2586 elsif ($strict and not $_ =~ m[^/]) { }
630 0 1 if ($_ =~ /^\s*!/) { }
0 1 elsif ($strict and not $_ =~ m[^/]) { }
684 21 4 if (not @_) { }
1 3 elsif (ref $_[0] eq 'HASH') { }
1 2 elsif (ref $_[0] eq 'ARRAY') { }
693 1 0 if (wantarray) { }
701 4 0 if (not ref $_) { }
703 4 0 defined $value ? :
708 1 1 if (wantarray) { }
0 1 elsif ($#ret == 0) { }
766 83 52 if (defined $index) { }
767 12 71 if ($index < 0)
771 65 6 if ($self->{'options'}{'cache'}) { }
772 41 24 if ($index > $self->{'max_dataidx'})
775 4 71 unless ($self->next)
783 0 61 if (wantarray) { }
789 3 3 if ($index <= $self->{'dataidx'})
794 0 7 unless ($self->next)
801 45 7 if ($self->{'options'}{'cache'}) { }
805 7 38 if (wantarray) { }
816 6 1 if (wantarray) { }
852 0 431 if (@_)
856 73 358 if ($self->{'options'}{'cache'} and $self->{'dataidx'} < $self->{'max_dataidx'}) { }
346 12 elsif ($self->{'handle'}) { }
859 0 73 if (wantarray) { }
871 268 0 if ($line)
874 206 62 if ($self->{'options'}{'cache'})
878 240 28 if ($self->{'dataidx'} > $self->{'max_dataidx'})
881 0 268 if (wantarray) { }
904 31 30 if ($self->{'dataidx'} != -1)
905 9 22 unless ($self->{'options'}{'cache'})
942 1 11 if (not $self->{'options'}{'cache'}) { }
1 10 elsif ($self->{'dataidx'} == -1) { }
948 2 8 unless (defined $new_row)
974 0 3 unless ($self->{'options'}{'cache'})
977 1 2 if ($index < 0)
981 0 2 unless (defined $new_row)
985 2 0 if ($index > $self->{'max_dataidx'})
990 1 1 if ($index > $self->{'max_dataidx'})
1032 0 16 unless ($self->{'options'}{'cache'})
1035 1 15 if ($index < INSERT_END())
1039 0 15 unless (defined $new_row)
1043 10 5 if ($index == INSERT_END()) { }
2 3 elsif ($index > $self->{'max_dataidx'}) { }
1052 0 2 if ($index == $self->{'max_dataidx'} + 1) { }
1 1 elsif ($index > $self->{'max_dataidx'}) { }
1059 3 11 if ($index <= $self->{'dataidx'} and $index != INSERT_END())
1065 2 12 if ($index == INSERT_BEGINNING()) { }
10 2 elsif ($index == INSERT_END()) { }
1106 1 5 if (not $self->{'options'}{'cache'}) { }
0 8 elsif (not defined $index and $self->{'dataidx'} < 0) { }
1112 2 3 unless (defined $index)
1116 0 5 if ($index < 0) { }
2 3 elsif ($index > $self->{'max_dataidx'}) { }
1123 1 1 if ($index > $self->{'max_dataidx'})
1128 3 1 if ($index <= $self->{'dataidx'})
1181 1 6 if (ref $function ne 'CODE')
1192 12 7 if (defined $ret and defined wantarray)
1195 2 17 unless (defined $row)
1196 1 1 if ($self->{'dataidx'} <= $currentidx)
1231 5 8 if (ref $_[$#_] eq 'HASH')
1234 0 13 unless (@_)
1238 3 10 $self->{'options'}{'missing_data_to_undef'} ? :
1246 4 17 if (&firstidx(sub { $_ eq $field; } , @{$$self{'actual_fields'};}) < 0)
1247 3 1 if (not $self->{'options'}{'fill_ancillary_data'} or &firstidx(sub { $_ eq $field; } , keys %{$$self{'ancillary'};}) < 0)
1256 20 20 if ($options{'delete_missing'})
1259 4 32 unless (defined $row->{$field} and !defined($missing) || $row->{$field} != $missing)
1264 4 16 unless ($has_all)
1276 3 7 if ($#_ == 0) { }
4 3 elsif (wantarray) { }
1277 1 2 if (wantarray) { }
1299 1 7 unless (@_)
1307 1 8 if ($field_idx < 0) { }
1331 0 25 if (not $self->{'options'}{'cache'}) { }
1 24 elsif (not $field) { }
1339 3 21 if ($field_idx >= 0)
1342 15 6 unless (defined $position)
1348 17 4 if ($position == INSERT_END()) { }
2 2 elsif ($position == INSERT_BEGINNING()) { }
1381 0 10 if ($#_ < 0)
1389 13 0 if (defined $find)
1390 7 6 if (not ref $find) { }
6 0 elsif (ref $find eq 'Regexp') { }
1399 23 69 if ($field =~ /$regex/)
1407 7 3 if ($#_ == 0) { }
1410 2 1 if (wantarray) { }
1430 1 2 if ($c =~ /^!/) { }
1448 2 4 if (@_) { }
1453 0 6 if (wantarray) { }
1473 1 1 if ($c =~ /^!/) { }
1501 1 14 $self->{'options'}{'keep_slashes'} ? :
1504 3 12 if ($strict_write)
1507 0 65 if (&firstidx(sub { $_ eq $header_no_slash; } , @ALL_HEADERS) < 0 and &firstidx(sub { $_ eq $header_no_slash; } , @HIDDEN_HEADERS) < 0)
1514 20 46 unless (exists $self->{'headers'}{$header})
1521 14 1 if (not $error) { }
1525 0 14 if (not $write_to_h and exists $self->{'default_write_to'})
1529 0 14 if (defined $write_to_h)
1530 0 0 if (ref $write_to_h eq 'GLOB') { }
0 0 elsif (not ref $write_to_h) { }
1535 0 0 unless open $write_to_h, '>', $write_to
1545 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') { }
1558 14 0 exists $self->{'missing'} ? :
1559 14 0 exists $self->{'below_detection_limit'} ? :
1560 14 0 exists $self->{'above_detection_limit'} ? :
1562 1 13 if ($self->{'options'}{'preserve_header'}) { }
1565 3 10 unless (exists $self->{'headers'}{"${slash}begin_header"})
1570 1 12 if ($add_missing_headers and $add_missing_headers eq '1')
1573 1 12 unless ($self->{'options'}{'preserve_case'})
1580 12 1 if ($missing eq $adl or $self->{'options'}{'missing_data_to_undef'} and not $self->{'options'}{'preserve_detection_limits'})
1583 12 1 if ($missing eq $bdl or $self->{'options'}{'missing_data_to_undef'} and not $self->{'options'}{'preserve_detection_limits'})
1587 6 7 unless (grep(($_ ne 'unitless'), @{$$self{'actual_units'};}))
1592 13 399 if ($header eq 'missing') { }
13 386 elsif ($header eq 'fields') { }
7 379 elsif ($header eq 'units') { }
111 268 elsif (exists $self->{'headers'}{"$slash$header"}) { }
0 268 elsif ($add_missing_headers) { }
1595 0 153 if (&firstidx(sub { $_ eq $header_no_slash; } , @ALL_HEADERS) < 0)
1603 1 12 if (not @{$self->{'comments'};} and $add_missing_headers)
1606 3 10 if (not exists $self->{'headers'}{"$slash$header"}) { }
1616 20 91 if ($header =~ /_header/) { }
65 26 elsif (length $self->{'headers'}{"$slash$header"}) { }
26 0 elsif ($add_missing_headers) { }
1620 8 57 if ($header =~ /_latitude|_longitude/) { }
4 53 elsif ($header =~ /_time/) { }
1629 1 25 if $OMIT_EMPTY_HEADERS{$header}
1632 4 21 if ($header =~ /_latitude|_longitude/) { }
2 19 elsif ($header =~ /_time/) { }
1641 0 0 if $OMIT_EMPTY_HEADERS{$header}
1644 0 0 if ($header =~ /_latitude|_longitude/) { }
0 0 elsif ($header =~ /_time/) { }
1654 3 10 unless (exists $self->{'headers'}{"${slash}end_header"})
1664 102 16 defined $row->{$field} ? :
1670 0 14 if ($close_write_to)
1689 133 10 if ($self->{'handle'}) { }
1722 0 33 unless ($self->{'delim'} or $self->guess_delim($line))
1729 0 268 if ($num_expected != $num_got)
1737 968 911 if ($self->{'options'}{'missing_data_to_undef'}) { }
1738 0 968 if (not length $v) { }
68 900 elsif ($self->{'missing_is_number'} and &looks_like_number($v) and $v == $self->{'missing'}) { }
1 899 elsif (not $self->{'options'}{'preserve_detection_limits'} and $self->{'adl_is_number'} and &looks_like_number($v) and $v == $self->{'above_detection_limit'}) { }
1 898 elsif (not $self->{'options'}{'preserve_detection_limits'} and $self->{'bdl_is_number'} and &looks_like_number($v) and $v == $self->{'below_detection_limit'}) { }
10 888 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'}) { }
1756 0 268 if (wantarray) { }
1815 0 138 unless (ref $self)
1820 138 0 if ($name)
1823 1 137 unless (defined $value)
1826 133 4 if (ref $value eq 'ARRAY' and wantarray) { }
0 8 elsif (ref $value eq 'HASH' and wantarray) { }
1857 2 1968 if (not exists $DEFAULT_OPTIONS{$k}) { }
2 1966 elsif (&firstidx(sub { $_ eq ref $v; } , @{$OPTION_TYPES{$k};}) < 0) { }
1861 1 1 $expected_ref ? :
1864 1 137 if ($self->{'options'}{'add_empty_headers'})
1907 1 3 $self->{'options'}{'keep_slashes'} ? :
1908 1 3 if ($self->{'options'}{'add_empty_headers'})
1910 34 0 unless (exists $self->{'headers'}{"$slash$_"})
1912 1 33 if ($_ eq 'missing')
1920 4 0 if ($self->{'options'}{'default_headers'})
1923 4 0 if ($self->{'options'}{'headers'})
1926 0 4 unless ($success)
1943 0 133 if ($self->{'headers'})
1947 7 126 $self->{'options'}{'keep_slashes'} ? :
1954 133 0 if ($self->{'options'}{'default_headers'})
1967 3294 0 if ($line)
1968 116 3178 if ($line =~ m[^(/end_header)\@?$]i) { }
2465 713 elsif ($line =~ m[^/]) { }
696 17 elsif ($line =~ /^!/) { }
1976 10 686 if ($self->{'options'}{'preserve_header'})
1981 0 17 if ($strict & STRICT_READ())
1991 5 128 if ($strict & STRICT_READ()) { }
1997 1 132 if ($self->{'options'}{'preserve_header'})
2006 133 0 if ($self->{'options'}{'headers'})
2012 132 1 if ($self->{'options'}{'preserve_comments'})
2017 1 132 if ($self->{'options'}{'delete_missing_headers'})
2019 3 28 if ($k =~ m[/?(?:end|begin)_header$|^/?missing$])
2022 7 21 if (not defined $v or $v =~ m(^n/?a(?:\[.*?\])?$)i or lc $v eq lc $missing)
2028 5 128 if ($strict & STRICT_READ())
2030 58 52 unless (exists $headers{"$slash$_"})
2036 0 72 if ($slash)
2039 0 72 if (&firstidx(sub { $_ eq $header; } , @ALL_HEADERS) < 0 and &firstidx(sub { $_ eq $header; } , @HIDDEN_HEADERS) < 0)
2044 0 5 if ($headers{"${slash}begin_header"} or $headers{"${slash}end_header"})
2050 1 132 unless (exists $headers{"$slash$_"})
2052 1 0 if ($strict & STRICT_READ())
2061 79 54 if ($headers{"${slash}units"}) { }
2075 1 132 if (@{$self->{'fields'};} != @{$self->{'units'};})
2076 1 0 if ($strict & STRICT_READ()) { }
2089 4 129 unless ($success)
2090 4 0 if ($strict & STRICT_READ()) { }
2104 119 10 if ($self->{'options'}{'cache'})
2112 18 111 if ($self->{'options'}{'fill_ancillary_data'})
2126 83 80 if ($idx >= 0)
2130 29 134 if (ref $value) { }
2150 159 6 if ($idx >= 0)
2159 0 163 if ($field ne $new_field)
2169 1 127 if ($self->{'options'}{'optional_warnings'} and $headers{$data_use_header})
2201 207 2388 if (not defined $v) { }
2211 1 2594 if (length $v == 0 and not $k =~ /_header/)
2212 0 1 if ($strict) { }
2220 1313 1282 if (not $self->{'options'}{'preserve_case'} or $k =~ /fields|units/)
2224 139 2456 if ($self->{'options'}{'keep_slashes'}) { }
2225 2 137 if ($k =~ m[^[^/]])
2229 0 6 if ($strict and &firstidx(sub { "/$_" eq $k; } , @ALL_HEADERS) < 0 and &firstidx(sub { "/$_" eq $k; } , @HIDDEN_HEADERS) < 0)
2234 2454 2 if ($k =~ m[^/])
2238 0 80 if ($strict and &firstidx(sub { $_ eq $k; } , @ALL_HEADERS) < 0 and &firstidx(sub { $_ eq $k; } , @HIDDEN_HEADERS) < 0)
2244 308 2287 if ($k =~ /_latitude|_longitude/) { }
159 2128 elsif ($k =~ /_time/) { }
93 2035 elsif ($k =~ m[^/?delimiter$]) { }
114 1921 elsif ($k =~ m[^/?missing$]) { }
7 1914 elsif ($k =~ m[^/?above_detection_limit]) { }
7 1907 elsif ($k =~ m[^/?below_detection_limit]) { }
2249 1 92 unless ($self->set_delim($strict, $v))
2250 0 1 if ($strict)
2255 114 0 length $v ? :
2258 7 0 length $v ? :
2261 7 0 length $v ? :
2282 0 93 if ($delim eq 'comma') { }
0 93 elsif ($delim eq 'semicolon') { }
91 2 elsif ($delim eq 'space') { }
0 2 elsif ($delim eq 'tab') { }
1 1 elsif ($strict) { }
2293 0 1 $self->{'options'}{'keep_slashes'} ? :
2298 92 1 $delim ? :
2311 4 24 if ($self->{'options'}{'cache'} and $self->{'max_dataidx'} >= 0)
2317 2 26 $self->{'options'}{'keep_slashes'} ? :
2339 21 1905 if (&firstidx(sub { $_ eq $field; } , @{$$self{'actual_fields'};}) < 0)
2340 21 0 unless ($self->{'options'}{'fill_ancillary_data'} and &firstidx(sub { $_ eq $field; } , keys %{$$self{'ancillary'};}) >= 0)
2346 142 137 $self->{'options'}{'missing_data_to_undef'} ? :
2350 279 1953 if ($case_var eq 'second') { }
50 1903 elsif (defined $v and length $v and !defined($missing) || $v != $missing) { }
2351 11 0 if (defined $v and length $v and !defined($missing) || $v != $missing)
2352 1 10 if ($v =~ /\D/) { }
2363 21 258 if (defined $self->{'ancillary'})
2366 193 80 if (defined $self->{'ancillary'}{$variable})
2368 193 0 if (defined $value)
2376 61 1921 unless (exists $hash->{$field})
2396 2 35 if ($line =~ /,/) { }
0 35 elsif ($line =~ /\t/) { }
35 0 elsif ($line =~ /\s+/) { }
0 0 elsif ($line =~ /;/) { }
2416 1 36 $self->{'options'}{'keep_slashes'} ? :
2443 1 26 if ($#_ < 0)
2448 14 12 if (ref $_[0] eq 'HASH') { }
3 9 elsif (ref $_[0] eq 'ARRAY') { }
9 0 elsif (not ref $_[0]) { }
2453 7 2 if ($#_ == 0) { }
1 1 elsif ($#_ % 2 == 1) { }
2454 0 4 unless ($self->{'delim'} or $self->guess_delim($_[0]))
2469 10 15 if ($arrayref)
2471 8 2 if (scalar @{$self->{'actual_fields'};} == scalar @{$arrayref;}) { }
2 0 elsif (scalar @{$self->{'fields'};} == scalar @{$arrayref;}) { }
2479 0 0 if ($actual_fields == $fields) { }
2493 0 25 if (wantarray) { }
2531 130 348 if ($self->{'ancillary'}{$field})
2535 83 265 if ($idx >= 0)
2540 0 265 $self->{'options'}{'keep_slashes'} ? :
2541 27 238 unless $ANCILLARY{$field}
2542 308 153 if (ref $attempt eq 'HASH') { }
104 49 elsif (ref $attempt eq 'ARRAY') { }
49 0 elsif (not ref $attempt) { }
2545 130 178 if ($where =~ /^\$/) { }
20 158 elsif (defined $self->{'headers'}{"$slash$where"} and $self->{'headers'}{"$slash$where"} =~ /$regex/ and lc $1 ne 'na') { }
2546 15 115 if (&firstidx(sub { "\$$_" eq $where; } , $self->fields) >= 0)
2559 50 54 if (ref $attempt[0] eq 'Regexp')
2569 55 90 if ($success) { }
2570 0 55 if (ref $self->{'ancillary'}{$variable}) { }
2583 14 90 if ($success)
2584 8 6 if ($regex)
2596 81 18 if ($success) { }
2597 6 75 if (ref $self->{'ancillary'}{$variable}) { }
2608 31 18 if ($success)
2633 47 193 if (ref $expression) { }
2640 131 104 if ($self->{'ancillary_tmp'}{$variable}) { }
104 0 elsif (defined $row->{$variable} and length $row->{$variable} and !defined($missing) || $row->{$variable} != $missing) { }
0 0 elsif (ref $self->{'ancillary'}{$variable}) { }
2647 0 0 unless (defined $value)
2676 41 6 if (ref $args[0] eq 'Regexp')
2681 0 47 unless (defined $_)
2686 41 6 if ($regex)
2687 41 0 if ($value =~ /$regex/)
2733 14 0 if ($yyyyjjj =~ /^(\d{4})(\d{3})$/)