Branch Coverage

lib/Getopt/ArgParse/Parser.pm
Criterion Covered Total %
branch 257 302 85.1


line true false branch
144 0 18 unless $parent_class and $parent_class->isa('Getopt::ArgParse::Parser')
152 0 5 unless $parent
163 0 7 unless $parent
173 0 6 unless $parent
176 2 4 if (exists $$parent{-'subparsers'})
183 2 4 if $command eq 'help'
200 1 15 if scalar(@_) % 2
207 1 14 if keys %$args
212 1 13 if (exists $$self{-'subparsers'})
246 1 35 unless $$self{-'subparsers'}
250 1 34 unless $command
252 1 33 if scalar(@_) % 2
254 1 32 if (exists $$self{-'subparsers'}{-'parsers'}{$command})
263 0 32 unless $$self{-'subparsers'}
269 1 31 if ref $aliases ne 'ARRAY'
272 1 30 if keys %$args
280 1 34 if (exists $$self{-'subparsers'}{-'alias_map'}{$alias})
326 1 200 unless @_
336 1 199 if scalar(@$rest) % 2
338 1 198 unless $name
351 197 1 if exists $Type2ConstMap{$type_name}
352 1 197 unless defined $type
356 28 169 if (defined $nargs)
357 1 27 if @flags
359 3 14 if ($type != 4 and $type != 2 and $nargs ne '1' and $nargs ne '?')
368 10 186 if ($type == 3) { }
23 163 elsif ($type == 2 or $type == 4) { }
369 10 0 unless defined $$args{'action'}
370 9 1 unless defined $$args{'default'}
372 23 0 unless defined $$args{'action'}
382 196 0 if exists $Action2ClassMap{$action_name}
385 0 196 unless $action
393 0 196 if $@
400 0 3 if (defined $split and not $split and $split =~ /^ +$/)
404 0 3 if (defined $split and $type != 2 and $type != 4)
412 20 176 if (exists $$args{'default'})
415 2 18 if (ref $val eq 'ARRAY') { }
5 13 elsif (ref $val eq 'HASH') { }
418 1 4 if $type != 4
425 15 4 if ($type != 4)
426 1 14 if ($type != 2 and scalar @$default > 1)
436 0 3 if ($choices and ref $choices ne 'CODE' and ref $choices ne 'ARRAY')
445 1 193 if ($choices and $choices_i)
449 1 192 if ($choices_i and ref $choices_i ne 'ARRAY')
460 117 75 if ($type == 5 or $type == 3)
474 117 75 if $type == 5 or $action_name eq '_count'
484 152 40 if (@flags) { }
486 123 16 if ($dest ne $d)
489 1 172 if grep {$f eq $_;} @{$$s{'flags'};}
494 0 151 if (exists $$self{-'position_specs'}{$dest})
498 1 39 if (exists $$self{-'option_specs'}{$dest})
524 151 39 if (@flags) { }
531 81 109 if (delete $$args{'reset'})
532 6 75 if $self->namespace
536 0 190 if keys %$args
542 3 187 if (exists $$specs{$$spec{'dest'}})
553 0 187 if $$self{-'groups'}
567 272 186 if (substr($flag, 0, 1) eq '-') { }
576 159 41 @flags ? :
593 80 2 scalar @_ ? :
612 32 50 unless $self->namespace
619 11 4 if (exists $$self{-'subparsers'} and scalar @argv and defined $argv[0] and substr($argv[0], 0, 1) ne '-')
624 1 10 unless $subparser
633 71 10 if (not $parsed_subcmd) { }
634 71 0 if @option_specs
635 32 32 if @position_specs
637 1 55 if ($self->print_usage_if_help and $self->namespace->get_attr('help'))
642 2 8 if ($self->print_usage_if_help and $self->_command eq 'help')
643 1 1 if ($self->namespace->get_attr('help_command')) { }
661 0 13 unless $alias
663 12 1 if exists $$self{-'subparsers'}{-'alias_map'}{$alias}
666 1 12 unless $command
691 0 1 unless $_[0]{-'argv'}
703 66 92 if ($$spec{'type'} == 2 or $$spec{'type'} == 3 or $$spec{'type'} == 4 or $$spec{'type'} == 1) { }
730 0 71 if $@
732 2 69 if @warns
734 0 69 unless $result
750 1 31 if $self->namespace->get_attr('help')
766 0 53 if ($$spec{'type'} == 5)
771 32 21 defined $$spec{'nargs'} ? :
772 32 21 if (defined $$spec{'nargs'})
773 5 27 if ($nargs eq '?') { }
3 24 elsif ($nargs eq '+') { }
3 21 elsif ($nargs eq '*') { }
1 20 elsif (not $nargs =~ /^\d+$/) { }
776 1 2 unless @{$$self{-'argv'};}
787 37 14 if @{$$self{-'argv'};}
792 3 48 if (scalar @$values and scalar @$values != $number)
817 198 0 if (defined $values) { }
818 90 108 if (ref $values eq 'SCALAR')
819 11 79 if (defined $$values) { }
832 8 114 if (not defined $self->namespace->get_attr($$spec{'dest'}) and scalar @$values < 1 and defined $$spec{'default'})
836 1 7 if ($$spec{'type'} == 3) { }
1 6 elsif ($$spec{'type'} == 5) { }
2 4 elsif ($$spec{'type'} == 4) { }
849 5 193 if (my $delimit = $$spec{'split'}) { }
852 3 9 $$spec{'type'} == 4 ? :
861 5 188 if ($$spec{'type'} == 4)
868 5 193 if ($$spec{'choices'})
869 2 3 if (ref $$spec{'choices'} eq 'CODE') { }
874 9 0 defined $_ ? :
880 2 0 defined $v ? :
881 1 1 if exists $choices{$k}
891 3 193 if ($$spec{'choices_i'})
892 6 0 defined $_ ? :
898 3 0 defined $v ? :
899 2 1 if exists $choices{$k}
925 111 78 unless defined $self->namespace->get_attr($$spec{'dest'})
935 1 188 if $error
953 15 171 if ($$spec{'required'} and not $self->namespace->get_attr('help'))
955 6 9 if ($$spec{'type'} == 2) { }
0 9 elsif ($$spec{'type'} == 4) { }
963 4 11 unless $has_v
985 1 0 if ($usage) { }
999 5 0 unless $$self{-'groups'}
1007 1 4 if @$aliases
1020 2 3 if ($self->description)
1027 2 30 if ($line =~ /^\s*$/) { }
1031 26 4 $para ? :
1046 3 2 if (exists $$self{-'subparsers'})
1049 1 2 if $$self{-'subparsers'}{-'description'}
1055 0 6 if $len > $max
1071 1 4 if $self->epilog
1083 0 2 unless $subp
1114 0 5 unless ($$self{-'groups'})
1124 0 5 unless $$self{-'groups'}{$group}{-'option'}
1129 2 13 $$_{'required'} ? :
2 13 $$_{'required'} ? :
1134 4 1 unless $$self{-'groups'}{$group}{-'position'}
1137 2 0 $$_{'required'} ? :
2 0 $$_{'required'} ? :
1143 3 2 if exists $$self{-'subparsers'}
1145 0 5 if ($group)
1149 1 4 if (@position_specs)
1154 5 0 if (@option_specs)
1168 0 6 unless $specs
1181 11 6 if $len > $max
1187 3 14 if (defined $$spec{'default'})
1188 1 2 if (ref $$spec{'default'} eq 'HASH') { }
2 0 elsif (ref $$spec{'default'} eq 'ARRAY') { }
1199 3 14 if (@$values)
1207 0 17 if ($$spec{'choices'} and ref $$spec{'choices'} ne 'CODE') { }
0 17 elsif ($$spec{'choices_i'}) { }
1218 0 17 if ($choices)
1222 4 13 $$spec{'required'} ? :
1262 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) { }