Branch Coverage

blib/lib/IO/Prompter.pm
Criterion Covered Total %
branch 234 542 43.1


line true false branch
88 0 42 if (defined $config_data and $config_data eq '-argv') { }
3 39 elsif (ref $config_data eq 'ARRAY') { }
2 37 elsif (ref $config_data eq 'HASH') { }
2 35 elsif (defined $config_data) { }
136 2 95 if &VOID() and not $opt_ref->{'-void'}
140 0 97 ($opt_ref->{'-yesno'}{'count'} // 0) > 1 ? :
145 0 97 unless (&openhandle($in_filehandle))
146 0 0 unless open my $fh, "<", $in_filehandle
150 0 97 unless (&openhandle($out_filehandle))
151 0 0 unless open my $fh, ">", $out_filehandle
160 0 97 unless &openhandle($in_filehandle) and &openhandle($out_filehandle)
163 0 97 -t $in_filehandle && -t $out_filehandle ? :
172 0 97 if ($opt_ref->{'-wipe'})
180 1 96 if ($opt_ref->{'-menu'}) { }
197 0 1 unless defined $tag
201 0 1 if ($tag eq $MENU_ESC)
203 0 0 if @menu <= 1
209 1 0 if ($tag =~ /\A\R?\Z/ and exists $opt_ref->{'-def'})
216 0 0 unless ref $input
238 0 0 if exists $opt_ref->{'-return'}
242 0 0 unless ref $error eq "IO::Prompter::Cancellation"
245 0 0 if $opt_ref->{'-verbatim'}
254 5 0 if (defined $input and $input =~ /\A\R?\Z/ and exists $opt_ref->{'-def'})
260 82 15 if (defined $input and not $opt_ref->{'-line'})
265 2 95 if (exists $opt_ref->{'-fail'} and match($input, $opt_ref->{'-fail'}))
270 1 96 if ($opt_ref->{'-argv'})
282 84 12 if (defined $input and $opt_ref->{'-history'} ne "NONE")
289 0 6 if ($timedout and exists $opt_ref->{'-def'})
298 27 69 if ($opt_ref->{'-yesno'}{'count'})
300 0 27 if ($succeeded and $opt_ref->{'-yesno'}{'count'} > 1)
303 0 0 $count > 1 ? :
0 0 @yesno_prompts ? :
312 6 90 if ($opt_ref->{'-verbatim'})
317 4 86 if &LIST() and not $succeeded
327 0 0 unless $timedout
329 0 0 $opt_ref->{'-timeout'} == 1 ? :
340 1 4 if ($text =~ /\A ' (.*) ' \z/msx)
349 2 2 if ($text =~ /\A " (.*) " \z/msx)
386 1 0 if ref $style or not $style =~ m[/]
390 0 0 /y/i ? :
397 0 0 if ref $style or not $style =~ m[/]
401 0 0 /y/i ? :
414 1 0 ref $arg ne 'CODE' ? :
425 2 1 if ref $constraint_spec
439 3 3 unless &$constraint($compare_val)
457 0 30 $char eq "\t" ? :
463 0 220 if (my $type = ref $arg) { }
472 6 214 if ($arg =~ /^-_/) { }
1 213 elsif ($arg =~ /^-line$/) { }
4 209 elsif ($arg =~ /^-l/) { }
4 205 elsif ($arg =~ /^-YesNo$/) { }
1 204 elsif ($arg =~ /^-YN/) { }
4 200 elsif ($arg =~ /^-yesno$/) { }
4 196 elsif ($arg =~ /^-yn/) { }
7 189 elsif ($arg =~ /^-Yes$/) { }
1 188 elsif ($arg =~ /^-Y/) { }
5 183 elsif ($arg =~ /^-yes$/) { }
1 182 elsif ($arg =~ /^-y/) { }
1 181 elsif ($arg =~ /^-argv$/) { }
0 181 elsif ($arg =~ /^-a/) { }
0 181 elsif ($arg =~ /^-wipe(first)?$/) { }
0 181 elsif ($arg =~ /^-w/) { }
3 178 elsif ($arg =~ /^-fail$/) { }
0 178 elsif ($arg =~ /^-cancel/) { }
0 178 elsif ($arg =~ /^-f(?:ilenames?)?$/) { }
0 178 elsif ($arg =~ /^-style/) { }
0 178 elsif ($arg =~ /^-echostyle/) { }
0 178 elsif ($arg =~ /^-stdio$/) { }
17 161 elsif ($arg =~ /^-in$/) { }
6 155 elsif ($arg =~ /^-out$/) { }
6 149 elsif ($arg =~ /^-integer$/) { }
2 147 elsif ($arg =~ /^-num(?:ber)?$/) { }
1 146 elsif ($arg =~ /^-i/) { }
1 145 elsif ($arg =~ /^-n/) { }
1 144 elsif ($arg =~ /^-void$/) { }
3 141 elsif ($arg =~ /^-verb(?:atim)?$/) { }
3 138 elsif ($arg =~ /^-v/) { }
1 137 elsif ($arg =~ /^-sing(?:le)?$/) { }
5 132 elsif ($arg =~ /^-[s1]/) { }
0 132 elsif ($arg =~ /^-DEF(?:AULT)?/) { }
5 127 elsif ($arg =~ /^-def(?:ault)?/) { }
2 125 elsif ($arg =~ /^-d(.+)$/) { }
1 124 elsif ($arg =~ /^-t(\d+)/) { }
2 122 elsif ($arg =~ /^-timeout$/) { }
8 114 elsif ($arg =~ /^-g.*/) { }
4 110 elsif ($arg =~ /-keyletters_implement/) { }
2 108 elsif ($arg =~ /^-key(?:let(?:ter)?)(?:s)?/) { }
2 106 elsif ($arg =~ /^-k/) { }
6 100 elsif ($arg =~ /^-must$/) { }
0 100 elsif ($arg =~ /^-history/) { }
0 100 elsif ($arg =~ /^-h(.*)/) { }
0 100 elsif ($arg =~ /^-comp(?:lete)?/) { }
0 100 elsif ($arg =~ /^-(echo|ret(?:urn)?)$/) { }
1 99 elsif ($arg =~ /^-e(.*)/) { }
0 99 elsif ($arg =~ /^-r(.+)/) { }
0 99 elsif ($arg =~ /^-r/) { }
0 99 elsif ($arg =~ /^-prefill/) { }
0 99 elsif ($arg =~ /^-prompt$/) { }
0 99 elsif ($arg =~ /^-p(\S*)$/) { }
1 98 elsif ($arg =~ /^-menu$/) { }
0 98 elsif ($arg =~ /^-monitor/) { }
2 96 elsif ($arg =~ /^-\w+$/) { }
487 0 4 @_ && &looks_like_number($_[0]) ? :
501 0 4 @_ && &looks_like_number($_[0]) ? :
515 0 7 @_ && &looks_like_number($_[0]) ? :
529 0 5 @_ && &looks_like_number($_[0]) ? :
549 0 0 $1 ? :
560 0 3 unless @_
566 0 0 unless @_
579 0 0 unless @_
586 0 0 unless @_
603 3 3 if (@_ and ref $_[0] || $_[0] =~ /$STD_CONSTRAINT/)
611 0 2 if (@_ and ref $_[0] || $_[0] =~ /$STD_CONSTRAINT/)
633 0 0 unless @_
637 0 0 if ref $option{'-def'}
640 0 5 unless @_
643 0 5 if ref $option{'-def'}
654 1 1 unless @_
657 1 0 unless &looks_like_number($option{'-timeout'})
662 0 8 unless @_
669 2 6 if ($restriction_type eq "HASH")
674 7 1 if ($restriction_type eq 'ARRAY') { }
1 0 elsif ($restriction_type eq 'Regexp') { }
684 7 0 if ($option{'-complete'} == $DEFAULT_COMPLETER)
706 0 4 if (@defaults > 1) { }
2 2 elsif (@defaults) { }
717 2 2 if (@defaults == 1)
733 0 6 unless @_
735 0 6 if ref $must ne "HASH"
745 0 0 @_ && !($_[0] =~ /^-/) ? :
748 0 0 if ref $option{'-history'}
750 0 0 length $1 ? :
754 0 0 unless @_
757 0 0 if ($comp_type =~ /\A(?: file\w* | dir\w* | ARRAY | HASH | CODE )\Z/msx) { }
768 0 0 $1 eq 'echo' ? :
769 0 0 if ($flag eq "-echo" and not eval { do { BEGIN {${^WARNING_BITS} = "\x44\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x45\x05"} require Term::ReadKey } })
772 0 0 $flag eq '-echo' ? :
0 0 @_ && !($_[0] =~ /^-/) ? :
778 1 0 unless (eval { do { BEGIN {${^WARNING_BITS} = "\x44\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15\x00\x04\x40\x45\x05"} require Term::ReadKey } })
794 0 0 unless @_
797 0 0 if ref $option{'-prefill'}
802 0 0 unless @_
805 0 0 if ref $option{'-prompt'}
813 0 1 unless @_
814 1 0 ref $_[0] ? :
821 0 0 if not @_ or ref $_[0] ne "CODE"
833 12 206 if $redo and $arg =~ s/\A -.{$redo} (?=.)/-/msx
838 1 96 if (exists $option{'-menu'})
846 6 91 if (defined $option{'-single'} and length($option{'-echo'}->("X") // "echoself"))
851 1 96 if ($option{'-argv'}) { }
3 93 elsif (not defined $option{'-prompt'}) { }
79 14 elsif ($option{'-prompt'} =~ / \S \z/msx) { }
0 14 elsif ($option{'-prompt'} =~ / (.*) \n \z/msx) { }
864 0 0 if $not_first++
884 6 91 if (exists $option{'-def'} and not $option{'-def_nocheck'})
885 0 6 unless (_verify_input_constraints(\"", undef, undef, \%option))
899 1 1 if (@_ > 3) { }
910 2 3 unless warnings::enabled($category)
913 1 2 $message =~ /\n$/ ? :
921 0 80 unless (&openhandle(\*ARGV))
923 0 0 unless open *ARGV
947 11 0 if (${$input_ref;} =~ /^\R?$/msx and exists $opt_ref->{'-def'})
948 1 10 if $opt_ref->{'-def_nocheck'}
955 4 116 if ($opt_ref->{'-integer'} and not $input =~ /$INTEGER_PAT/)
960 2 114 if (not $failed and $opt_ref->{'-number'} and not $input =~ /$NUMBER_PAT/)
967 0 36 /^\d+[.:]?\s*(.*)/s ? :
983 62 58 if (not $failed and keys %constraint_for)
987 40 22 if eval { do { no warnings; local $_ = $input; match($input, $constraint) } }
992 5 15 $msg =~ /\A \W /msx ? :
2 20 $msg =~ /\A [[:upper:]] /msx ? :
999 28 92 if ($failed)
1001 0 28 unless $outputter_ref
1011 0 28 if (defined $fake_input and length $fake_input > 0)
1033 0 97 if ($has_timeout and $fileno >= 0)
1040 4 93 if (defined $fake_input and length $fake_input > 0)
1050 125 0 if (not $has_timeout or select $readbits, undef, undef, $timeout) { }
1054 121 4 if (not defined $local_fake_input) { }
1068 0 4 if ($input =~ /^ \s* (?: \cD | \cZ ) /msx)
1073 0 125 if (exists $opt_ref->{'-cancel'})
1076 0 0 if match($nextchar, $opt_ref->{'-cancel'})
1080 115 10 if (defined $input)
1087 6 91 defined $input && $opt_ref->{'-single'} ? :
1136 0 0 if ($completer_type eq 'CODE') { }
0 0 elsif ($completer_type eq 'ARRAY') { }
0 0 elsif ($completer_type eq 'HASH') { }
0 0 elsif ($completer_type eq /^file\w*$/) { }
0 0 elsif ($completer_type eq /^dir\w*$/) { }
1176 0 0 /\A (.*?) \R \Z/x ? :
1186 0 0 unless $common_length
1195 0 0 if @candidates <= 1
1226 97 0 unless (-t $in_fh and $has_readkey)
1236 0 0 $^O eq 'MSWin32' ? :
1246 0 0 $opt_ref->{'-timeout'} == 0 ? :
0 0 !defined($opt_ref->{'-timeout'}) ? :
1252 0 0 unless &openhandle($in_fh)
1257 0 0 if $prev_SIGINT eq "IGNORE"
1259 0 0 if not defined $prev_SIGINT or $prev_SIGINT eq "DEFAULT"
1271 0 0 if (defined $fake_input and length $fake_input > 0)
1276 0 0 exists $opt_ref->{'-prefill'} ? :
1277 0 0 if (exists $opt_ref->{'-prefill'})
1278 0 0 if (exists $opt_ref->{'-monitor'})
1302 0 0 if (exists $opt_ref->{'-cancel'} and match($next, $opt_ref->{'-cancel'}))
1308 0 0 unless (($next // "") =~ / $COMPLETE_INIT | $COMPLETE_CYCLE /msx)
1317 0 0 if (defined $next)
1322 0 0 if ($next eq $ctrl{'INTERRUPT'}) { }
0 0 elsif (not $prev_was_verbatim and $next eq $VERBATIM_KEY) { }
0 0 elsif (not $prev_was_verbatim and $next =~ /$COMPLETE_INIT/ || $completion_level > 0 && $next =~ /$COMPLETE_CYCLE/) { }
0 0 elsif (not $prev_was_verbatim and $next eq $ctrl{'ERASE'}) { }
0 0 elsif (not $prev_was_verbatim and $next eq $ctrl{'EOF'}) { }
0 0 elsif (not $prev_was_verbatim and $faking and $next eq $FAKE_ESC) { }
0 0 elsif (not $prev_was_verbatim and $next =~ /\A\R\z/) { }
0 0 elsif ($prev_was_verbatim or not $next =~ /$ctrl/) { }
1345 0 0 if ($next =~ /$COMPLETE_INIT/ and index($completion_type, $next) < 0) { }
1346 0 0 index($COMPLETE_KEY, $next) >= 0 ? :
1354 0 0 if ($completion_level == 1)
1355 0 0 index($COMPLETE_KEY, $next) >= 0 ? :
1364 0 0 if (@completion_list)
1370 0 0 if ($mode =~ /longest/) { }
0 0 elsif ($mode =~ /full/) { }
1377 0 0 unless ($completion_ring_first)
1378 0 0 if ($next eq $COMPLETE_PREV) { }
1391 0 0 $mode =~ /list/ ? :
1403 0 0 if (@completion_list <= 1)
1412 0 0 if (not length $input) { }
0 0 elsif ($insert_offset) { }
1417 0 0 if $insert_offset >= length $input
1438 0 0 if ($faking)
1454 0 0 length $input ? :
1462 0 0 if ($lookahead eq $FAKE_ESC) { }
1477 0 0 if ($faking and length $local_fake_input)
1495 0 0 if ($input =~ /\A\R?\Z/msx and defined $opt_ref->{'-def'})
1499 0 0 if (exists $opt_ref->{'-menu_curr_level'})
1501 0 0 if (match($def_val, $opt_ref->{'-menu_curr_level'}{$key}))
1519 0 0 if ($faking and $input =~ /^ (?: \cD | \cZ) /msx)
1529 0 0 if ($faking)
1530 0 0 length $local_fake_input ? :
1536 0 0 if ($next eq $EDIT{'BACK'}) { }
0 0 elsif ($next eq $EDIT{'FORWARD'}) { }
0 0 elsif ($next eq $EDIT{'START'}) { }
0 0 elsif ($next eq $EDIT{'END'}) { }
1537 0 0 $insert_offset < length $input ? :
1540 0 0 $insert_offset > 0 ? :
1552 0 0 if (exists $opt_ref->{'-guarantee'})
1553 0 0 unless ($input . $next) =~ /$opt_ref->{'-guarantee'}/
1557 0 0 if ($insert_offset) { }
1568 0 0 if ($insert_offset or $prev_insert_offset) { }
0 0 elsif (not $next =~ /$EDIT_KEY/) { }
1596 0 0 if ($opt_ref->{'-single'} or not defined $next or $input =~ m[\Q$/\E$])
1598 0 0 if (defined $next)
1609 0 0 if (not defined $next and length $input == 0 or exists $opt_ref->{'-cancel'} and match($next, $opt_ref->{'-cancel'}))
1611 0 0 if $opt_ref->{'-verbatim'}
1619 0 0 if ($opt_ref->{'-single'} and exists $opt_ref->{'-return'} and not $input =~ /\A\R\z/)
1630 0 0 if ($opt_ref->{'-monitor'})
1638 0 0 if (not defined eval { do { $opt_ref->{'-monitor'}->($input_copy, \%opts) } } or $output_pos != &$outputter_ref(-(tell)))
1667 0 1 if ($source_type eq 'HASH') { }
0 1 elsif ($source_type eq 'SCALAR') { }
1 0 elsif ($source_type eq 'ARRAY') { }
1669 0 0 $is_numeric ? :
1683 1 0 $is_numeric ? :
1684 1 0 unless (keys %value_for)
1694 0 1 if (@source)
1702 0 0 $final =~ /[A-Z]/ ? :
1 0 $is_numeric ? :
1705 1 0 $is_numeric ? :
1761 0 0 if (ref $spec eq 'ARRAY') { }
0 0 elsif (ref $spec eq 'HASH') { }
1780 0 0 $2 || exists $synonyms{$3} ? :
1786 0 0 @style ? :
1796 0 0 if (eval { do { require Term::ANSIColor } }) { }
1799 0 0 if $style eq -(tell)
1808 0 0 if $style eq -(tell)