Branch Coverage

blib/lib/Getopt/Long.pm
Criterion Covered Total %
branch 208 624 33.3


line true false branch
80 0 13 if (defined $ENV{'POSIXLY_CORRECT'}) { }
111 3 5 if ($_ eq ":config")
119 2 4 if @syms
123 3 3 if @config
156 1 1 if (defined $atts{'config'}) { }
166 0 2 if (%atts)
212 0 2 if $@
281 1 2 if wantarray
282 1 1 if (@$args)
304 0 20 if ($Getopt::Long::debug)
307 0 0 UNIVERSAL::isa($argv, 'ARRAY') ? :
0 0 defined $argv ? :
335 6 14 if (@optionlist and ref $optionlist[0] and UNIVERSAL::isa($optionlist[0], "HASH"))
338 0 6 if $Getopt::Long::debug
344 0 20 if (@optionlist and $optionlist[0] =~ /^\W+$/ and not $optionlist[0] eq '<>' && @optionlist > 0 && ref $optionlist[1])
352 0 0 if $Getopt::Long::debug
360 0 38 unless (defined $opt)
366 0 38 if $opt =~ /^$prefix+(.*)$/s
368 2 36 if ($opt eq "<>")
369 0 0 if (defined $userlinkage and not @optionlist > 0 && ref $optionlist[0] and exists $userlinkage->{$opt} and ref $userlinkage->{$opt})
375 0 2 unless (@optionlist > 0 and ref $optionlist[0] and ref $optionlist[0] eq "CODE")
379 0 0 if @optionlist and ref $optionlist[0]
389 0 36 unless (defined $name)
393 0 0 if @optionlist and ref $optionlist[0]
400 11 25 if (defined $userlinkage)
401 6 5 unless (@optionlist > 0 and ref $optionlist[0])
402 0 6 if (exists $userlinkage->{$orig} and ref $userlinkage->{$orig}) { }
404 0 0 if $Getopt::Long::debug
417 15 15 if (@optionlist > 0 and ref $optionlist[0]) { }
418 0 15 if $Getopt::Long::debug
422 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') { }
451 0 15 if ($opctl{$name}[3] == 1) { }
0 15 elsif ($opctl{$name}[3] == 2) { }
452 0 0 if $Getopt::Long::debug
457 0 0 if $Getopt::Long::debug
462 0 15 if $Getopt::Long::debug
468 0 0 if ($opctl{$name}[0] eq "I" and $opctl{$name}[3] == 1 || $opctl{$name}[3] == 2)
477 0 20 unless $argv and UNIVERSAL::isa($argv, "ARRAY")
481 0 20 if $Getopt::Long::error
485 0 20 defined $Getopt::Long::auto_version ? :
0 20 if (defined $Getopt::Long::auto_version ? $Getopt::Long::auto_version : $requested_version >= "2.3203")
486 0 0 unless (defined $opctl{'version'})
492 0 20 defined $Getopt::Long::auto_help ? :
0 20 if (defined $Getopt::Long::auto_help ? $Getopt::Long::auto_help : $requested_version >= "2.3203")
493 0 0 unless (defined $opctl{'help'} or defined $opctl{'?'})
501 0 20 if ($Getopt::Long::debug)
516 0 52 if $Getopt::Long::debug
519 1 51 if (defined $opt and $opt eq $argend)
520 0 1 if $Getopt::Long::passthrough
535 36 15 if ($found) { }
14 1 elsif ($Getopt::Long::order == $Getopt::Long::PERMUTE) { }
538 1 35 unless defined $opt
545 0 35 if $Getopt::Long::debug
547 0 35 if $Getopt::Long::debug
549 30 5 if (defined $linkage{$opt}) { }
0 5 elsif ($ctl->[3] == 1) { }
0 5 elsif ($ctl->[3] == 2) { }
551 0 30 if $Getopt::Long::debug
553 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') { }
555 0 29 if ($ctl->[0] eq '+') { }
0 29 elsif ($ctl->[3] == 1) { }
0 29 elsif ($ctl->[3] == 2) { }
556 0 0 if $Getopt::Long::debug
558 0 0 if (defined ${$linkage{$opt};}) { }
566 0 0 if $Getopt::Long::debug
571 0 0 if $Getopt::Long::debug
576 0 0 if $Getopt::Long::debug
581 0 0 if $Getopt::Long::debug
586 0 29 if $Getopt::Long::debug
592 0 0 if $Getopt::Long::debug
597 0 0 if $Getopt::Long::debug
602 0 0 $ctl->[3] == 2 ? :
0 1 if $Getopt::Long::debug
610 0 1 $ctl->[3] == 2 ? :
625 0 1 if $Getopt::Long::debug and $eval_error ne ""
627 0 1 if ($eval_error =~ /^!/) { }
0 1 elsif ($eval_error ne '') { }
628 0 0 if ($eval_error =~ /^!FINISH\b/)
645 0 0 if (defined $userlinkage->{$opt}) { }
646 0 0 if $Getopt::Long::debug
651 0 0 if $Getopt::Long::debug
657 0 0 if (defined $userlinkage->{$opt}) { }
658 0 0 if $Getopt::Long::debug
663 0 0 if $Getopt::Long::debug
669 0 5 if ($ctl->[0] eq '+') { }
670 0 0 if $Getopt::Long::debug
672 0 0 if (defined $userlinkage->{$opt}) { }
680 0 5 if $Getopt::Long::debug
686 35 0 if $argcnt >= $ctl->[5] and $ctl->[5] != -1
690 0 0 if ($argcnt < $ctl->[4])
691 0 0 if (@$argv) { }
692 0 0 if (&ValidValue($ctl, $argv->[0], 1, $argend, $prefix))
694 0 0 if ($ctl->[0] =~ /^[iIo]$/)
696 0 0 $ctl->[0] eq 'o' && $arg =~ /^0/ ? :
700 0 0 if $ctl->[3] == 2
714 0 0 if (@$argv and &ValidValue($ctl, $argv->[0], 0, $argend, $prefix))
716 0 0 if ($ctl->[0] =~ /^[iIo]$/)
718 0 0 $ctl->[0] eq 'o' && $arg =~ /^0/ ? :
722 0 0 if $ctl->[3] == 2
733 3 11 if (defined($cb = $linkage{'<>'})) { }
734 0 3 if $Getopt::Long::debug
748 0 3 if $Getopt::Long::debug and $eval_error ne ""
750 0 3 if ($eval_error =~ /^!/) { }
0 3 elsif ($eval_error ne '') { }
751 0 0 if ($eval_error =~ /^!FINISH\b/)
761 0 11 if $Getopt::Long::debug
778 9 0 if (@ret and $Getopt::Long::order == $Getopt::Long::PERMUTE || $Getopt::Long::passthrough)
780 0 9 if $Getopt::Long::debug
791 0 0 defined $_ ? :
810 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 : (?: 0[0-7]+ | 0[xX][0-9a-fA-F]+ | 0[bB][01]+ | -?\d+ | \+ ) [\@%]? )? $]x)
832 15 21 unless defined $spec
843 36 0 if (defined $names) { }
854 19 17 if ($spec eq '' or $spec eq '+' or $spec eq '!') { }
0 17 elsif ($spec =~ /^:(0[0-7]+|0x[0-9a-f]+|0b[01]+|-?\d+|\+)([\@%])?$/i) { }
862 0 0 if ($def eq '+') { }
0 0 elsif ($def =~ /^(0[0-7]+|0[xX][0-9a-fA-F]+|0[bB][01]+)$/) { }
0 0 elsif ($def =~ /^-?\d+$/) { }
876 0 0 $dest eq '%' ? :
0 0 $dest eq '@' ? :
879 0 0 $def eq '+' ? :
885 0 17 if $Getopt::Long::bundling and defined $4
888 0 0 if defined $mi and not $mi and not defined $ma and not defined $cm
891 0 17 if $type eq "n"
893 0 17 $dest eq '%' ? :
0 17 $dest eq '@' ? :
896 15 2 $mand eq '=' ? :
17 0 unless defined $mi
898 15 2 $mi ? :
900 15 2 $mi ? :
17 0 unless defined $ma or defined $cm
901 0 17 if defined $ma and not $ma
903 0 17 if defined $ma and $ma < $mi
914 0 36 $Getopt::Long::bundling && length $_ == 1 ? :
10 26 if $Getopt::Long::ignorecase > ($Getopt::Long::bundling && length $_ == 1 ? 1 : 0)
917 0 36 if (exists $opctl->{$_})
921 4 32 if ($spec eq '!') { }
932 0 0 if ($dups and $^W)
949 0 51 if $Getopt::Long::debug
951 0 51 unless defined $opt
952 12 39 unless $opt =~ /^($prefix)(.*)$/s
953 0 39 if $opt eq "-" and not defined $opctl->{''}
958 0 39 if $Getopt::Long::debug
965 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)
971 0 3 if $Getopt::Long::debug
979 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) { }
982 0 0 $Getopt::Long::ignorecase ? :
985 0 0 if ($Getopt::Long::bundling == 2 and length $tryopt > 1 and defined $opctl->{$tryopt}) { }
0 0 elsif ($bundling_values) { }
987 0 0 if $Getopt::Long::debug
995 0 0 length $tryopt > 0 ? :
997 0 0 if $Getopt::Long::ignorecase > 1
998 0 0 if $Getopt::Long::debug
1001 0 0 $rest eq '' ? :
1010 0 0 length $tryopt > 0 ? :
1012 0 0 if $Getopt::Long::ignorecase > 1
1013 0 0 if $Getopt::Long::debug
1015 0 0 unless $rest ne ""
1024 10 29 if $Getopt::Long::ignorecase
1030 0 39 if $Getopt::Long::debug
1034 0 39 unless (@hits <= 1 or grep(($_ eq $opt), @hits) == 1)
1039 0 0 if defined $opctl->{$_}[1]
1040 0 0 if $opctl->{$_}[0] eq "!"
1044 0 0 if (keys %hit == 2)
1045 0 0 if ($Getopt::Long::auto_version and exists $hit{'version'}) { }
0 0 elsif ($Getopt::Long::auto_help and exists $hit{'help'}) { }
1053 0 0 unless (keys %hit == 1)
1054 0 0 if $Getopt::Long::passthrough
1064 0 39 if (@hits == 1 and $hits[0] ne $opt)
1066 0 0 $Getopt::Long::bundling && length $tryopt == 1 ? :
0 0 if $Getopt::Long::ignorecase > ($Getopt::Long::bundling && length $tryopt == 1 ? 1 : 0)
1068 0 0 if $Getopt::Long::debug
1080 4 35 unless (defined $ctl)
1081 3 1 if $Getopt::Long::passthrough
1083 1 0 if ($Getopt::Long::bundling == 1 and length $starter == 1)
1085 0 1 if defined $rest
1087 0 1 if ($opt eq '') { }
1098 0 35 if $Getopt::Long::debug
1107 3 17 if ($type eq "" or $type eq "!" or $type eq "+")
1108 0 18 if (defined $optarg) { }
15 3 elsif ($type eq '' or $type eq '+') { }
1109 0 0 if $Getopt::Long::passthrough
1113 0 0 if $bundling_values
1123 0 18 if defined $rest
1131 0 17 if ($Getopt::Long::gnu_compat)
1133 0 0 if (defined $optarg) { }
0 0 elsif (defined $rest or @$argv > 0) { }
1134 0 0 length $optarg == 0 ? :
1142 0 0 if ($optargtype == 0 and not $mand)
1143 0 0 if ($type eq "I")
1149 0 0 $type eq 's' ? :
0 0 defined $ctl->[2] ? :
1155 0 0 $type eq 's' ? :
0 0 if $optargtype == 1
1160 3 14 defined $optarg ? :
0 17 if (defined $optarg ? $optarg eq "" : !(defined $rest || @$argv > 0))
1165 0 0 if ($mand or $ctl->[3] == 2)
1166 0 0 if $Getopt::Long::passthrough
1171 0 0 if ($type eq "I")
1177 0 0 $type eq 's' ? :
0 0 defined $ctl->[2] ? :
1183 3 14 defined $optarg ? :
0 17 defined $rest ? :
1188 0 17 if ($ctl->[3] == 2 and defined $arg)
1189 0 0 $type eq 's' ? :
0 0 $mand ? :
0 0 defined $ctl->[2] ? :
0 0 $arg =~ /^([^=]*)=(.*)$/s ? :
1192 0 0 unless (defined $arg)
1196 0 0 if defined $rest
1203 0 17 $ctl->[3] == 2 ? :
1205 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') { }
1207 14 1 if $mand
1210 0 1 if $ctl->[3] == 2
1214 0 1 if defined $optarg or defined $rest
1216 0 1 if $arg eq "-"
1219 0 1 if ($arg eq $argend or $arg =~ /^$prefix.+/)
1232 0 2 $type eq 'o' ? :
1234 0 2 if ($Getopt::Long::bundling and defined $rest and $rest =~ /^($key_valid)($o_valid)(.*)$/is) { }
2 0 elsif ($arg =~ /^$o_valid$/is) { }
1237 0 0 if $key
1238 0 0 $type eq 'o' && $arg =~ /^0/ ? :
1239 0 0 if defined $rest and $rest ne ""
1243 0 2 $type eq 'o' && $arg =~ /^0/ ? :
1246 0 0 if (defined $optarg or $mand) { }
1247 0 0 if ($Getopt::Long::passthrough)
1248 0 0 defined $rest ? :
0 0 unless defined $optarg
1252 0 0 $type eq 'o' ? :
1258 0 0 if defined $rest
1263 0 0 defined $rest ? :
1264 0 0 if ($type eq "I")
1271 0 0 defined $ctl->[2] ? :
1278 0 0 if ($Getopt::Long::bundling and defined $rest and $rest =~ /^($key_valid)($o_valid)(.*)$/s) { }
0 0 elsif ($arg =~ /^$o_valid$/) { }
1282 0 0 if $key
1283 0 0 if defined $rest and $rest ne ""
1289 0 0 if (defined $optarg or $mand) { }
1290 0 0 if ($Getopt::Long::passthrough)
1291 0 0 defined $rest ? :
0 0 unless defined $optarg
1299 0 0 if defined $rest
1304 0 0 defined $rest ? :
1319 0 0 if ($ctl->[3] == 2)
1320 0 0 unless $arg =~ /[^=]+=(.*)/
1326 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') { }
1328 0 0 if $mand
1330 0 0 if $arg eq "-"
1333 0 0 if $arg eq $argend or $arg =~ /^$prefix.+/
1341 0 0 $type eq 'o' ? :
1362 6 19 if (ref $options[0] eq "ARRAY")
1373 6 20 if ($try =~ /^no_?(.*)$/s)
1377 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') { }
1382 0 0 if $action
1390 0 0 $action ? :
1393 0 0 if ($action)
1417 2 0 $action ? :
1421 2 0 if $action
1424 0 0 $action ? :
1425 0 0 if $action
1429 0 0 if $action
1432 1 0 $action ? :
1435 0 0 $action ? :
1445 0 0 if $@
1450 3 0 unless $Getopt::Long::genprefix =~ /^\(.*\)$/
1453 0 3 if $@
1458 3 0 unless $Getopt::Long::longprefix =~ /^\(.*\)$/
1461 0 3 if $@
1494 0 0 defined $pa->{'-message'} ? :
0 0 defined $v ? :
0 0 defined $Getopt::Long::VERSION_STRING ? :
0 0 $] >= 5.006 ? :
1504 0 0 unless $pa->{'-exitval'} eq "NOEXIT"
1516 0 0 unless eval { do { require Pod::Usage; "Pod::Usage"->import; 1 } }
1534 0 0 if @_ == 2 and $_[0] eq $tag
1537 0 0 if (@_ > 1) { }
1547 0 0 if (UNIVERSAL::isa($pa, 'HASH')) { }
0 0 elsif ($pa =~ /^-?\d+$/) { }
1549 0 0 unless (defined $pa->{'-message'})
1561 0 0 unless exists $pa->{'-verbose'}
1562 0 0 unless exists $pa->{'-exitval'}
1568 0 0 if @_ > 1