Branch Coverage

lib/Getopt/ArgParse/Parser.pm
Criterion Covered Total %
branch 264 306 86.2


line true false branch
146 0 18 unless $parent_class and $parent_class->isa('Getopt::ArgParse::Parser')
154 0 5 unless $parent
165 0 7 unless $parent
175 0 6 unless $parent
178 2 4 if (exists $$parent{-'subparsers'})
185 2 4 if $command eq 'help'
202 1 15 if scalar(@_) % 2
209 1 14 if keys %$args
214 1 13 if (exists $$self{-'subparsers'})
248 1 35 unless $$self{-'subparsers'}
252 1 34 unless $command
254 1 33 if scalar(@_) % 2
256 1 32 if (exists $$self{-'subparsers'}{-'parsers'}{$command})
265 0 32 unless $$self{-'subparsers'}
271 1 31 if ref $aliases ne 'ARRAY'
274 1 30 if keys %$args
282 1 34 if (exists $$self{-'subparsers'}{-'alias_map'}{$alias})
328 1 203 unless @_
338 1 202 if scalar(@$rest) % 2
340 1 201 unless $name
353 200 1 if exists $Type2ConstMap{$type_name}
354 1 200 unless defined $type
358 28 172 if (defined $nargs)
359 1 27 if @flags
361 3 14 if ($type != 4 and $type != 2 and $nargs ne '1' and $nargs ne '?')
370 10 189 if ($type == 3) { }
23 166 elsif ($type == 2 or $type == 4) { }
371 10 0 unless defined $$args{'action'}
372 9 1 unless defined $$args{'default'}
374 23 0 unless defined $$args{'action'}
384 199 0 if exists $Action2ClassMap{$action_name}
387 0 199 unless $action
395 0 199 if $@
402 0 3 if (defined $split and not $split and $split =~ /^ +$/)
406 0 3 if (defined $split and $type != 2 and $type != 4)
414 20 179 if (exists $$args{'default'})
417 2 18 if (ref $val eq 'ARRAY') { }
5 13 elsif (ref $val eq 'HASH') { }
420 1 4 if $type != 4
427 15 4 if ($type != 4)
428 1 14 if ($type != 2 and scalar @$default > 1)
438 0 3 if ($choices and ref $choices ne 'CODE' and ref $choices ne 'ARRAY')
447 1 196 if ($choices and $choices_i)
451 1 195 if ($choices_i and ref $choices_i ne 'ARRAY')
462 117 78 if ($type == 5 or $type == 3)
476 117 78 if $type == 5 or $action_name eq '_count'
486 153 42 if (@flags) { }
488 125 16 if ($dest ne $d)
491 1 176 if grep {$f eq $_;} @{$$s{'flags'};}
496 0 152 if (exists $$self{-'position_specs'}{$dest})
500 1 41 if (exists $$self{-'option_specs'}{$dest})
526 152 41 if (@flags) { }
533 81 112 if (delete $$args{'reset'})
534 6 75 if $self->namespace
538 0 193 if keys %$args
544 3 190 if (exists $$specs{$$spec{'dest'}})
555 0 190 if $$self{-'groups'}
569 274 189 if (substr($flag, 0, 1) eq '-') { }
578 160 43 @flags ? :
595 80 2 scalar @_ ? :
614 32 50 unless $self->namespace
621 11 4 if (exists $$self{-'subparsers'} and scalar @argv and defined $argv[0] and substr($argv[0], 0, 1) ne '-')
626 1 10 unless $subparser
635 71 10 if (not $parsed_subcmd) { }
636 71 0 if @option_specs
637 32 32 if @position_specs
639 1 55 if ($self->print_usage_if_help and $self->namespace->get_attr('help'))
644 2 8 if ($self->print_usage_if_help and $self->_command eq 'help')
645 1 1 if ($self->namespace->get_attr('help_command')) { }
663 0 13 unless $alias
665 12 1 if exists $$self{-'subparsers'}{-'alias_map'}{$alias}
668 1 12 unless $command
693 0 1 unless $_[0]{-'argv'}
705 66 92 if ($$spec{'type'} == 2 or $$spec{'type'} == 3 or $$spec{'type'} == 4 or $$spec{'type'} == 1) { }
732 0 71 if $@
734 2 69 if @warns
736 0 69 unless $result
752 1 31 if $self->namespace->get_attr('help')
768 0 53 if ($$spec{'type'} == 5)
773 32 21 defined $$spec{'nargs'} ? :
774 32 21 if (defined $$spec{'nargs'})
775 5 27 if ($nargs eq '?') { }
3 24 elsif ($nargs eq '+') { }
3 21 elsif ($nargs eq '*') { }
1 20 elsif (not $nargs =~ /^\d+$/) { }
778 1 2 unless @{$$self{-'argv'};}
789 37 14 if @{$$self{-'argv'};}
794 3 48 if (scalar @$values and scalar @$values != $number)
819 198 0 if (defined $values) { }
820 90 108 if (ref $values eq 'SCALAR')
821 11 79 if (defined $$values) { }
834 8 114 if (not defined $self->namespace->get_attr($$spec{'dest'}) and scalar @$values < 1 and defined $$spec{'default'})
838 1 7 if ($$spec{'type'} == 3) { }
1 6 elsif ($$spec{'type'} == 5) { }
2 4 elsif ($$spec{'type'} == 4) { }
851 5 193 if (my $delimit = $$spec{'split'}) { }
854 3 9 $$spec{'type'} == 4 ? :
863 5 188 if ($$spec{'type'} == 4)
870 5 193 if ($$spec{'choices'})
871 2 3 if (ref $$spec{'choices'} eq 'CODE') { }
876 9 0 defined $_ ? :
882 2 0 defined $v ? :
883 1 1 if exists $choices{$k}
893 3 193 if ($$spec{'choices_i'})
894 6 0 defined $_ ? :
900 3 0 defined $v ? :
901 2 1 if exists $choices{$k}
927 111 78 unless defined $self->namespace->get_attr($$spec{'dest'})
937 1 188 if $error
955 15 171 if ($$spec{'required'} and not $self->namespace->get_attr('help'))
957 6 9 if ($$spec{'type'} == 2) { }
0 9 elsif ($$spec{'type'} == 4) { }
965 4 11 unless $has_v
987 1 0 if ($usage) { }
1001 5 0 unless $$self{-'groups'}
1009 1 4 if @$aliases
1010 2 3 if ($self->help)
1025 2 3 if ($self->description)
1032 2 30 if ($line =~ /^\s*$/) { }
1036 26 4 $para ? :
1049 3 2 if (exists $$self{-'subparsers'})
1052 1 2 if $$self{-'subparsers'}{-'description'}
1058 0 6 if $len > $max
1072 1 4 if $self->epilog
1084 0 2 unless $subp
1115 0 5 unless ($$self{-'groups'})
1125 0 5 unless $$self{-'groups'}{$group}{-'option'}
1130 3 13 $$_{'required'} ? :
3 13 $$_{'required'} ? :
1135 3 2 unless $$self{-'groups'}{$group}{-'position'}
1138 3 1 $$_{'required'} ? :
3 1 $$_{'required'} ? :
1144 3 2 if exists $$self{-'subparsers'}
1146 0 5 if ($group)
1157 10 10 if (@$output)
1176 0 20 unless $specs
1183 20 20 if $print_type == 2 and $$spec{'required'} or $print_type == 1 and not $$spec{'required'}
1188 16 4 if (@{$$spec{'flags'};})
1196 13 7 if $len > $max
1202 3 17 if (defined $$spec{'default'})
1203 1 2 if (ref $$spec{'default'} eq 'HASH') { }
2 0 elsif (ref $$spec{'default'} eq 'ARRAY') { }
1214 3 17 if (@$values)
1222 0 20 if ($$spec{'choices'} and ref $$spec{'choices'} ne 'CODE') { }
0 20 elsif ($$spec{'choices_i'}) { }
1233 0 20 if ($choices)
1237 6 14 $$spec{'required'} ? :
1276 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) { }