Branch Coverage

blib/lib/Getopt/Long.pm
Criterion Covered Total %
branch 208 618 33.6


line true false branch
78 0 13 if (defined $ENV{'POSIXLY_CORRECT'}) { }
109 3 5 if ($_ eq ":config")
117 2 4 if @syms
121 3 3 if @config
154 1 1 if (defined $atts{'config'}) { }
164 0 2 if (%atts)
210 0 2 if $@
279 1 2 if wantarray
280 1 1 if (@$args)
302 0 20 if ($Getopt::Long::debug)
305 0 0 UNIVERSAL::isa($argv, 'ARRAY') ? :
0 0 defined $argv ? :
333 6 14 if (@optionlist and ref $optionlist[0] and UNIVERSAL::isa($optionlist[0], "HASH"))
336 0 6 if $Getopt::Long::debug
342 0 20 if (@optionlist and $optionlist[0] =~ /^\W+$/ and not $optionlist[0] eq '<>' && @optionlist > 0 && ref $optionlist[1])
350 0 0 if $Getopt::Long::debug
358 0 38 unless (defined $opt)
364 0 38 if $opt =~ /^$prefix+(.*)$/s
366 2 36 if ($opt eq "<>")
367 0 0 if (defined $userlinkage and not @optionlist > 0 && ref $optionlist[0] and exists $userlinkage->{$opt} and ref $userlinkage->{$opt})
373 0 2 unless (@optionlist > 0 and ref $optionlist[0] and ref $optionlist[0] eq "CODE")
377 0 0 if @optionlist and ref $optionlist[0]
387 0 36 unless (defined $name)
391 0 0 if @optionlist and ref $optionlist[0]
398 11 25 if (defined $userlinkage)
399 6 5 unless (@optionlist > 0 and ref $optionlist[0])
400 0 6 if (exists $userlinkage->{$orig} and ref $userlinkage->{$orig}) { }
402 0 0 if $Getopt::Long::debug
415 15 15 if (@optionlist > 0 and ref $optionlist[0]) { }
416 0 15 if $Getopt::Long::debug
420 0 15 if ($rl eq 'ARRAY') { }
0 15 elsif ($rl eq 'HASH') { }
13 2 elsif ($rl eq 'SCALAR' or $rl eq 'REF') { }
2 0 elsif ($rl eq 'CODE') { }
449 0 15 if ($opctl{$name}[3] == 1) { }
0 15 elsif ($opctl{$name}[3] == 2) { }
450 0 0 if $Getopt::Long::debug
455 0 0 if $Getopt::Long::debug
460 0 15 if $Getopt::Long::debug
466 0 0 if ($opctl{$name}[0] eq "I" and $opctl{$name}[3] == 1 || $opctl{$name}[3] == 2)
475 0 20 unless $argv and UNIVERSAL::isa($argv, "ARRAY")
479 0 20 if $Getopt::Long::error
483 0 20 defined $Getopt::Long::auto_version ? :
0 20 if (defined $Getopt::Long::auto_version ? $Getopt::Long::auto_version : $requested_version >= "2.3203")
484 0 0 unless (defined $opctl{'version'})
490 0 20 defined $Getopt::Long::auto_help ? :
0 20 if (defined $Getopt::Long::auto_help ? $Getopt::Long::auto_help : $requested_version >= "2.3203")
491 0 0 unless (defined $opctl{'help'} or defined $opctl{'?'})
499 0 20 if ($Getopt::Long::debug)
514 0 52 if $Getopt::Long::debug
517 1 51 if (defined $opt and $opt eq $argend)
518 0 1 if $Getopt::Long::passthrough
533 36 15 if ($found) { }
14 1 elsif ($Getopt::Long::order == $Getopt::Long::PERMUTE) { }
536 1 35 unless defined $opt
543 0 35 if $Getopt::Long::debug
545 0 35 if $Getopt::Long::debug
547 30 5 if (defined $linkage{$opt}) { }
0 5 elsif ($ctl->[3] == 1) { }
0 5 elsif ($ctl->[3] == 2) { }
549 0 30 if $Getopt::Long::debug
551 29 1 if (ref $linkage{$opt} eq 'SCALAR' or ref $linkage{$opt} eq 'REF') { }
0 1 elsif (ref $linkage{$opt} eq 'ARRAY') { }
0 1 elsif (ref $linkage{$opt} eq 'HASH') { }
1 0 elsif (ref $linkage{$opt} eq 'CODE') { }
553 0 29 if ($ctl->[0] eq '+') { }
0 29 elsif ($ctl->[3] == 1) { }
0 29 elsif ($ctl->[3] == 2) { }
554 0 0 if $Getopt::Long::debug
556 0 0 if (defined ${$linkage{$opt};}) { }
564 0 0 if $Getopt::Long::debug
569 0 0 if $Getopt::Long::debug
574 0 0 if $Getopt::Long::debug
579 0 0 if $Getopt::Long::debug
584 0 29 if $Getopt::Long::debug
590 0 0 if $Getopt::Long::debug
595 0 0 if $Getopt::Long::debug
600 0 0 $ctl->[3] == 2 ? :
0 1 if $Getopt::Long::debug
608 0 1 $ctl->[3] == 2 ? :
623 0 1 if $Getopt::Long::debug and $eval_error ne ""
625 0 1 if ($eval_error =~ /^!/) { }
0 1 elsif ($eval_error ne '') { }
626 0 0 if ($eval_error =~ /^!FINISH\b/)
643 0 0 if (defined $userlinkage->{$opt}) { }
644 0 0 if $Getopt::Long::debug
649 0 0 if $Getopt::Long::debug
655 0 0 if (defined $userlinkage->{$opt}) { }
656 0 0 if $Getopt::Long::debug
661 0 0 if $Getopt::Long::debug
667 0 5 if ($ctl->[0] eq '+') { }
668 0 0 if $Getopt::Long::debug
670 0 0 if (defined $userlinkage->{$opt}) { }
678 0 5 if $Getopt::Long::debug
684 35 0 if $argcnt >= $ctl->[5] and $ctl->[5] != -1
688 0 0 if ($argcnt < $ctl->[4])
689 0 0 if (@$argv) { }
690 0 0 if (&ValidValue($ctl, $argv->[0], 1, $argend, $prefix))
692 0 0 if ($ctl->[0] =~ /^[iIo]$/)
694 0 0 $ctl->[0] eq 'o' && $arg =~ /^0/ ? :
698 0 0 if $ctl->[3] == 2
712 0 0 if (@$argv and &ValidValue($ctl, $argv->[0], 0, $argend, $prefix))
714 0 0 if ($ctl->[0] =~ /^[iIo]$/)
716 0 0 $ctl->[0] eq 'o' && $arg =~ /^0/ ? :
720 0 0 if $ctl->[3] == 2
731 3 11 if (defined($cb = $linkage{'<>'})) { }
732 0 3 if $Getopt::Long::debug
746 0 3 if $Getopt::Long::debug and $eval_error ne ""
748 0 3 if ($eval_error =~ /^!/) { }
0 3 elsif ($eval_error ne '') { }
749 0 0 if ($eval_error =~ /^!FINISH\b/)
759 0 11 if $Getopt::Long::debug
776 9 0 if (@ret and $Getopt::Long::order == $Getopt::Long::PERMUTE || $Getopt::Long::passthrough)
778 0 9 if $Getopt::Long::debug
789 0 0 defined $_ ? :
808 0 36 unless ($opt =~ m[^ ( # Option name (?: \w+[-\w]* ) # Aliases (?: \| (?: . [^|!+=:]* )? )* )? ( # Either modifiers ... [!+] | # ... or a value/dest/repeat specification [=:] [ionfs] [\@%]? (?: \{\d*,?\d*\} )? | # ... or an optional-with-default spec : (?: -?\d+ | \+ ) [\@%]? )? $]x)
830 15 21 unless defined $spec
841 36 0 if (defined $names) { }
852 19 17 if ($spec eq '' or $spec eq '+' or $spec eq '!') { }
0 17 elsif ($spec =~ /^:(-?\d+|\+)([\@%])?$/) { }
859 0 0 $def eq '+' ? :
861 0 0 $dest eq '%' ? :
0 0 $dest eq '@' ? :
864 0 0 $def eq '+' ? :
870 0 17 if $Getopt::Long::bundling and defined $4
873 0 0 if defined $mi and not $mi and not defined $ma and not defined $cm
876 0 17 if $type eq "n"
878 0 17 $dest eq '%' ? :
0 17 $dest eq '@' ? :
881 15 2 $mand eq '=' ? :
17 0 unless defined $mi
883 15 2 $mi ? :
885 15 2 $mi ? :
17 0 unless defined $ma or defined $cm
886 0 17 if defined $ma and not $ma
888 0 17 if defined $ma and $ma < $mi
899 0 36 $Getopt::Long::bundling && length $_ == 1 ? :
10 26 if $Getopt::Long::ignorecase > ($Getopt::Long::bundling && length $_ == 1 ? 1 : 0)
902 0 36 if (exists $opctl->{$_})
906 4 32 if ($spec eq '!') { }
917 0 0 if ($dups and $^W)
934 0 51 if $Getopt::Long::debug
936 0 51 unless defined $opt
937 12 39 unless $opt =~ /^($prefix)(.*)$/s
938 0 39 if $opt eq "-" and not defined $opctl->{''}
943 0 39 if $Getopt::Long::debug
950 3 36 if ($starter =~ /^$Getopt::Long::longprefix$/ || $Getopt::Long::getopt_compat && ($Getopt::Long::bundling == 0 || $Getopt::Long::bundling == 2) and (my $oppos = index($opt, "=", 1)) > 0)
956 0 3 if $Getopt::Long::debug
964 0 39 if ($Getopt::Long::bundling || $bundling_values and $starter eq '-') { }
39 0 elsif ($Getopt::Long::autoabbrev and $opt ne '') { }
0 0 elsif ($Getopt::Long::ignorecase) { }
967 0 0 $Getopt::Long::ignorecase ? :
970 0 0 if ($Getopt::Long::bundling == 2 and length $tryopt > 1 and defined $opctl->{$tryopt}) { }
0 0 elsif ($bundling_values) { }
972 0 0 if $Getopt::Long::debug
980 0 0 length $tryopt > 0 ? :
982 0 0 if $Getopt::Long::ignorecase > 1
983 0 0 if $Getopt::Long::debug
986 0 0 $rest eq '' ? :
995 0 0 length $tryopt > 0 ? :
997 0 0 if $Getopt::Long::ignorecase > 1
998 0 0 if $Getopt::Long::debug
1000 0 0 unless $rest ne ""
1009 10 29 if $Getopt::Long::ignorecase
1015 0 39 if $Getopt::Long::debug
1019 0 39 unless (@hits <= 1 or grep(($_ eq $opt), @hits) == 1)
1024 0 0 if defined $opctl->{$_}[1]
1025 0 0 if $opctl->{$_}[0] eq "!"
1029 0 0 if (keys %hit == 2)
1030 0 0 if ($Getopt::Long::auto_version and exists $hit{'version'}) { }
0 0 elsif ($Getopt::Long::auto_help and exists $hit{'help'}) { }
1038 0 0 unless (keys %hit == 1)
1039 0 0 if $Getopt::Long::passthrough
1049 0 39 if (@hits == 1 and $hits[0] ne $opt)
1051 0 0 $Getopt::Long::bundling && length $tryopt == 1 ? :
0 0 if $Getopt::Long::ignorecase > ($Getopt::Long::bundling && length $tryopt == 1 ? 1 : 0)
1053 0 0 if $Getopt::Long::debug
1065 4 35 unless (defined $ctl)
1066 3 1 if $Getopt::Long::passthrough
1068 1 0 if ($Getopt::Long::bundling == 1 and length $starter == 1)
1070 0 1 if defined $rest
1072 0 1 if ($opt eq '') { }
1083 0 35 if $Getopt::Long::debug
1092 3 17 if ($type eq "" or $type eq "!" or $type eq "+")
1093 0 18 if (defined $optarg) { }
15 3 elsif ($type eq '' or $type eq '+') { }
1094 0 0 if $Getopt::Long::passthrough
1098 0 0 if $bundling_values
1108 0 18 if defined $rest
1116 0 17 if ($Getopt::Long::gnu_compat)
1118 0 0 if (defined $optarg) { }
0 0 elsif (defined $rest or @$argv > 0) { }
1119 0 0 length $optarg == 0 ? :
1127 0 0 if ($optargtype == 0 and not $mand)
1128 0 0 if ($type eq "I")
1134 0 0 $type eq 's' ? :
0 0 defined $ctl->[2] ? :
1140 0 0 $type eq 's' ? :
0 0 if $optargtype == 1
1145 3 14 defined $optarg ? :
0 17 if (defined $optarg ? $optarg eq "" : !(defined $rest || @$argv > 0))
1150 0 0 if ($mand or $ctl->[3] == 2)
1151 0 0 if $Getopt::Long::passthrough
1156 0 0 if ($type eq "I")
1162 0 0 $type eq 's' ? :
0 0 defined $ctl->[2] ? :
1168 3 14 defined $optarg ? :
0 17 defined $rest ? :
1173 0 17 if ($ctl->[3] == 2 and defined $arg)
1174 0 0 $type eq 's' ? :
0 0 $mand ? :
0 0 defined $ctl->[2] ? :
0 0 $arg =~ /^([^=]*)=(.*)$/s ? :
1177 0 0 unless (defined $arg)
1181 0 0 if defined $rest
1188 0 17 $ctl->[3] == 2 ? :
1190 15 2 if ($type eq 's') { }
2 0 elsif ($type eq 'i' or $type eq 'I' or $type eq 'o') { }
0 0 elsif ($type eq 'f') { }
1192 14 1 if $mand
1195 0 1 if $ctl->[3] == 2
1199 0 1 if defined $optarg or defined $rest
1201 0 1 if $arg eq "-"
1204 0 1 if ($arg eq $argend or $arg =~ /^$prefix.+/)
1217 0 2 $type eq 'o' ? :
1219 0 2 if ($Getopt::Long::bundling and defined $rest and $rest =~ /^($key_valid)($o_valid)(.*)$/is) { }
2 0 elsif ($arg =~ /^$o_valid$/is) { }
1222 0 0 if $key
1223 0 0 $type eq 'o' && $arg =~ /^0/ ? :
1224 0 0 if defined $rest and $rest ne ""
1228 0 2 $type eq 'o' && $arg =~ /^0/ ? :
1231 0 0 if (defined $optarg or $mand) { }
1232 0 0 if ($Getopt::Long::passthrough)
1233 0 0 defined $rest ? :
0 0 unless defined $optarg
1237 0 0 $type eq 'o' ? :
1243 0 0 if defined $rest
1248 0 0 defined $rest ? :
1249 0 0 if ($type eq "I")
1256 0 0 defined $ctl->[2] ? :
1263 0 0 if ($Getopt::Long::bundling and defined $rest and $rest =~ /^($key_valid)($o_valid)(.*)$/s) { }
0 0 elsif ($arg =~ /^$o_valid$/) { }
1267 0 0 if $key
1268 0 0 if defined $rest and $rest ne ""
1274 0 0 if (defined $optarg or $mand) { }
1275 0 0 if ($Getopt::Long::passthrough)
1276 0 0 defined $rest ? :
0 0 unless defined $optarg
1284 0 0 if defined $rest
1289 0 0 defined $rest ? :
1304 0 0 if ($ctl->[3] == 2)
1305 0 0 unless $arg =~ /[^=]+=(.*)/
1311 0 0 if ($type eq 's') { }
0 0 elsif ($type eq 'i' or $type eq 'I' or $type eq 'o') { }
0 0 elsif ($type eq 'f') { }
1313 0 0 if $mand
1315 0 0 if $arg eq "-"
1318 0 0 if $arg eq $argend or $arg =~ /^$prefix.+/
1326 0 0 $type eq 'o' ? :
1347 6 19 if (ref $options[0] eq "ARRAY")
1358 6 20 if ($try =~ /^no_?(.*)$/s)
1362 7 19 if ($try eq 'default' || $try eq 'defaults' and $action) { }
0 19 elsif ($try eq 'posix_default' or $try eq 'posix_defaults') { }
0 19 elsif ($try eq 'auto_abbrev' or $try eq 'autoabbrev') { }
0 19 elsif ($try eq 'getopt_compat') { }
0 19 elsif ($try eq 'gnu_getopt') { }
0 19 elsif ($try eq 'gnu_compat') { }
0 19 elsif ($try =~ /^(auto_?)?version$/) { }
0 19 elsif ($try =~ /^(auto_?)?help$/) { }
6 13 elsif ($try eq 'ignorecase' or $try eq 'ignore_case') { }
2 11 elsif ($try eq 'ignorecase_always' or $try eq 'ignore_case_always') { }
2 9 elsif ($try eq 'bundling') { }
0 9 elsif ($try eq 'bundling_override') { }
0 9 elsif ($try eq 'bundling_values') { }
1 8 elsif ($try eq 'require_order') { }
0 8 elsif ($try eq 'permute') { }
2 6 elsif ($try eq 'pass_through' or $try eq 'passthrough') { }
0 6 elsif ($try =~ /^prefix=(.+)$/ and $action) { }
3 3 elsif ($try =~ /^prefix_pattern=(.+)$/ and $action) { }
3 0 elsif ($try =~ /^long_prefix_pattern=(.+)$/ and $action) { }
0 0 elsif ($try eq 'debug') { }
1367 0 0 if $action
1375 0 0 $action ? :
1378 0 0 if ($action)
1402 2 0 $action ? :
1406 2 0 if $action
1409 0 0 $action ? :
1410 0 0 if $action
1414 0 0 if $action
1417 1 0 $action ? :
1420 0 0 $action ? :
1430 0 0 if $@
1435 3 0 unless $Getopt::Long::genprefix =~ /^\(.*\)$/
1438 0 3 if $@
1443 3 0 unless $Getopt::Long::longprefix =~ /^\(.*\)$/
1446 0 3 if $@
1479 0 0 defined $pa->{'-message'} ? :
0 0 defined $v ? :
0 0 defined $Getopt::Long::VERSION_STRING ? :
0 0 $] >= 5.006 ? :
1489 0 0 unless $pa->{'-exitval'} eq "NOEXIT"
1501 0 0 unless eval { do { require Pod::Usage; "Pod::Usage"->import; 1 } }
1519 0 0 if @_ == 2 and $_[0] eq $tag
1522 0 0 if (@_ > 1) { }
1532 0 0 if (UNIVERSAL::isa($pa, 'HASH')) { }
0 0 elsif ($pa =~ /^-?\d+$/) { }
1544 0 0 unless exists $pa->{'-verbose'}
1545 0 0 unless exists $pa->{'-exitval'}
1551 0 0 if @_ > 1