Branch Coverage

lib/Getopt/ArgParse/Parser.pm
Criterion Covered Total %
branch 271 320 84.6


line true false branch
155 0 18 unless $parent_class and $parent_class->isa('Getopt::ArgParse::Parser')
163 0 5 unless $parent
174 0 7 unless $parent
184 0 6 unless $parent
187 2 4 if (exists $$parent{-'subparsers'})
194 2 4 if $command eq 'help'
211 1 15 if scalar(@_) % 2
218 1 14 if keys %$args
223 1 13 if (exists $$self{-'subparsers'})
257 1 35 unless $$self{-'subparsers'}
261 1 34 unless $command
263 1 33 if scalar(@_) % 2
265 1 32 if (exists $$self{-'subparsers'}{-'parsers'}{$command})
274 0 32 unless $$self{-'subparsers'}
280 1 31 if ref $aliases ne 'ARRAY'
283 1 30 if keys %$args
291 1 34 if (exists $$self{-'subparsers'}{-'alias_map'}{$alias})
337 1 203 unless @_
347 1 202 if scalar(@$rest) % 2
349 1 201 unless $name
362 200 1 if exists $Type2ConstMap{$type_name}
363 1 200 unless defined $type
367 28 172 if (defined $nargs)
368 1 27 if @flags
370 3 14 if ($type != 4 and $type != 2 and $nargs ne '1' and $nargs ne '?')
379 10 189 if ($type == 3) { }
23 166 elsif ($type == 2 or $type == 4) { }
380 10 0 unless defined $$args{'action'}
381 9 1 unless defined $$args{'default'}
383 23 0 unless defined $$args{'action'}
393 199 0 if exists $Action2ClassMap{$action_name}
396 0 199 unless $action
404 0 199 if $@
411 0 3 if (defined $split and not $split and $split =~ /^ +$/)
415 0 3 if (defined $split and $type != 2 and $type != 4)
423 20 179 if (exists $$args{'default'})
426 2 18 if (ref $val eq 'ARRAY') { }
5 13 elsif (ref $val eq 'HASH') { }
429 1 4 if $type != 4
436 15 4 if ($type != 4)
437 1 14 if ($type != 2 and scalar @$default > 1)
447 0 3 if ($choices and ref $choices ne 'CODE' and ref $choices ne 'ARRAY')
456 1 196 if ($choices and $choices_i)
460 1 195 if ($choices_i and ref $choices_i ne 'ARRAY')
471 117 78 if ($type == 5 or $type == 3)
485 117 78 if $type == 5 or $action_name eq '_count'
495 153 42 if (@flags) { }
497 125 16 if ($dest ne $d)
500 1 176 if grep {$f eq $_;} @{$$s{'flags'};}
505 0 152 if (exists $$self{-'position_specs'}{$dest})
509 1 41 if (exists $$self{-'option_specs'}{$dest})
535 152 41 if (@flags) { }
542 81 112 if (delete $$args{'reset'})
543 6 75 if $self->namespace
547 0 193 if keys %$args
553 3 190 if (exists $$specs{$$spec{'dest'}})
564 0 190 if $$self{-'groups'}
578 274 189 if (substr($flag, 0, 1) eq '-') { }
587 160 43 @flags ? :
604 80 2 scalar @_ ? :
623 32 50 unless $self->namespace
630 11 4 if (exists $$self{-'subparsers'} and scalar @argv and defined $argv[0] and substr($argv[0], 0, 1) ne '-')
635 1 10 unless $subparser
644 71 10 if (not $parsed_subcmd) { }
645 71 0 if @option_specs
646 32 32 if @position_specs
648 1 55 if ($self->print_usage_if_help and $self->namespace->get_attr('help'))
653 2 8 if ($self->print_usage_if_help and $self->_command eq 'help')
654 1 1 if ($self->namespace->get_attr('help_command')) { }
672 0 13 unless $alias
674 12 1 if exists $$self{-'subparsers'}{-'alias_map'}{$alias}
677 1 12 unless $command
702 0 1 unless $_[0]{-'argv'}
714 66 92 if ($$spec{'type'} == 2 or $$spec{'type'} == 3 or $$spec{'type'} == 4 or $$spec{'type'} == 1) { }
741 0 71 if $@
743 2 69 if @warns
745 0 69 unless $result
761 1 31 if $self->namespace->get_attr('help')
777 0 53 if ($$spec{'type'} == 5)
782 32 21 defined $$spec{'nargs'} ? :
783 32 21 if (defined $$spec{'nargs'})
784 5 27 if ($nargs eq '?') { }
3 24 elsif ($nargs eq '+') { }
3 21 elsif ($nargs eq '*') { }
1 20 elsif (not $nargs =~ /^\d+$/) { }
787 1 2 unless @{$$self{-'argv'};}
798 37 14 if @{$$self{-'argv'};}
803 3 48 if (scalar @$values and scalar @$values != $number)
828 198 0 if (defined $values) { }
829 90 108 if (ref $values eq 'SCALAR')
830 11 79 if (defined $$values) { }
843 8 114 if (not defined $self->namespace->get_attr($$spec{'dest'}) and scalar @$values < 1 and defined $$spec{'default'})
847 1 7 if ($$spec{'type'} == 3) { }
1 6 elsif ($$spec{'type'} == 5) { }
2 4 elsif ($$spec{'type'} == 4) { }
860 5 193 if (my $delimit = $$spec{'split'}) { }
863 3 9 $$spec{'type'} == 4 ? :
872 5 188 if ($$spec{'type'} == 4)
879 5 193 if ($$spec{'choices'})
880 2 3 if (ref $$spec{'choices'} eq 'CODE') { }
885 9 0 defined $_ ? :
891 2 0 defined $v ? :
892 1 1 if exists $choices{$k}
902 3 193 if ($$spec{'choices_i'})
903 6 0 defined $_ ? :
909 3 0 defined $v ? :
910 2 1 if exists $choices{$k}
936 111 78 unless defined $self->namespace->get_attr($$spec{'dest'})
946 1 188 if $error
964 15 171 if ($$spec{'required'} and not $self->namespace->get_attr('help'))
966 6 9 if ($$spec{'type'} == 2) { }
0 9 elsif ($$spec{'type'} == 4) { }
974 4 11 unless $has_v
996 1 0 if ($usage) { }
1010 5 0 unless $$self{-'groups'}
1018 1 4 if @$aliases
1019 2 3 if ($self->help)
1034 2 3 if ($self->description)
1041 2 30 if ($line =~ /^\s*$/) { }
1045 26 4 $para ? :
1058 3 2 if (exists $$self{-'subparsers'})
1061 1 2 if $$self{-'subparsers'}{-'description'}
1067 0 6 if $len > $max
1081 1 4 if $self->epilog
1093 0 2 unless $subp
1129 5 11 if ($$element{'position'} == 0)
1140 5 3 unless ($$element{'required'})
1154 0 5 unless ($$self{-'groups'})
1166 0 5 if ($self->sortby eq 'name') { }
5 0 elsif ($self->sortby eq 'position') { }
1168 0 0 unless $$b{'required'} cmp $$a{'required'}
1169 0 0 unless $$self{-'groups'}{$group}{-'option'}
1175 0 5 unless $$b{'required'} cmp $$a{'required'}
1176 0 5 unless $$self{-'groups'}{$group}{-'option'}
1184 3 13 $$_{'required'} ? :
3 13 $$_{'required'} ? :
1189 3 2 unless $$self{-'groups'}{$group}{-'position'}
1192 3 1 $$_{'required'} ? :
3 1 $$_{'required'} ? :
1198 3 2 if exists $$self{-'subparsers'}
1200 0 5 if ($group)
1211 10 10 if (@$output)
1230 0 20 unless $specs
1237 20 20 if $print_type == 2 and $$spec{'required'} or $print_type == 1 and not $$spec{'required'}
1242 16 4 if (@{$$spec{'flags'};})
1250 12 8 if $len > $max
1256 3 17 if (defined $$spec{'default'})
1257 1 2 if (ref $$spec{'default'} eq 'HASH') { }
2 0 elsif (ref $$spec{'default'} eq 'ARRAY') { }
1268 3 17 if (@$values)
1276 0 20 if ($$spec{'choices'} and ref $$spec{'choices'} ne 'CODE') { }
0 20 elsif ($$spec{'choices_i'}) { }
1287 0 20 if ($choices)
1291 6 14 $$spec{'required'} ? :
1330 48 110 if ($$spec{'type'} == 1) { }
10 100 elsif ($$spec{'type'} == 2) { }
4 96 elsif ($$spec{'type'} == 4) { }
0 96 elsif ($$spec{'type'} == 0) { }
92 4 elsif ($$spec{'type'} == 5) { }
4 0 elsif ($$spec{'type'} == 3) { }