Branch Coverage

blib/lib/Config/Param.pm
Criterion Covered Total %
branch 489 778 62.8


line true false branch
67 65 2 ref $_[0] eq 'HASH' ? :
71 66 1 if (ref $_[0] eq 'ARRAY') { }
74 64 2 if (ref $_[0] eq "ARRAY")
94 64 3 if $give_error
187 0 657 defined $def->{'type'} && !defined($def->{'value'}) ? :
203 0 234 unless defined $h{'short'}
204 178 56 unless defined $h{'flags'}
212 0 79 if defined $config and defined $config->{'version'}
221 251 8 defined $def->{'short'} ? :
224 0 259 if defined $def->{'section'}
225 1 0 defined $def->{'long'} ? :
1 258 unless valid_def($def)
228 1 0 defined $def->{'short'} ? :
1 257 if $$name_there{$def->{'long'}} or $name_there->{$short}
230 257 0 if defined $def->{'long'}
231 209 48 if $short ne ""
245 69 1 if (@{$indef;})
247 33 36 if (ref $indef->[0] ne '') { }
253 0 86 if $t eq ""
255 0 86 if $t ne "ARRAY" and $t ne "HASH"
258 61 25 $t eq 'ARRAY' ? :
261 0 86 if $problem
266 0 36 if @{$indef;} % 4
274 2 171 if $problem
286 2 141 unless defined $_[0]
290 16 157 if /^\s/
306 1 69 unless defined $self->{'config'}
308 1 69 unless defined $pars
312 40 30 unless defined $self->{'config'}{'program'}
313 40 30 unless exists $self->{'config'}{'shortdefaults'}
327 0 15 if ($self->{'config'}{'lazy'} and $self->{'config'}{'posixhelp'})
333 0 70 $self->{'config'}{'posixhelp'} ? :
335 0 70 $self->{'config'}{'posixhelp'} ? :
361 69 1 $self->{'config'}{'shortdefaults'} ? :
369 1 0 unless (defined $_[2])
376 69 1 $self->{'config'}{'shortdefaults'} ? :
380 0 70 if defined $self->{'config'}{'version'}
384 0 70 if exists $self->{'config'}{'ignorehelp'}
386 0 70 if exists $self->{'config'}{'eval'}
389 2 68 if ($problem) { }
399 0 252 unless $self->define($def)
420 342 56 unless defined $val
421 0 342 $val eq '' ? :
56 342 $flags & $arg ? :
435 140 257 ref $pd->{'help'} ? :
397 71 defined $pd->{'help'} ? :
437 70 398 if (exists $pd->{'section'})
442 0 70 defined $pd->{'flags'} ? :
443 70 0 defined $pd->{'level'} ? :
447 0 70 if @{$self->{'section'};}
455 0 398 unless (@{$self->{'section'};})
464 1 397 unless defined $pd->{'help'}
465 8 390 unless defined $pd->{'short'}
467 0 398 unless (valid_def($pd, $type))
474 387 11 defined $pd->{'flags'} ? :
476 0 398 if defined $pd->{'addflags'}
479 160 238 defined $pd->{'regex'} ? :
482 82 316 defined $pd->{'call'} ? :
483 0 398 if ($flags & $switch and $flags & $arg)
488 0 398 if (defined $self->{'param'}{$name} or defined $self->{'long'}{$pd->{'short'}}) { }
495 212 186 if (ref $pd->{'value'}) { }
507 346 52 if $pd->{'short'} ne ""
513 0 398 defined $pd->{'level'} ? :
516 70 328 if $lev < $section->{'minlevel'}
519 0 398 if $self->{'flags'}{$name} & $switch
524 144 254 if length $name > $self->{'length'}
527 144 254 if $arglen > $self->{'arglength'}
528 160 238 if defined $regex
530 82 316 if defined $call
545 0 68 if (defined $self->{'config'}{'file'})
549 0 0 ref $self->{'config'}{'file'} eq 'ARRAY' ? :
554 42 26 unless ($self->{'config'}{'nofile'} or @{$self->{'param'}{'config'};})
560 11 31 if defined $pconf
561 0 42 if defined $hconf
565 42 0 unless ($self->{'config'}{'multi'})
567 11 31 if @l
581 69 0 if (defined(my $name = $self->{'long'}{$s})) { }
587 0 0 if ($self->{'config'}{'fuzzy'}) { }
595 0 0 unless ($self->{'config'}{'ignore_unknown'} and $self->{'config'}{'ignore_unknown'} > 1)
616 205 1 if my $arrhash = defined $self->{'type'}{$name}
621 158 48 if (defined $_[0] and $arrhash) { }
16 33 elsif (not defined $_[0] and $flags & $arg) { }
624 16 142 if ($_[0] eq "/" and $_[1] =~ m[(./)(=?)(.*)])
627 4 12 $3 eq '' && $2 eq '' ? :
628 4 12 if $2 eq "" and defined $_[1]
631 8 150 if ($_[0] =~ m[^/./$] and $flags & $arg)
633 0 8 unless (@{$_[2];})
636 0 0 $self->{'short'}{$name} ne '' ? :
644 0 16 unless ($lastoption and @{$_[2];})
647 0 0 $self->{'short'}{$name} ne '' ? :
655 31 175 unless defined $_[0]
660 6 200 if (defined $self->{'call'}{$name})
664 1 5 if ($ret or (not defined $nname or $nname ne $name))
666 0 1 if $ret
675 30 175 unless (defined $_[0])
677 0 30 if ($flags & $count) { }
679 0 0 $sign =~ /^-/ ? :
684 30 0 $sign =~ /^-/ ? :
687 204 1 if ($arrhash)
690 61 143 if $self->{'flags'}{$name} & $append
701 149 57 unless defined $self->{'ops'}{$name}
703 1 205 unless defined $op
705 199 6 $op =~ /=$/ ? :
718 0 66 if $self->{'config'}{'gimme'} and not @{$args;}
725 15 51 if ($self->{'config'}{'lazy'})
740 0 208 if ($e >= 0) { }
749 0 208 if ($begin =~ /$separator/o) { }
46 162 elsif ($begin =~ /$shortarg/ and defined($name = $self->{'long'}{$1}) and $self->{'flags'}{$name} & $arg) { }
65 97 elsif ($begin =~ /$shorts/o) { }
96 1 elsif ($begin =~ /$longex/) { }
760 38 8 $2 ne '' ? :
769 7 58 if $sign eq ""
771 30 35 defined $op ? :
772 30 35 defined $6 ? :
779 0 65 unless @{$names;}
788 65 4 $lastoption ? :
789 65 4 $lastoption ? :
792 69 0 if @{$self->{'errors'};} == $olderr
799 0 96 defined $7 ? :
800 2 94 if $sign eq ""
801 0 96 defined $8 ? :
804 86 10 defined $6 ? :
805 6 0 unless (exists $self->{'param'}{$name} or $self->{'config'}{'accept_unknown'})
807 0 6 if ($self->{'config'}{'fuzzy'}) { }
814 5 1 unless ($self->{'config'}{'ignore_unknown'} and $self->{'config'}{'ignore_unknown'} > 1)
822 0 96 unless ($name =~ /$noop$/o)
830 91 5 if @{$self->{'errors'};} == $olderr
832 91 5 if @{$self->{'errors'};} == $olderr
841 66 0 unless $self->{'bad_command_line'}
853 0 63 if ($olderr != $newerr)
871 0 1 if (not exists $self->{'param'}{$key} and defined $self->{'config'}{'accept_unknown'} and $self->{'config'}{'accept_unknown'} > 1)
877 143 1 if (exists $self->{'param'}{$key}) { }
0 1 elsif (not $self->{'config'}{'ignore_unknown'}) { }
887 62 0 unless $self->{'bad_command_line'}
896 40 27 if $self->{'config'}{'nofinals'}
899 11 16 unless defined $handle
904 0 0 $self->{'bad_config_file'} ? :
0 0 $self->{'bad_command_line'} ? :
0 27 @{$self->{'errors'};} ? :
908 0 27 if ($end)
910 0 0 if (@{$self->{'errors'};})
915 0 0 unless $self->{'config'}{'noexit'}
920 15 12 if ($self->{'param'}{'help'}) { }
0 12 elsif (defined $self->{'config'}{'version'} and $self->{'param'}{'version'}) { }
1 11 elsif ($self->{'printconfig'}) { }
924 0 15 unless $self->{'config'}{'noexit'}
930 0 0 unless $self->{'config'}{'noexit'}
936 0 1 unless $self->{'config'}{'noexit'}
950 71 0 unless defined $mk
952 68 3 if (not defined $format or $format eq 'dump') { }
3 0 elsif ($format eq 'lines') { }
954 68 0 if (eval { do { require Data::Dumper } }) { }
960 0 68 unless defined $Data::Dumper::Indent
969 0 3 unless defined $self->{$mk}{$k}
970 1 2 if ($self->{'type'}{$k} == $array) { }
1 1 elsif ($self->{'type'}{$k} == $hash) { }
972 0 1 unless @{$self->{$mk}{$k};}
992 48 0 unless defined $filler
994 36 6 $prefill && $indent - $prefill > 2 ? :
42 6 $indent > $prefill ? :
1004 0 87 unless @_
1017 0 87 unless @paragraphs
1027 3 128 if ($p =~ /^\t/) { }
33 95 elsif ($p eq '') { }
95 0 elsif ($can_wrap) { }
1029 0 3 if $llen
1037 27 6 unless defined $line
1050 220 1106 if (not $l or $l + $llen >= $length)
1057 1231 95 if ($l)
1059 1011 160 do { $llen } ? :
1171 60 defined $line ? :
1082 0 0 defined $line ? :
1104 0 4 unless defined $handle
1112 2 2 if defined $self->{'config'}{'info'}
1114 2 2 unless defined $tagline or not defined $prog
1119 1 3 unless (defined $usage or not @desc)
1121 1 0 if (lc($desc[0]) =~ /^\s*usage:\s*(.*\S?)\s*$/)
1123 0 1 if $1 ne ""
1128 1 0 if (not defined $usage and @desc)
1137 4 0 if (defined $prog)
1140 4 0 if defined $tagline
1143 2 2 if (defined $usage)
1148 1 3 if (@desc or defined $self->{'config'}{'infopod'})
1151 0 1 if (defined $self->{'config'}{'infopod'}) { }
1159 4 0 defined $prog ? :
1164 4 0 if ($self->{'config'}{'lazy'}) { }
1183 24 4 $self->{'short'}{$k} ne '' ? :
1186 4 24 $k eq 'help' ? :
1191 4 24 if $k eq "help"
1199 4 0 if defined $self->{'config'}{'extrapod'}
1205 8 4 if defined $self->{'config'}{$_->[1]}
1211 4 12 $ps->{'verbatim'} ? :
1224 0 0 $self->{'type'}{$k} == $scalar && ($self->{'flags'}{$k} & $switch || defined $self->{'arg'}{$k} && $self->{'arg'}{$k} eq '') && $self->{'default'}{$k} ? :
1232 0 15 unless defined $handle
1235 0 15 $self->{'config'}{'posixhelp'} ? :
1239 15 0 if (defined $self->{'config'}{'linewidth'}) { }
0 0 elsif (eval { do { require Term::ReadKey } }) { }
0 0 elsif (eval { do { require IPC::Run } }) { }
1247 0 0 if @s
1252 0 0 if (eval { do { IPC::Run::run(["tput", "cols"], \$in, \$linewidth, \$err) } })
1258 0 15 $linewidth > 80 ? :
1260 9 6 if ($self->{'param'}{'help'} =~ /^(-\d+),?(.*)$/)
1267 0 5 unless (exists $self->{'param'}{$_})
1274 0 9 if $badkeys
1276 1 8 if ($code == -1) { }
1 7 elsif ($code == -2) { }
1 6 elsif ($code == -3) { }
1 5 elsif ($code == -10) { }
1 4 elsif ($code == -11) { }
4 0 elsif ($code == -100) { }
1289 1 0 if @pars
1296 1 1 if ($first) { }
1319 0 6 if ($self->{'param'}{'help'} =~ /../)
1322 0 0 if (exists $self->{'param'}{$k}) { }
1329 0 0 unless defined $val
1331 0 0 $s ne '' ? :
0 0 $s ne '' ? :
0 0 $self->{'config'}{'posixhelp'} ? :
1342 0 0 $c eq $dc ? :
1347 0 0 if ($type eq $scalar) { }
0 0 elsif (grep {$_ == $type;} $array, $hash) { }
1350 0 0 if $flags & $switch or not $flags & $count
1352 0 0 if $flags & $count or not $flags & $switch
1354 0 0 $s ne '' ? :
0 0 $val ne '' ? :
0 0 $flags & $arg ? :
1370 0 0 unless $flags & $switch
1375 0 0 if not $flags & $switch and $s ne ""
1379 0 0 $s ne '' ? :
0 0 $s ne '' ? :
0 0 $s ne '' ? :
0 0 $s ne '' ? :
0 0 $flags & $count ? :
0 0 unless $flags & $arg
1393 0 0 $type == $hash ? :
1398 0 0 if $flags & $append
1401 0 0 $flags & $arg ? :
1408 0 0 if $flags & $append
1410 0 0 $flags & $arg ? :
0 0 if $s ne ""
1427 0 0 if $self->{'config'}{'lazy'}
1430 0 0 if (${$self->{'help'}{$k};} ne '') { }
1439 0 0 if $k eq "help"
1448 0 6 if ($self->{'param'}{'help'} =~ /\D/)
1454 0 6 defined $self->{'config'}{'version'} ? :
1455 3 3 if (defined $self->{'config'}{'tagline'}) { }
1458 1 2 if (defined $self->{'config'}{'usage'})
1463 1 2 if (defined $self->{'config'}{'info'}) { }
0 2 elsif (defined $self->{'config'}{'infopod'}) { }
1472 3 0 if defined $self->{'config'}{'copyright'}
1476 3 0 if (defined $self->{'config'}{'info'}) { }
0 0 elsif (defined $self->{'config'}{'infopod'}) { }
1486 3 0 if defined $self->{'config'}{'copyright'}
1492 0 6 if ($self->{'config'}{'posixhelp'}) { }
1503 6 0 if length $preprint > $indent
1510 6 0 if ($self->{'config'}{'lazy'}) { }
1513 2 4 if ($level > 1)
1523 2 4 if ($level > 1) { }
1537 0 6 if ($self->{'config'}{'ordered'}) { }
1541 0 0 if ($level >= $s->{'minlevel'})
1544 0 0 if $s->{'section'} ne ""
1546 0 0 if ${$s->{'help'};} ne ""
1565 0 6 if (@hidden_nonshort)
1568 0 0 if ($level > 1) { }
1575 0 0 @hidden_nonshort == 1 ? :
1581 0 6 if (@hidden_level)
1584 0 0 if ($level > 1) { }
1590 0 0 @hidden_level == 1 ? :
1607 0 0 if ($self->{'config'}{'hidenonshort'} and $self->{'short'}{$k} eq "" and not $k eq 'version' && defined $self->{'config'}{'version'})
1613 0 42 if ($level < $self->{'level'}{$k})
1619 0 42 if $hide
1621 0 42 if ($self->{'config'}{'posixhelp'}) { }
1642 36 6 if $self->{'short'}{$k} ne ""
1649 2 4 if $k eq "help" and $self->{'param'}{'help'} > 1 and defined $self->{'extrahelp'}
1653 42 10 $i == 0 ? :
1666 0 0 $self->{'short'}{$k} ne '' ? :
1670 0 0 if $k eq "help" and $self->{'param'}{'help'} > 1
1673 0 0 unless @help
1675 0 0 if $pm eq "+"
1679 0 0 $i == 0 ? :
1696 1 9 unless $self->parse_file($file, $construct)
1715 15 86 if "File::Spec"->file_name_is_absolute($name)
1720 2 84 if INT_filelike($name)
1721 0 84 if INT_filelike("$name.conf")
1726 0 84 if (defined $self->{'config'}{'confdir'}) { }
1746 555 11 unless INT_filelike($f)
1747 11 555 if (INT_filelike($f))
1754 11 73 if defined $path
1774 0 17 if (not defined $file) { }
0 17 elsif (grep {$_ eq $file;} @{$$self{'parse_chain'};}) { }
17 0 elsif ($cdat->open($file, '<')) { }
1776 0 0 unless $self->{'config'}{'nocomplain'}
1786 0 17 if (defined $self->{'config'}{'binmode'})
1801 35 263 if ($mcollect) { }
1803 140 123 if $_ =~ /^\s*#/ or $_ =~ /^\s*#?\s*$lend$/o
1805 39 84 if ($_ =~ /^=($nlend+)$lend*$/o) { }
1808 13 26 if ($construct)
1810 1 12 if ($meta =~ /^param file\s*(\(([^)]*)\)|)\s*for\s*(.+)$/) { }
0 12 elsif ($meta =~ /^version\s*(.+)$/) { }
0 12 elsif ($meta =~ /^info\s(.*)$/) { }
0 12 elsif ($meta =~ /^infopod\s(.*)$/) { }
1814 0 1 if (defined $2 and $2 =~ /^(.+)$/)
1819 0 0 if $s eq "eval"
1838 16 23 if ($meta =~ /^(long|key)\s*(\S*)(\s*short\s*(\S)|)(\s*type\s*(\S+)|)/) { }
16 7 elsif ($meta =~ /^(help|desc)\s(.*)$/) { }
5 2 elsif ($meta =~ /^include\s*(.+)$/) { }
1840 8 8 defined $4 ? :
1841 16 0 defined $6 ? :
1842 16 0 if (exists $typemap{$type}) { }
1851 0 16 $curpar{'help'} ne '' ? :
1859 5 0 unless ("File::Spec"->file_name_is_absolute($incfile))
1864 0 5 unless -e $incfile
1872 74 10 if ($_ =~ /^\s*($parname)\s*($lopex)\s*($nlend*)$lend$/) { }
0 10 elsif ($_ =~ /^\s*($parname)\s*$lend$/) { }
10 0 elsif ($_ =~ /^\s*($parname)\s*([$ops]?)<<(.*)$/) { }
1880 71 3 if (exists $self->{'param'}{$par}) { }
1887 1 2 unless ($self->{'config'}{'ignore_unknown'})
1889 0 1 if $self->{'config'}{'nanny'}
1898 0 0 if (exists $self->{'param'}{$par}) { }
1905 0 0 unless ($self->{'config'}{'ignore_unknown'})
1907 0 0 if $self->{'config'}{'nanny'}
1915 5 5 $2 ne '' ? :
1918 5 5 unless $mop =~ /=$/
1926 10 25 if ($_ =~ /^$ender$/) { }
1937 10 0 if (exists $self->{'param'}{$mkey}) { }
1945 0 0 unless ($self->{'config'}{'ignore_unknown'})
1947 0 0 if ($self->{'config'}{'nanny'})
1960 0 0 unless $self->{'config'}{'nocomplain'}
1962 16 1 if (@{$self->{'errors'};} == $olderrs) { }
1978 6 0 if (defined $curpar->{'long'} and $construct || $self->{'config'}{'accept_unknown'} && !exists $self->{'param'}{$par} && $curpar->{'long'} eq $par)
1990 0 3 if not exists $self->{'param'}{$par} and $construct || $self->{'config'}{'accept_unknown'}
2000 0 2 if defined $self->{'config'}{'version'}
2001 0 2 if defined $self->{'config'}{'notinfile'}
2002 2 0 unless ($bare)
2045 0 2 if @opt
2047 0 2 if defined $self->{'config'}{'version'}
2049 1 1 if (defined $self->{'config'}{'info'} and not $bare)
2054 0 2 if (defined $self->{'config'}{'infopod'} and not $bare)
2061 11 4 unless (grep /^$k$/, @omit)
2067 11 0 unless ($bare)
2070 8 3 $self->{'short'}{$k} ne '' ? :
2079 4 7 $self->{'type'}{$k} ? :
2080 2 9 if ($self->{'type'}{$k} == $hash)
2085 4 0 defined $values->{$k} ? :
2089 0 11 unless defined $values
2091 11 0 unless $bare
2097 4 0 @{$values;} > 1 ? :
8 4 !$first ? :
12 7 $self->{'type'}{$k} ? :
2099 18 1 if (defined $v) { }
2101 1 17 if ($v =~ /[\012\015]/) { }
2125 104 0 if (defined $k) { }
2140 0 280 unless exists $self->{'param'}{$_[0]}
2142 101 179 if ($self->{'type'}{$_[0]} == $scalar) { }
101 78 elsif ($self->{'type'}{$_[0]} == $array) { }
78 0 elsif ($self->{'type'}{$_[0]} == $hash) { }
2146 69 32 if ($_[1] eq '=') { }
6 26 elsif ($_[1] eq '.=') { }
10 16 elsif ($_[1] eq '+=') { }
11 5 elsif ($_[1] eq '-=') { }
5 0 elsif ($_[1] eq '*=') { }
0 0 elsif ($_[1] eq '/=') { }
2158 18 83 if ($_[1] eq '=') { }
54 29 elsif ($_[1] eq '.=') { }
3 26 elsif ($_[1] eq '//=' or $_[1] eq '/=' and $_[2] eq '/') { }
25 1 elsif ($_[1] =~ m[^/(.)/(.*)$]) { }
2166 11 14 if ($op eq '=') { }
14 0 elsif ($op eq '.=') { }
2171 1 100 if ($bad)
2182 25 53 if ($_[1] =~ m[^/(.)/(.*)$]) { }
3 50 elsif ($_[1] eq '//=' or $_[1] eq '/=' and $_[2] eq '/') { }
2188 11 14 if ($op eq '=') { }
14 0 elsif ($op eq '.=') { }
2197 12 38 if ($_[1] eq '=') { }
38 0 elsif ($_[1] eq '.=') { }
2201 0 78 if ($bad)
2216 64 76 if ($self->{'type'}{$k} == $scalar) { }
68 8 elsif ($self->{'type'}{$k} == $array) { }
8 0 elsif ($self->{'type'}{$k} == $hash) { }
2219 0 64 unless $p->{$k} =~ /$self->{'regex'}{$k}/
2225 2 13 unless $p->{$k}[$i] =~ /$self->{'regex'}{$k}/
2232 0 4 unless $p->{$k}{$n} =~ /$self->{'regex'}{$k}/
2240 321 16 unless $self->{'flags'}{$k} & $nonempty
2241 3 3 unless ($self->{'type'}{$k} == $scalar and $p->{$k} ne "" or $self->{'type'}{$k} == $array and @{$p->{$k};} or $self->{'type'}{$k} == $hash and %{$p->{$k};})
2261 6 18 if $bin->{$p}
2262 6 12 ref $self->{'param'}{$p} ? :
2275 62 144 unless defined $self->{'ops'}{$key}
2288 1381 0 unless $verbose or $self->{'config'}{'verbose'}
2296 0 14 unless $self->{'config'}{'silenterr'}