Branch Coverage

blib/lib/Getopt/Long.pm
Criterion Covered Total %
branch 208 622 33.4


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 : (?: 0[0-7]+ | 0[xX][0-9a-fA-F]+ | 0[bB][01]+ | -?\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 =~ /^:(0[0-7]+|0x[0-9a-f]+|0b[01]+|-?\d+|\+)([\@%])?$/i) { }
860 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+$/) { }
874 0 0 $dest eq '%' ? :
0 0 $dest eq '@' ? :
877 0 0 $def eq '+' ? :
883 0 17 if $Getopt::Long::bundling and defined $4
886 0 0 if defined $mi and not $mi and not defined $ma and not defined $cm
889 0 17 if $type eq "n"
891 0 17 $dest eq '%' ? :
0 17 $dest eq '@' ? :
894 15 2 $mand eq '=' ? :
17 0 unless defined $mi
896 15 2 $mi ? :
898 15 2 $mi ? :
17 0 unless defined $ma or defined $cm
899 0 17 if defined $ma and not $ma
901 0 17 if defined $ma and $ma < $mi
912 0 36 $Getopt::Long::bundling && length $_ == 1 ? :
10 26 if $Getopt::Long::ignorecase > ($Getopt::Long::bundling && length $_ == 1 ? 1 : 0)
915 0 36 if (exists $opctl->{$_})
919 4 32 if ($spec eq '!') { }
930 0 0 if ($dups and $^W)
947 0 51 if $Getopt::Long::debug
949 0 51 unless defined $opt
950 12 39 unless $opt =~ /^($prefix)(.*)$/s
951 0 39 if $opt eq "-" and not defined $opctl->{''}
956 0 39 if $Getopt::Long::debug
963 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)
969 0 3 if $Getopt::Long::debug
977 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) { }
980 0 0 $Getopt::Long::ignorecase ? :
983 0 0 if ($Getopt::Long::bundling == 2 and length $tryopt > 1 and defined $opctl->{$tryopt}) { }
0 0 elsif ($bundling_values) { }
985 0 0 if $Getopt::Long::debug
993 0 0 length $tryopt > 0 ? :
995 0 0 if $Getopt::Long::ignorecase > 1
996 0 0 if $Getopt::Long::debug
999 0 0 $rest eq '' ? :
1008 0 0 length $tryopt > 0 ? :
1010 0 0 if $Getopt::Long::ignorecase > 1
1011 0 0 if $Getopt::Long::debug
1013 0 0 unless $rest ne ""
1022 10 29 if $Getopt::Long::ignorecase
1028 0 39 if $Getopt::Long::debug
1032 0 39 unless (@hits <= 1 or grep(($_ eq $opt), @hits) == 1)
1037 0 0 if defined $opctl->{$_}[1]
1038 0 0 if $opctl->{$_}[0] eq "!"
1042 0 0 if (keys %hit == 2)
1043 0 0 if ($Getopt::Long::auto_version and exists $hit{'version'}) { }
0 0 elsif ($Getopt::Long::auto_help and exists $hit{'help'}) { }
1051 0 0 unless (keys %hit == 1)
1052 0 0 if $Getopt::Long::passthrough
1062 0 39 if (@hits == 1 and $hits[0] ne $opt)
1064 0 0 $Getopt::Long::bundling && length $tryopt == 1 ? :
0 0 if $Getopt::Long::ignorecase > ($Getopt::Long::bundling && length $tryopt == 1 ? 1 : 0)
1066 0 0 if $Getopt::Long::debug
1078 4 35 unless (defined $ctl)
1079 3 1 if $Getopt::Long::passthrough
1081 1 0 if ($Getopt::Long::bundling == 1 and length $starter == 1)
1083 0 1 if defined $rest
1085 0 1 if ($opt eq '') { }
1096 0 35 if $Getopt::Long::debug
1105 3 17 if ($type eq "" or $type eq "!" or $type eq "+")
1106 0 18 if (defined $optarg) { }
15 3 elsif ($type eq '' or $type eq '+') { }
1107 0 0 if $Getopt::Long::passthrough
1111 0 0 if $bundling_values
1121 0 18 if defined $rest
1129 0 17 if ($Getopt::Long::gnu_compat)
1131 0 0 if (defined $optarg) { }
0 0 elsif (defined $rest or @$argv > 0) { }
1132 0 0 length $optarg == 0 ? :
1140 0 0 if ($optargtype == 0 and not $mand)
1141 0 0 if ($type eq "I")
1147 0 0 $type eq 's' ? :
0 0 defined $ctl->[2] ? :
1153 0 0 $type eq 's' ? :
0 0 if $optargtype == 1
1158 3 14 defined $optarg ? :
0 17 if (defined $optarg ? $optarg eq "" : !(defined $rest || @$argv > 0))
1163 0 0 if ($mand or $ctl->[3] == 2)
1164 0 0 if $Getopt::Long::passthrough
1169 0 0 if ($type eq "I")
1175 0 0 $type eq 's' ? :
0 0 defined $ctl->[2] ? :
1181 3 14 defined $optarg ? :
0 17 defined $rest ? :
1186 0 17 if ($ctl->[3] == 2 and defined $arg)
1187 0 0 $type eq 's' ? :
0 0 $mand ? :
0 0 defined $ctl->[2] ? :
0 0 $arg =~ /^([^=]*)=(.*)$/s ? :
1190 0 0 unless (defined $arg)
1194 0 0 if defined $rest
1201 0 17 $ctl->[3] == 2 ? :
1203 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') { }
1205 14 1 if $mand
1208 0 1 if $ctl->[3] == 2
1212 0 1 if defined $optarg or defined $rest
1214 0 1 if $arg eq "-"
1217 0 1 if ($arg eq $argend or $arg =~ /^$prefix.+/)
1230 0 2 $type eq 'o' ? :
1232 0 2 if ($Getopt::Long::bundling and defined $rest and $rest =~ /^($key_valid)($o_valid)(.*)$/is) { }
2 0 elsif ($arg =~ /^$o_valid$/is) { }
1235 0 0 if $key
1236 0 0 $type eq 'o' && $arg =~ /^0/ ? :
1237 0 0 if defined $rest and $rest ne ""
1241 0 2 $type eq 'o' && $arg =~ /^0/ ? :
1244 0 0 if (defined $optarg or $mand) { }
1245 0 0 if ($Getopt::Long::passthrough)
1246 0 0 defined $rest ? :
0 0 unless defined $optarg
1250 0 0 $type eq 'o' ? :
1256 0 0 if defined $rest
1261 0 0 defined $rest ? :
1262 0 0 if ($type eq "I")
1269 0 0 defined $ctl->[2] ? :
1276 0 0 if ($Getopt::Long::bundling and defined $rest and $rest =~ /^($key_valid)($o_valid)(.*)$/s) { }
0 0 elsif ($arg =~ /^$o_valid$/) { }
1280 0 0 if $key
1281 0 0 if defined $rest and $rest ne ""
1287 0 0 if (defined $optarg or $mand) { }
1288 0 0 if ($Getopt::Long::passthrough)
1289 0 0 defined $rest ? :
0 0 unless defined $optarg
1297 0 0 if defined $rest
1302 0 0 defined $rest ? :
1317 0 0 if ($ctl->[3] == 2)
1318 0 0 unless $arg =~ /[^=]+=(.*)/
1324 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') { }
1326 0 0 if $mand
1328 0 0 if $arg eq "-"
1331 0 0 if $arg eq $argend or $arg =~ /^$prefix.+/
1339 0 0 $type eq 'o' ? :
1360 6 19 if (ref $options[0] eq "ARRAY")
1371 6 20 if ($try =~ /^no_?(.*)$/s)
1375 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') { }
1380 0 0 if $action
1388 0 0 $action ? :
1391 0 0 if ($action)
1415 2 0 $action ? :
1419 2 0 if $action
1422 0 0 $action ? :
1423 0 0 if $action
1427 0 0 if $action
1430 1 0 $action ? :
1433 0 0 $action ? :
1443 0 0 if $@
1448 3 0 unless $Getopt::Long::genprefix =~ /^\(.*\)$/
1451 0 3 if $@
1456 3 0 unless $Getopt::Long::longprefix =~ /^\(.*\)$/
1459 0 3 if $@
1492 0 0 defined $pa->{'-message'} ? :
0 0 defined $v ? :
0 0 defined $Getopt::Long::VERSION_STRING ? :
0 0 $] >= 5.006 ? :
1502 0 0 unless $pa->{'-exitval'} eq "NOEXIT"
1514 0 0 unless eval { do { require Pod::Usage; "Pod::Usage"->import; 1 } }
1532 0 0 if @_ == 2 and $_[0] eq $tag
1535 0 0 if (@_ > 1) { }
1545 0 0 if (UNIVERSAL::isa($pa, 'HASH')) { }
0 0 elsif ($pa =~ /^-?\d+$/) { }
1557 0 0 unless exists $pa->{'-verbose'}
1558 0 0 unless exists $pa->{'-exitval'}
1564 0 0 if @_ > 1