Branch Coverage

blib/lib/Getopt/Long.pm
Criterion Covered Total %
branch 207 618 33.5


line true false branch
77 0 15 if (defined $ENV{'POSIXLY_CORRECT'}) { }
108 3 5 if ($_ eq ":config")
116 2 4 if @syms
120 3 3 if @config
210 1 2 if wantarray
211 1 1 if (@$args)
233 0 20 if ($debug)
236 0 0 UNIVERSAL::isa($argv, 'ARRAY') ? :
0 0 defined $argv ? :
264 6 14 if (@optionlist and ref $optionlist[0] and UNIVERSAL::isa($optionlist[0], "HASH"))
267 0 6 if $debug
273 0 20 if (@optionlist and $optionlist[0] =~ /^\W+$/ and not $optionlist[0] eq '<>' && @optionlist > 0 && ref $optionlist[1])
281 0 0 if $debug
289 0 38 unless (defined $opt)
295 0 38 if $opt =~ /^$prefix+(.*)$/s
297 2 36 if ($opt eq "<>")
298 0 0 if (defined $userlinkage and not @optionlist > 0 && ref $optionlist[0] and exists $userlinkage->{$opt} and ref $userlinkage->{$opt})
304 0 2 unless (@optionlist > 0 and ref $optionlist[0] and ref $optionlist[0] eq "CODE")
308 0 0 if @optionlist and ref $optionlist[0]
318 0 36 unless (defined $name)
322 0 0 if @optionlist and ref $optionlist[0]
329 11 25 if (defined $userlinkage)
330 6 5 unless (@optionlist > 0 and ref $optionlist[0])
331 0 6 if (exists $userlinkage->{$orig} and ref $userlinkage->{$orig}) { }
333 0 0 if $debug
346 15 15 if (@optionlist > 0 and ref $optionlist[0]) { }
347 0 15 if $debug
351 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') { }
380 0 15 if ($opctl{$name}[3] == 1) { }
0 15 elsif ($opctl{$name}[3] == 2) { }
381 0 0 if $debug
386 0 0 if $debug
391 0 15 if $debug
397 0 0 if ($opctl{$name}[0] eq "I" and $opctl{$name}[3] == 1 || $opctl{$name}[3] == 2)
406 0 20 unless $argv and UNIVERSAL::isa($argv, "ARRAY")
410 0 20 if $error
414 0 20 defined $auto_version ? :
0 20 if (defined $auto_version ? $auto_version : $requested_version >= "2.3203")
415 0 0 unless (defined $opctl{'version'})
421 0 20 defined $auto_help ? :
0 20 if (defined $auto_help ? $auto_help : $requested_version >= "2.3203")
422 0 0 unless (defined $opctl{'help'} or defined $opctl{'?'})
430 0 20 if ($debug)
445 0 52 if $debug
448 1 51 if (defined $opt and $opt eq $argend)
449 0 1 if $passthrough
464 36 15 if ($found) { }
14 1 elsif ($order == $PERMUTE) { }
467 1 35 unless defined $opt
474 0 35 if $debug
476 0 35 if $debug
478 30 5 if (defined $linkage{$opt}) { }
0 5 elsif ($ctl->[3] == 1) { }
0 5 elsif ($ctl->[3] == 2) { }
480 0 30 if $debug
482 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') { }
484 0 29 if ($ctl->[0] eq '+') { }
0 29 elsif ($ctl->[3] == 1) { }
0 29 elsif ($ctl->[3] == 2) { }
485 0 0 if $debug
487 0 0 if (defined ${$linkage{$opt};}) { }
495 0 0 if $debug
500 0 0 if $debug
505 0 0 if $debug
510 0 0 if $debug
515 0 29 if $debug
521 0 0 if $debug
526 0 0 if $debug
531 0 0 $ctl->[3] == 2 ? :
0 1 if $debug
539 0 1 $ctl->[3] == 2 ? :
554 0 1 if $debug and $eval_error ne ""
556 0 1 if ($eval_error =~ /^!/) { }
0 1 elsif ($eval_error ne '') { }
557 0 0 if ($eval_error =~ /^!FINISH\b/)
574 0 0 if (defined $userlinkage->{$opt}) { }
575 0 0 if $debug
580 0 0 if $debug
586 0 0 if (defined $userlinkage->{$opt}) { }
587 0 0 if $debug
592 0 0 if $debug
598 0 5 if ($ctl->[0] eq '+') { }
599 0 0 if $debug
601 0 0 if (defined $userlinkage->{$opt}) { }
609 0 5 if $debug
615 35 0 if $argcnt >= $ctl->[5] and $ctl->[5] != -1
619 0 0 if ($argcnt < $ctl->[4])
620 0 0 if (@$argv) { }
621 0 0 if (&ValidValue($ctl, $argv->[0], 1, $argend, $prefix))
623 0 0 if ($ctl->[0] =~ /^[iIo]$/)
625 0 0 $ctl->[0] eq 'o' && $arg =~ /^0/ ? :
629 0 0 if $ctl->[3] == 2
643 0 0 if (@$argv and &ValidValue($ctl, $argv->[0], 0, $argend, $prefix))
645 0 0 if ($ctl->[0] =~ /^[iIo]$/)
647 0 0 $ctl->[0] eq 'o' && $arg =~ /^0/ ? :
651 0 0 if $ctl->[3] == 2
662 3 11 if (defined($cb = $linkage{'<>'})) { }
663 0 3 if $debug
677 0 3 if $debug and $eval_error ne ""
679 0 3 if ($eval_error =~ /^!/) { }
0 3 elsif ($eval_error ne '') { }
680 0 0 if ($eval_error =~ /^!FINISH\b/)
690 0 11 if $debug
707 9 0 if (@ret and $order == $PERMUTE || $passthrough)
709 0 9 if $debug
720 0 0 defined $_ ? :
739 2 34 $passthrough ? :
743 0 36 unless ($opt =~ m[^ ( # Option name $op # 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)
765 15 21 unless defined $spec
776 36 0 if (defined $names) { }
787 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) { }
795 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+$/) { }
809 0 0 $dest eq '%' ? :
0 0 $dest eq '@' ? :
812 0 0 $def eq '+' ? :
818 0 17 if $bundling and defined $4
821 0 0 if defined $mi and not $mi and not defined $ma and not defined $cm
824 0 17 if $type eq "n"
826 0 17 $dest eq '%' ? :
0 17 $dest eq '@' ? :
829 15 2 $mand eq '=' ? :
17 0 unless defined $mi
831 15 2 $mi ? :
833 15 2 $mi ? :
17 0 unless defined $ma or defined $cm
834 0 17 if defined $ma and not $ma
836 0 17 if defined $ma and $ma < $mi
847 0 36 $bundling && length $_ == 1 ? :
10 26 if $ignorecase > ($bundling && length $_ == 1 ? 1 : 0)
850 0 36 if (exists $opctl->{$_})
854 4 32 if ($spec eq '!') { }
865 0 36 if ($dups)
883 0 51 if $debug
885 0 51 unless defined $opt
886 12 39 unless $opt =~ /^($prefix)(.*)$/s
887 0 39 if $opt eq "-" and not defined $opctl->{''}
892 0 39 if $debug
899 3 36 if ($starter =~ /^$longprefix$/ || $getopt_compat && ($bundling == 0 || $bundling == 2) and (my $oppos = index($opt, "=", 1)) > 0)
905 0 3 if $debug
913 0 39 if ($bundling || $bundling_values and $starter eq '-') { }
39 0 elsif ($autoabbrev and $opt ne '') { }
0 0 elsif ($ignorecase) { }
916 0 0 $ignorecase ? :
919 0 0 if ($bundling == 2 and length $tryopt > 1 and defined $opctl->{$tryopt}) { }
0 0 elsif ($bundling_values) { }
921 0 0 if $debug
929 0 0 length $tryopt > 0 ? :
931 0 0 if $ignorecase > 1
932 0 0 if $debug
935 0 0 $rest eq '' ? :
944 0 0 length $tryopt > 0 ? :
946 0 0 if $ignorecase > 1
947 0 0 if $debug
949 0 0 unless $rest ne ""
958 10 29 if $ignorecase
964 0 39 if $debug
968 0 39 unless (@hits <= 1 or grep(($_ eq $opt), @hits) == 1)
973 0 0 if defined $opctl->{$_}[1]
974 0 0 if $opctl->{$_}[0] eq "!"
978 0 0 if (keys %hit == 2)
979 0 0 if ($auto_version and exists $hit{'version'}) { }
0 0 elsif ($auto_help and exists $hit{'help'}) { }
987 0 0 unless (keys %hit == 1)
988 0 0 if $passthrough
998 0 39 if (@hits == 1 and $hits[0] ne $opt)
1000 0 0 $bundling && length $tryopt == 1 ? :
0 0 if $ignorecase > ($bundling && length $tryopt == 1 ? 1 : 0)
1002 0 0 if $debug
1014 4 35 unless (defined $ctl)
1015 3 1 if $passthrough
1017 1 0 if ($bundling == 1 and length $starter == 1)
1019 0 1 if defined $rest
1021 0 1 if ($opt eq '') { }
1032 0 35 if $debug
1041 3 17 if ($type eq "" or $type eq "!" or $type eq "+")
1042 0 18 if (defined $optarg) { }
15 3 elsif ($type eq '' or $type eq '+') { }
1043 0 0 if $passthrough
1047 0 0 if $bundling_values
1057 0 18 if defined $rest
1065 0 17 if ($gnu_compat)
1067 0 0 if (defined $optarg) { }
0 0 elsif (defined $rest or @$argv > 0) { }
1068 0 0 length $optarg == 0 ? :
1076 0 0 if ($optargtype == 0 and not $mand)
1077 0 0 if ($type eq "I")
1083 0 0 $type eq 's' ? :
0 0 defined $ctl->[2] ? :
1089 0 0 $type eq 's' ? :
0 0 if $optargtype == 1
1094 3 14 defined $optarg ? :
0 17 if (defined $optarg ? $optarg eq "" : !(defined $rest || @$argv > 0))
1099 0 0 if ($mand or $ctl->[3] == 2)
1100 0 0 if $passthrough
1105 0 0 if ($type eq "I")
1111 0 0 $type eq 's' ? :
0 0 defined $ctl->[2] ? :
1117 3 14 defined $optarg ? :
0 17 defined $rest ? :
1122 0 17 if ($ctl->[3] == 2 and defined $arg)
1123 0 0 $type eq 's' ? :
0 0 $mand ? :
0 0 defined $ctl->[2] ? :
0 0 $arg =~ /^([^=]*)=(.*)$/s ? :
1126 0 0 unless (defined $arg)
1130 0 0 if defined $rest
1137 0 17 $ctl->[3] == 2 ? :
1139 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') { }
1141 14 1 if $mand
1144 0 1 if $ctl->[3] == 2
1148 0 1 if defined $optarg or defined $rest
1150 0 1 if $arg eq "-"
1153 0 1 if ($arg eq $argend or $arg =~ /^$prefix.+/)
1166 0 2 $type eq 'o' ? :
1168 0 2 if ($bundling and defined $rest and $rest =~ /^($key_valid)($o_valid)(.*)$/is) { }
2 0 elsif ($arg =~ /^$o_valid$/is) { }
1171 0 0 if $key
1172 0 0 $type eq 'o' && $arg =~ /^0/ ? :
1173 0 0 if defined $rest and $rest ne ""
1177 0 2 $type eq 'o' && $arg =~ /^0/ ? :
1180 0 0 if (defined $optarg or $mand) { }
1181 0 0 if ($passthrough)
1182 0 0 defined $rest ? :
0 0 unless defined $optarg
1186 0 0 $type eq 'o' ? :
1192 0 0 if defined $rest
1197 0 0 defined $rest ? :
1198 0 0 if ($type eq "I")
1205 0 0 defined $ctl->[2] ? :
1212 0 0 if ($bundling and defined $rest and $rest =~ /^($key_valid)($o_valid)(.*)$/s) { }
0 0 elsif ($arg =~ /^$o_valid$/) { }
1216 0 0 if $key
1217 0 0 if defined $rest and $rest ne ""
1223 0 0 if (defined $optarg or $mand) { }
1224 0 0 if ($passthrough)
1225 0 0 defined $rest ? :
0 0 unless defined $optarg
1233 0 0 if defined $rest
1238 0 0 defined $rest ? :
1253 0 0 if ($ctl->[3] == 2)
1254 0 0 unless $arg =~ /[^=]+=(.*)/
1260 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') { }
1262 0 0 if $mand
1264 0 0 if $arg eq "-"
1267 0 0 if $arg eq $argend or $arg =~ /^$prefix.+/
1275 0 0 $type eq 'o' ? :
1296 6 21 if (ref $options[0] eq "ARRAY")
1307 6 20 if ($try =~ /^no_?(.*)$/s)
1311 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') { }
1316 0 0 if $action
1324 0 0 $action ? :
1327 0 0 if ($action)
1351 2 0 $action ? :
1355 2 0 if $action
1358 0 0 $action ? :
1359 0 0 if $action
1363 0 0 if $action
1366 1 0 $action ? :
1369 0 0 $action ? :
1379 0 0 if $@
1384 3 0 unless $genprefix =~ /^\(.*\)$/
1387 0 3 if $@
1392 3 0 unless $longprefix =~ /^\(.*\)$/
1395 0 3 if $@
1428 0 0 defined $pa->{'-message'} ? :
0 0 defined $v ? :
0 0 $] >= 5.006 ? :
1436 0 0 unless $pa->{'-exitval'} eq "NOEXIT"
1448 0 0 unless eval { do { require Pod::Usage; "Pod::Usage"->import; 1 } }
1466 0 0 if @_ == 2 and $_[0] eq $tag
1469 0 0 if (@_ > 1) { }
1479 0 0 if (UNIVERSAL::isa($pa, 'HASH')) { }
0 0 elsif ($pa =~ /^-?\d+$/) { }
1481 0 0 unless (defined $pa->{'-message'})
1493 0 0 unless exists $pa->{'-verbose'}
1494 0 0 unless exists $pa->{'-exitval'}
1500 0 0 if @_ > 1