Branch Coverage

blib/lib/Spreadsheet/Edit.pm
Criterion Covered Total %
branch 187 694 26.9


line true false branch
115 9 21 $Type eq 'Array' ? :
6 30 $Type eq 'Hash' ? :
121 0 36 if $@
259 0 0 ref $_[0] eq 'HASH' ? :
0 0 ref $_[0] eq 'ARRAY' ? :
4 0 @_ != 1 ? :
263 0 0 if wantarray
266 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"} and not defined $$opthash{$k} and not grep({$_ eq $k;} @{$opts{"undef_ok"};})
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
974 2 2 if (my $newdata = delete $opts{"rows"})
989 0 4 if $$$self{"verbose"}
1020 0 6 if defined $current_rx
1024 0 12 unless &__looks_like_aref($row)
1027 0 30 if ref $$row[$cx]
1034 6 0 if defined $_
0 6 unless ref $linenums eq "ARRAY" and &all(sub {
1036 4 2 if (@$rows) { }
1038 4 8 if @$_ > $nc
1039 0 4 if ($num_cols and $num_cols != $nc) { }
1058 0 6 unless @$linenums == @$rows
1098 1 2 $pkg eq 'main' ? :
1109 0 3 if (@_ > 0 and %$tiedvarnames)
1112 0 0 unless exists $$tiedvarnames{$_}
1123 16 0 defined $cx ? :
1129 0 16 unless $ident =~ /^\w+$/u
1131 0 16 if (exists $$tiedvarnames{$ident})
1132 0 0 if $debug
1136 0 16 if $debug
1139 8 8 if ($safe)
1140 0 8 if (${^GLOBAL_PHASE} ne "START")
1141 0 0 unless $silent
1148 0 16 if $debug
1150 0 16 if (exists ${$p . "::";}{$ident})
1170 0 0 if (my $r = *$fqname{"SCALAR"})
1171 0 0 if (defined $$r)
1175 0 0 if (my $r = *$fqname{"ARRAY"})
1178 0 0 if (my $r = *$fqname{"HASH"})
1181 0 0 if (my $r = *$fqname{"CODE"})
1184 0 0 if (my $r = *$fqname{"IO"})
1187 0 0 if (eval {
1190 0 0 unless /^(.+)\.(.*)$/u
1191 0 0 if (grep {$_ eq $ident;} $obj->$methname)
1201 0 16 if $debug
1227 0 18 if (/^(?:REGERROR|REGMARK|AUTOLOAD)$/u)
1241 0 3 unless @_
1251 5 0 if (/:/u) { }
1253 0 0 unless /^\$?\w+$/u
1273 0 3 if exists $$opts{"title_rx"}
1275 3 0 if (delete $tokens{":all"})
1281 0 3 if %tokens
1285 0 3 $r == 1 ? :
1288 0 3 if $$$self{"verbose"}
1300 274 0 if (@_ == 0)
1301 0 274 if $$$self{"verbose"}
1304 0 0 if $$$self{"verbose"}
1305 0 0 unless @_ == 1
1323 0 0 unless exists $${$self;}{"input_iolayers"} and $${$self;}{"input_iolayers"} =~ /encoding\(([^()]*)\)/u
1331 0 0 defined $title_rx ? :
1332 0 0 if $$$self{"verbose"}
1348 0 0 if $rx < 0 or $rx > $#$rows
1351 0 0 if not defined $cx or $cx < 0 or $cx > $#$row
1370 0 12 if defined $sheet and not &blessed($sheet) && $sheet->isa('Spreadsheet::Edit')
1387 0 0 $in_midst ? :
1394 0 0 unless defined $sheet
1398 0 0 if (length $desc > $trunclen)
1404 0 0 unless $${$_[0];}{"verbose"}
1410 0 8 if @_ > 3
1411 8 0 unless $${$_[0];}{"verbose"}
1422 0 6 if (@$cxlist) { }
1433 0 6 if ($@)
1436 0 0 unless $$$self{"debug"}
1449 0 6 unless ref $code eq "CODE"
1452 0 0 if ($_ < 0 or $_ >= $num_cols)
1463 5 1 if (defined $rxlist) { }
1465 0 5 if $rx < 0 or $rx > $#$rows
1485 0 6 if defined $$hash{"current_rx"} and $$hash{"current_rx"} > $#$rows
1598 0 0 unless @$old_colxs == $num_cols
1602 0 0 if defined $old_cx
1607 0 0 unless defined $cx
1608 0 0 if (defined(my $new_cx = $old2new{$cx})) { }
1609 0 0 if $debug
1612 0 0 if $debug
1630 0 0 unless defined $spec
1631 0 0 if ($spec eq "^")
1635 0 0 if ($spec eq "\$")
1639 0 0 if ($spec =~ /^[1-9]\d*$/u || $spec eq '0' and $spec <= $num_cols)
1644 0 0 if (defined(my $cx = $$colx{$spec}))
1648 0 0 if (ref $spec eq "Regexp")
1650 0 0 unless defined $title_rx
1658 0 0 if ($title =~ /$spec/u)
1663 0 0 unless ($matched)
1676 0 0 unless wantarray
1682 0 0 if (@list > 1)
1691 0 0 if ref $colspec eq "Regexp"
1718 0 0 if ($spec =~ /^>(.*)/u)
1727 0 0 ref $_[0] eq 'HASH' ? :
1728 0 0 if ($opthash)
1732 0 0 unless scalar @_ % 2 == 0
1745 0 0 if (my $wheredefined = $$useraliases{$ident})
1753 0 0 if $$useraliases{$ident}
1756 0 0 unless (defined $cx)
1757 0 0 unless $@
1758 0 0 unless $$opthash{"optional"} and $@ =~ /does not match/isu
1777 0 0 if ref $_[0] eq "HASH"
1829 2 6 if (@_ == 0) { }
1831 0 2 if %$opthash
1838 1 5 if &u($_[0]) eq "_notie"
1839 0 6 if @_
1841 6 0 if (defined $rx)
1842 1 5 if ($rx eq 'auto') { }
0 5 elsif (not $rx =~ /^\d+$/u) { }
0 5 elsif ($rx > $#{$$$self{'rows'};}) { }
1865 0 1 if ($#$rows == -1)
1871 0 1 $$opthash{'required'} ? :
1872 0 1 if grep {not defined $_;} @required_specs
1877 1 0 if $max_rx > $#$rows
1881 1 0 if $last_cx >= $num_cols
1884 0 1 if ($min_rx > $#$rows) { }
0 1 elsif ($min_rx > $max_rx) { }
1891 0 1 if ($first_cx >= $num_cols) { }
0 1 elsif ($first_cx > $last_cx) { }
1900 1 0 unless (@nd_reasons)
1905 0 1 if $debug and @nd_reasons
1906 0 1 if $debug
1912 0 1 unless $rx == $$$self{"title_rx"}
1916 0 2 if ($$row[$cx] eq "")
1924 0 0 if $debug
1925 0 0 if (@list == 0)
1929 0 0 if $$_[0] >= $first_cx
1931 0 0 if (@shortlist == 0)
1935 0 0 unless (grep {$$_[1] =~ /title/iu;} @shortlist)
1940 0 0 if $debug
1947 1 0 if (defined $detected) { }
1948 0 1 if ($verbose)
1957 0 0 if (@nd_reasons == 0)
1972 0 0 if (@_ == 0)
1979 0 0 if defined $rx
1986 0 0 if (@_ == 0)
1992 0 0 if (defined $rx)
1995 0 0 unless $rx >= ($$$self{"first_data_rx"} // 0)
2019 0 0 if $to_cx + @sources - @source_cxs_before > $num_cols
2049 0 0 if (not defined $title_rx and $have_new_titles)
2055 0 0 if (defined $title_rx and $row == $$rows[$title_rx]) { }
2075 0 0 unless @_ == 1
2081 0 0 defined $title_rx ? :
2087 0 0 unless defined $first_rx
2088 0 0 unless defined $last_rx
2117 0 0 if $cx > $#$row
2135 12 0 unless !!$oldval != !!$val
2136 0 0 if ($key eq 'silent') { }
0 0 elsif ($key eq 'verbose') { }
0 0 elsif ($key eq 'debug') { }
2140 0 0 if ($val) { }
2148 0 0 if ($val) { }
2168 0 0 exists $$$self{$_} ? :
2172 0 0 if (@_ == 0) { }
2173 0 0 unless wantarray
2185 0 0 unless @_ == 2
2190 0 0 if ($seen{$cx})
2234 0 0 ref $separator eq 'CODE' ? :
2251 0 0 unless scalar @_ % 2 == 0
2256 0 0 unless defined $title_rx
2266 0 0 if $cx > $#$title_row
2302 0 0 @cxs > 0 ? :
0 0 if $$$self{"verbose"}
2309 3 2 ref $_ eq 'ARRAY' ? :
2311 5 0 unless ref $_
0 5 unless @$result > 0 and not grep({$_ eq "" unless ref $_;} @$result)
2322 0 5 unless defined $rxlist_arg
2327 0 0 @cxs > 0 ? :
0 5 if $$$self{"verbose"}
2337 0 0 unless defined $exrxlist_arg
2342 0 0 @cxs > 0 ? :
0 0 if $$$self{"verbose"}
2346 0 0 if $_ < 0 or $_ > $max_rx
2368 0 0 if $$$self{"verbose"}
2374 0 0 if $old_cx >= $newcols_first_cx
2385 0 0 if $$$self{"verbose"}
2395 0 0 if $$$self{"verbose"}
2418 0 0 if ($$$self{'saved_linenums'}) { }
2443 0 0 if /^(?:LAST|\$)$/u
2445 0 0 unless $_ <= $#$rows
2448 0 0 if $$$self{"verbose"}
2451 0 0 if (defined $title_rx)
2453 0 0 if ($_ < $title_rx) { }
0 0 elsif ($_ == $title_rx) { }
2456 0 0 if $$$self{"verbose"}
2463 0 0 if (defined $first_data_rx)
2465 0 0 if ($_ <= $first_data_rx)
2469 0 0 if (defined $last_data_rx)
2471 0 0 if ($_ <= $last_data_rx)
2481 0 0 if (defined $current_rx)
2483 0 0 if $_ <= $current_rx
2513 0 0 if $rx =~ /^(?:END|\$)$/u
2516 0 0 if $$$self{"verbose"}
2520 0 0 if (defined $title_rx and $rx <= $title_rx)
2523 0 0 if (defined $first_data_rx and $rx <= $first_data_rx)
2526 0 0 if (defined $last_data_rx and $rx <= $last_data_rx)
2561 0 62 if defined $$opthash{$key}
2567 0 2 if exists $$opthash{"sheet"}
2580 0 2 if (my $enc = delete $$opthash{"encoding"})
2616 0 2 unless my $csv = "Text::CSV"->new(\%csvopts)
2640 0 2 unless close $fh
2652 0 10 if exists $$opthash{$_}
2655 1 1 exists $$opthash{'title_rx'} ? :
2663 0 2 if $$$self{"verbose"}
2672 0 0 ref $_[0] eq 'HASH' ? :
2680 0 0 if defined $$opts{$key}
2689 0 0 if %notok
2695 0 0 unless ($$opts{"iolayers"} =~ /encoding\(|:utf8/u)
2700 0 0 unless ($$opts{"iolayers"} =~ /:(?:crlf|raw)\b/u)
2709 0 0 if (&openhandle($dest)) { }
2712 0 0 if $$$self{"verbose"}
2717 0 0 if $$$self{"verbose"}
2718 0 0 if $dest =~ /\.([a-z]*)$/u and lc $1 ne "csv"
2720 0 0 unless open $fh, ">$dest"
2723 0 0 unless binmode $fh, $$opts{"iolayers"}
2762 0 0 $csvopts{'quote_char'} ne '' ? :
0 0 $csvopts{'escape_char'} ne '' && $csvopts{'escape_char'} ne "\000" ? :
2770 0 0 unless defined $value
2774 0 0 unless ($must_be_quoted)
2775 0 0 if ($value eq '') { }
2776 0 0 if $csvopts{"quote_empty"}
2778 0 0 if ($csvopts{"quote_char"} ne "")
2785 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
2790 0 0 if ($csvopts{"escape_null"})
2793 0 0 if ($must_be_quoted)
2796 0 0 unless $cx == 0
2802 0 0 unless (&openhandle($dest))
2803 0 0 unless close $fh
2816 0 0 if $$$self{"verbose"}
2822 0 0 if (ref $cf eq "HASH")
2825 0 0 if $key eq "__DEFAULT__"
2829 0 0 unless defined $_
2839 0 0 unless close $csvfh
2861 0 7 unless (defined $$$self{"current_rx"})
2864 0 0 if defined $pkg and $pkg->isa("Data::Dumper")
2874 0 9 if $mutating
2876 0 9 unless defined $sheet
2878 5 4 $onlyinapply ? :
2883 0 5 unless exists $$$sheet{$ident}
2892 0 0 if ($index_ident eq "current_rx" or $index_ident eq "title_rx")
2897 0 0 if $index > $#$aref
2902 4 0 if $mutable
2915 0 14 if index($pkg, "Spreadsheet::Edit") >= 0
2916 2 12 $$opthash{'package'} ? :
2919 12 2 if (@_) { }
2921 0 12 if @_
2922 9 3 if (defined $new)
2923 0 9 if $$$new{"cmd_nesting"}
2927 0 0 &u($curr) eq &u($new) ? :
0 12 if $verbose
2936 0 2 if $verbose
2967 0 47 unless $index >= 0 and $index <= $#$aref
2974 0 12 unless $index >= 0 and $index <= $#$aref + 1
2976 0 12 unless &Spreadsheet::Edit::__looks_like_aref($val)
2979 0 12 if grep {not defined $_;} @$val
2981 0 30 if ref $_
0 12 if grep {not &looks_like_number($_) if ref $_;} @$val
2982 0 12 if (my $num_cols = $$$sheet{"num_cols"})
2983 0 0 if @$val != $num_cols
3036 0 4 unless (defined $cx)
3037 0 0 unless exists $$colx{$key}
3042 0 0 if $mutating