Branch Coverage

blib/lib/Spreadsheet/Edit.pm
Criterion Covered Total %
branch 187 678 27.5


line true false branch
115 9 15 $Type eq 'Array' ? :
6 24 $Type eq 'Hash' ? :
121 0 30 if $@
257 0 0 ref $_[0] eq 'HASH' ? :
0 0 ref $_[0] eq 'ARRAY' ? :
4 0 @_ != 1 ? :
261 0 0 if wantarray
264 0 4 @_ % 2 != 0 ? :
0 4 @_ == 1 && ref $_[0] eq 'HASH' ? :
302 0 0 if (/^\w/u) { }
303 0 0 if ($barewords++) { }
306 0 0 if $s
310 0 0 if ($barewords)
314 0 0 if $s
318 0 0 if $barewords
327 0 0 if @_ == 1
328 0 0 if $result
351 0 0 if ($_ eq "\n" or $llen > $indent and $llen + length($_) > $foldwidth)
355 0 0 if $_ eq "\n"
357 0 0 if ($llen == 0) { }
361 0 0 if (substr($buf, -1) =~ /\S/u)
375 0 0 if (ref $colspec eq 'Regexp') { }
380 0 0 if (index($colspec, $left) < 0 and index($colspec, $right) < 0)
388 0 0 unless defined $cx
390 0 0 $colspec eq "$cx" ? :
394 28 0 defined $cx ? :
466 0 14 unless defined $title
467 14 0 unless $title eq "" or $title eq "^" or $title eq "\$"
488 0 14 if $title eq ""
489 0 14 if ($seen{$title}++)
490 0 0 unless $$$self{"silent"}
495 0 14 if (&__unindexed_title($title, $num_cols)) { }
519 0 2 if exists $opts{"package"}
521 0 2 $opts{'package'} ? :
522 0 2 unless defined $userpkg and $userpkg =~ /^[a-zA-Z][:\w]*$/a
530 0 2 if $$$sheet{"verbose"}
578 0 274 unless ref($sheet) =~ /^Spreadsheet::Edit\b/u
579 274 0 unless $sheet->sheetname
583 208 77 if (@_ > 0 and ref $_[0])
584 24 184 if (ref($_[0]) =~ /^Spreadsheet::Edit\b/u) { }
184 0 elsif (ref $_[0] eq 'ARRAY' and @{$_[0];} <= 2 and ref($_[0][0]) . '' =~ /^Spreadsheet::Edit\b/u) { }
594 77 208 unless (defined $sheet)
597 22 263 unless (defined $sheet)
600 125 160 unless (defined $rx)
601 114 11 if defined $sheet
604 274 11 if (defined $sheet)
606 80 194 if (defined $rx and $rx < 0 || $rx > $#{$sheet->rows;}) { }
610 121 73 if defined $rx
615 49 236 $msgstr =~ /\n\z/su ? :
617 0 285 if ($msgstr =~ s/\A(\n+)([^\n])/$2/su)
645 0 53 unless defined $frame[0]
646 15 38 if ($frame[3] =~ /::([a-z][^:]*)/u)
647 13 2 unless wantarray
650 2 0 if ($hasargs)
652 0 2 if $@
681 0 1 if index($pkg, "Spreadsheet::Edit") == 0
697 0 4 if exists $$opthash{$key}
699 0 4 if exists $$new_args{$key}
728 10 1110 unless defined &blessed($_[0]) and $_[0]->isa("Spreadsheet::Edit") and shift @_
731 0 841 unless (&__self_ifexists)
738 0 279 unless (&__self_ifexists)
755 12 23 ref $_[0] eq 'HASH' ? :
769 0 274 if @_
774 0 553 if @_
782 0 2 if $Nargs != @_
794 0 10 unless defined $opthash
797 0 1 unless &first(sub {
800 0 1 if $opts{"undef_ok_only"} and not defined $$opthash{$k} and not grep({$_ eq $k;} @{$opts{"undef_ok_only"};})
815 2 28 if (exists $$opthash{$key})
829 0 0 unless defined $_[0]
830 0 0 unless $_[0] ne ""
831 0 0 unless $_[0] eq &title2ident($_[0])
839 0 0 unless defined $opthash
842 0 0 unless &first(sub {
848 0 4 unless defined $_[0] and "$_[0]" =~ /^\d+$/u
854 0 0 unless not defined $_[0] or "$_[0]" =~ /^\d+$/u
861 0 4 unless (scalar(@_) % 2 == 0)
862 0 0 if ref $_[0] eq "HASH"
869 0 1 unless $key =~ /^\w+$/u
877 0 0 unless ($rx // "") =~ /^\d+$/u
880 0 0 $one_past_end_ok ? :
0 0 if $rx > ($one_past_end_ok ? $maxrx + 1 : $maxrx)
888 0 0 if $wantarray
889 0 0 if @_
890 0 0 if defined $wantarray
895 0 0 unless $wantarray or not defined $wantarray
903 0 0 if $$$self{"_carponce"}{$msg}++
904 0 0 unless $msg =~ /\n\z/su
906 0 0 unless $$$self{"silent"}
920 0 4 unless defined $classname and $classname =~ /^[\w_:]+$/u
935 0 4 if (my $clonee = delete $opts{'clone'}) { }
937 0 0 if %opts
972 2 2 if (my $newdata = delete $opts{"rows"})
987 0 4 if $$$self{"verbose"}
1018 0 6 if defined $current_rx
1022 0 12 unless &__looks_like_aref($row)
1025 0 30 if ref $$row[$cx]
1032 6 0 if defined $_
0 6 unless ref $linenums eq "ARRAY" and &all(sub {
1034 4 2 if (@$rows) { }
1036 4 8 if @$_ > $nc
1037 0 4 if ($num_cols and $num_cols != $nc) { }
1056 0 6 unless @$linenums == @$rows
1094 1 2 $pkg eq 'main' ? :
1105 0 3 if (@_ > 0 and %$tiedvarnames)
1108 0 0 unless exists $$tiedvarnames{$_}
1119 16 0 defined $cx ? :
1125 0 16 unless $ident =~ /^\w+$/u
1127 0 16 if (exists $$tiedvarnames{$ident})
1128 0 0 if $debug
1132 0 16 if $debug
1135 8 8 if ($safe)
1136 0 8 if (${^GLOBAL_PHASE} ne "START")
1137 0 0 unless $silent
1144 0 16 if $debug
1146 0 16 if (exists ${$p . "::";}{$ident})
1166 0 0 if (my $r = *$fqname{"SCALAR"})
1167 0 0 if (defined $$r)
1171 0 0 if (my $r = *$fqname{"ARRAY"})
1174 0 0 if (my $r = *$fqname{"HASH"})
1177 0 0 if (my $r = *$fqname{"CODE"})
1180 0 0 if (my $r = *$fqname{"IO"})
1183 0 0 if (eval {
1186 0 0 unless /^(.+)\.(.*)$/u
1187 0 0 if (grep {$_ eq $ident;} $obj->$methname)
1197 0 16 if $debug
1223 0 18 if (/^(?:REGERROR|REGMARK|AUTOLOAD)$/u)
1237 0 3 unless @_
1247 5 0 if (/:/u) { }
1249 0 0 unless /^\$?\w+$/u
1269 0 3 if exists $$opts{"title_rx"}
1271 3 0 if (delete $tokens{":all"})
1277 0 3 if %tokens
1281 0 3 $r == 1 ? :
1284 0 3 if $$$self{"verbose"}
1296 274 0 if (@_ == 0)
1297 0 274 if $$$self{"verbose"}
1300 0 0 if $$$self{"verbose"}
1301 0 0 unless @_ == 1
1319 0 0 unless exists $${$self;}{"input_iolayers"} and $${$self;}{"input_iolayers"} =~ /encoding\(([^()]*)\)/u
1327 0 0 defined $title_rx ? :
1328 0 0 if $$$self{"verbose"}
1344 0 0 if $rx < 0 or $rx > $#$rows
1347 0 0 if not defined $cx or $cx < 0 or $cx > $#$row
1366 0 12 if defined $sheet and not &blessed($sheet) && $sheet->isa('Spreadsheet::Edit')
1383 0 0 $in_midst ? :
1390 0 0 unless defined $sheet
1394 0 0 if (length $desc > $trunclen)
1400 0 0 unless $${$_[0];}{"verbose"}
1406 0 8 if @_ > 3
1407 8 0 unless $${$_[0];}{"verbose"}
1418 0 6 if (@$cxlist) { }
1429 0 6 if ($@)
1432 0 0 unless $$$self{"debug"}
1445 0 6 unless ref $code eq "CODE"
1448 0 0 if ($_ < 0 or $_ >= $num_cols)
1459 5 1 if (defined $rxlist) { }
1461 0 5 if $rx < 0 or $rx > $#$rows
1481 0 6 if defined $$hash{"current_rx"} and $$hash{"current_rx"} > $#$rows
1594 0 0 unless @$old_colxs == $num_cols
1598 0 0 if defined $old_cx
1603 0 0 unless defined $cx
1604 0 0 if (defined(my $new_cx = $old2new{$cx})) { }
1605 0 0 if $debug
1608 0 0 if $debug
1626 0 0 unless defined $spec
1627 0 0 if ($spec eq "^")
1631 0 0 if ($spec eq "\$")
1635 0 0 if ($spec =~ /^[1-9]\d*$/u || $spec eq '0' and $spec <= $num_cols)
1640 0 0 if (defined(my $cx = $$colx{$spec}))
1644 0 0 if (ref $spec eq "Regexp")
1646 0 0 unless defined $title_rx
1654 0 0 if ($title =~ /$spec/u)
1659 0 0 unless ($matched)
1672 0 0 unless wantarray
1678 0 0 if (@list > 1)
1687 0 0 if ref $colspec eq "Regexp"
1714 0 0 if ($spec =~ /^>(.*)/u)
1723 0 0 ref $_[0] eq 'HASH' ? :
1724 0 0 if ($opthash)
1728 0 0 unless scalar @_ % 2 == 0
1741 0 0 if (my $wheredefined = $$useraliases{$ident})
1749 0 0 if $$useraliases{$ident}
1752 0 0 unless (defined $cx)
1753 0 0 unless $@
1754 0 0 unless $$opthash{"optional"} and $@ =~ /does not match/isu
1773 0 0 if ref $_[0] eq "HASH"
1825 2 6 if (@_ == 0) { }
1827 0 2 if %$opthash
1834 1 5 if &u($_[0]) eq "_notie"
1835 0 6 if @_
1837 6 0 if (defined $rx)
1838 1 5 if ($rx eq 'auto') { }
0 5 elsif (not $rx =~ /^\d+$/u) { }
0 5 elsif ($rx > $#{$$$self{'rows'};}) { }
1861 0 1 if ($#$rows == -1)
1867 0 1 $$opthash{'required'} ? :
1868 0 1 if grep {not defined $_;} @required_specs
1873 1 0 if $max_rx > $#$rows
1877 1 0 if $last_cx >= $num_cols
1880 0 1 if ($min_rx > $#$rows) { }
0 1 elsif ($min_rx > $max_rx) { }
1887 0 1 if ($first_cx >= $num_cols) { }
0 1 elsif ($first_cx > $last_cx) { }
1896 1 0 unless (@nd_reasons)
1901 0 1 if $debug and @nd_reasons
1902 0 1 if $debug
1908 0 1 unless $rx == $$$self{"title_rx"}
1912 0 2 if ($$row[$cx] eq "")
1920 0 0 if $debug
1921 0 0 if (@list == 0)
1925 0 0 if $$_[0] >= $first_cx
1927 0 0 if (@shortlist == 0)
1931 0 0 unless (grep {$$_[1] =~ /title/iu;} @shortlist)
1936 0 0 if $debug
1943 1 0 if (defined $detected) { }
1944 0 1 if ($verbose)
1953 0 0 if (@nd_reasons == 0)
1983 0 0 if $to_cx + @sources - @source_cxs_before > $num_cols
2013 0 0 if (&first(sub {
2014 0 0 unless defined $title_rx
2019 0 0 if $seen{$ntitle}++
2021 0 0 if defined $ex_rx
2032 0 0 if (defined $title_rx and $row == $$rows[$title_rx]) { }
2052 0 0 unless @_ == 1
2057 0 0 defined $title_rx ? :
2062 0 0 unless defined $first_rx
2063 0 0 unless defined $last_rx
2092 0 0 if $cx > $#$row
2110 12 0 unless !!$oldval != !!$val
2111 0 0 if ($key eq 'silent') { }
0 0 elsif ($key eq 'verbose') { }
0 0 elsif ($key eq 'debug') { }
2115 0 0 if ($val) { }
2123 0 0 if ($val) { }
2143 0 0 exists $$$self{$_} ? :
2147 0 0 if (@_ == 0) { }
2148 0 0 unless wantarray
2160 0 0 unless @_ == 2
2165 0 0 if ($seen{$cx})
2209 0 0 ref $separator eq 'CODE' ? :
2225 0 0 unless scalar @_ % 2 == 0
2230 0 0 unless defined $title_rx
2240 0 0 if $cx > $#$title_row
2275 0 0 @cxs > 0 ? :
0 0 if $$$self{"verbose"}
2282 3 2 ref $_ eq 'ARRAY' ? :
2284 5 0 unless ref $_
0 5 unless @$result > 0 and not grep({$_ eq "" unless ref $_;} @$result)
2294 0 5 unless defined $rxlist_arg
2299 0 0 @cxs > 0 ? :
0 5 if $$$self{"verbose"}
2309 0 0 unless defined $exrxlist_arg
2314 0 0 @cxs > 0 ? :
0 0 if $$$self{"verbose"}
2318 0 0 if $_ < 0 or $_ > $max_rx
2340 0 0 if $$$self{"verbose"}
2346 0 0 if $old_cx >= $newcols_first_cx
2357 0 0 if $$$self{"verbose"}
2367 0 0 if $$$self{"verbose"}
2388 0 0 if ($$$self{'saved_linenums'}) { }
2413 0 0 if /^(?:LAST|\$)$/u
2415 0 0 unless $_ <= $#$rows
2418 0 0 if $$$self{"verbose"}
2421 0 0 if (defined $title_rx)
2423 0 0 if ($_ < $title_rx) { }
0 0 elsif ($_ == $title_rx) { }
2426 0 0 if $$$self{"verbose"}
2439 0 0 if (defined $current_rx)
2441 0 0 if $_ <= $current_rx
2471 0 0 if $rx =~ /^(?:END|\$)$/u
2474 0 0 if $$$self{"verbose"}
2478 0 0 if (defined $title_rx and $rx <= $title_rx)
2513 0 62 if defined $$opthash{$key}
2519 0 2 if exists $$opthash{"sheet"}
2533 0 2 if (my $enc = delete $$opthash{"encoding"})
2569 0 2 unless my $csv = "Text::CSV"->new(\%csvopts)
2593 0 2 unless close $fh
2605 0 10 if exists $$opthash{$_}
2608 1 1 exists $$opthash{'title_rx'} ? :
2616 0 2 if $$$self{"verbose"}
2625 0 0 ref $_[0] eq 'HASH' ? :
2633 0 0 if defined $$opts{$key}
2642 0 0 if %notok
2648 0 0 unless ($$opts{"iolayers"} =~ /encoding\(|:utf8/u)
2653 0 0 unless ($$opts{"iolayers"} =~ /:(?:crlf|raw)\b/u)
2662 0 0 if (&openhandle($dest)) { }
2665 0 0 if $$$self{"verbose"}
2670 0 0 if $$$self{"verbose"}
2671 0 0 if $dest =~ /\.([a-z]*)$/u and lc $1 ne "csv"
2673 0 0 unless open $fh, ">$dest"
2676 0 0 unless binmode $fh, $$opts{"iolayers"}
2715 0 0 $csvopts{'quote_char'} ne '' ? :
0 0 $csvopts{'escape_char'} ne '' && $csvopts{'escape_char'} ne "\000" ? :
2723 0 0 unless defined $value
2727 0 0 unless ($must_be_quoted)
2728 0 0 if ($value eq '') { }
2729 0 0 if $csvopts{"quote_empty"}
2731 0 0 if ($csvopts{"quote_char"} ne "")
2738 0 0 if $value =~ /\Q$csvopts{"quote_char"}\E/d or $csvopts{"sep_char"} ne "" and $csvopts{"sep_char"} ne "\0" and $value =~ /\Q$csvopts{"sep_char"}\E/d or $csvopts{"escape_char"} ne "" and $csvopts{"escape_char"} ne "\0" and $value =~ /\Q$csvopts{"escape_char"}\E/d or $csvopts{"quote_binary"} and $value =~ /[\x00-\x1f\x7f-\xa0]/d or $csvopts{"quote_space"} and $value =~ /[\x09\x20]/d
2743 0 0 if ($csvopts{"escape_null"})
2746 0 0 if ($must_be_quoted)
2749 0 0 unless $cx == 0
2755 0 0 unless (&openhandle($dest))
2756 0 0 unless close $fh
2769 0 0 if $$$self{"verbose"}
2775 0 0 if (ref $cf eq "HASH")
2778 0 0 if $key eq "__DEFAULT__"
2782 0 0 unless defined $_
2792 0 0 unless close $csvfh
2814 0 7 unless (defined $$$self{"current_rx"})
2817 0 0 if defined $pkg and $pkg->isa("Data::Dumper")
2827 0 9 if $mutating
2829 0 9 unless defined $sheet
2831 5 4 $onlyinapply ? :
2836 0 5 unless exists $$$sheet{$ident}
2845 0 0 if ($index_ident eq "current_rx" or $index_ident eq "title_rx")
2850 0 0 if $index > $#$aref
2855 4 0 if $mutable
2868 0 14 if index($pkg, "Spreadsheet::Edit") >= 0
2869 2 12 $$opthash{'package'} ? :
2872 12 2 if (@_) { }
2874 0 12 if @_
2875 9 3 if (defined $new)
2876 0 9 if $$$new{"cmd_nesting"}
2880 0 0 &u($curr) eq &u($new) ? :
0 12 if $verbose
2889 0 2 if $verbose
2920 0 47 unless $index >= 0 and $index <= $#$aref
2927 0 12 unless $index >= 0 and $index <= $#$aref + 1
2929 0 12 unless &Spreadsheet::Edit::__looks_like_aref($val)
2932 0 12 if grep {not defined $_;} @$val
2934 0 30 if ref $_
0 12 if grep {not &looks_like_number($_) if ref $_;} @$val
2935 0 12 if (my $num_cols = $$$sheet{"num_cols"})
2936 0 0 if @$val != $num_cols
2989 0 4 unless (defined $cx)
2990 0 0 unless exists $$colx{$key}
2995 0 0 if $mutating