Branch Coverage

blib/lib/IO/Prompter.pm
Criterion Covered Total %
branch 234 548 42.7


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
239 0 0 if exists $opt_ref->{'-return'}
243 0 0 unless ref $error eq "IO::Prompter::Cancellation"
246 0 0 if $opt_ref->{'-verbatim'}
256 5 0 if (defined $input and $input =~ /\A\R?\Z/ and exists $opt_ref->{'-def'})
262 82 15 if (defined $input and not $opt_ref->{'-line'})
268 2 95 if (exists $opt_ref->{'-fail'} and match($input, $opt_ref->{'-fail'}))
273 1 96 if ($opt_ref->{'-argv'})
285 84 12 if (defined $input and $opt_ref->{'-history'} ne "NONE")
293 0 6 if ($timedout and exists $opt_ref->{'-def'})
302 27 69 if ($opt_ref->{'-yesno'}{'count'})
304 0 27 if ($succeeded and $opt_ref->{'-yesno'}{'count'} > 1)
307 0 0 $count > 1 ? :
0 0 @yesno_prompts ? :
316 6 90 if ($opt_ref->{'-verbatim'})
321 4 86 if &LIST() and not $succeeded
331 0 0 unless $timedout
333 0 0 $opt_ref->{'-timeout'} == 1 ? :
344 1 4 if ($text =~ /\A ' (.*) ' \z/msx)
353 2 2 if ($text =~ /\A " (.*) " \z/msx)
390 1 0 if ref $style or not $style =~ m[/]
394 0 0 /y/i ? :
401 0 0 if ref $style or not $style =~ m[/]
405 0 0 /y/i ? :
418 1 0 ref $arg ne 'CODE' ? :
429 2 1 if ref $constraint_spec
443 3 3 unless &$constraint($compare_val)
461 0 30 $char eq "\t" ? :
468 0 220 if (my $type = ref $arg) { }
477 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 =~ /^-indent/) { }
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+$/) { }
492 0 4 @_ && &looks_like_number($_[0]) ? :
506 0 4 @_ && &looks_like_number($_[0]) ? :
520 0 7 @_ && &looks_like_number($_[0]) ? :
534 0 5 @_ && &looks_like_number($_[0]) ? :
554 0 0 $1 ? :
565 0 3 unless @_
571 0 0 unless @_
584 0 0 unless @_
591 0 0 unless @_
599 0 0 if &looks_like_number($indent)
615 3 3 if (@_ and ref $_[0] || $_[0] =~ /$STD_CONSTRAINT/)
623 0 2 if (@_ and ref $_[0] || $_[0] =~ /$STD_CONSTRAINT/)
645 0 0 unless @_
649 0 0 if ref $option{'-def'}
652 0 5 unless @_
655 0 5 if ref $option{'-def'}
666 1 1 unless @_
669 1 0 unless &looks_like_number($option{'-timeout'})
674 0 8 unless @_
681 2 6 if ($restriction_type eq "HASH")
686 7 1 if ($restriction_type eq 'ARRAY') { }
1 0 elsif ($restriction_type eq 'Regexp') { }
696 7 0 if ($option{'-complete'} == $DEFAULT_COMPLETER)
718 0 4 if (@defaults > 1) { }
2 2 elsif (@defaults) { }
729 2 2 if (@defaults == 1)
745 0 6 unless @_
747 0 6 if ref $must ne "HASH"
757 0 0 @_ && !($_[0] =~ /^-/) ? :
760 0 0 if ref $option{'-history'}
762 0 0 length $1 ? :
766 0 0 unless @_
769 0 0 if ($comp_type =~ /\A(?: file\w* | dir\w* | ARRAY | HASH | CODE )\Z/msx) { }
780 0 0 $1 eq 'echo' ? :
781 0 0 if ($flag eq "-echo" and not eval { do { BEGIN {${^WARNING_BITS} = "\x45\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x50\x41\x50\x41\x00\x00\x01\x00\x55\x55"} require Term::ReadKey } })
784 0 0 $flag eq '-echo' ? :
0 0 @_ && !($_[0] =~ /^-/) ? :
790 1 0 unless (eval { do { BEGIN {${^WARNING_BITS} = "\x45\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x50\x41\x50\x41\x00\x00\x01\x00\x55\x55"} require Term::ReadKey } })
806 0 0 unless @_
809 0 0 if ref $option{'-prefill'}
814 0 0 unless @_
817 0 0 if ref $option{'-prompt'}
825 0 1 unless @_
826 1 0 ref $_[0] ? :
833 0 0 if not @_ or ref $_[0] ne "CODE"
845 12 206 if $redo and $arg =~ s/\A -.{$redo} (?=.)/-/msx
850 1 96 if (exists $option{'-menu'})
858 6 91 if (defined $option{'-single'} and length($option{'-echo'}->("X") // "echoself"))
863 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) { }
876 0 0 if $not_first++
896 6 91 if (exists $option{'-def'} and not $option{'-def_nocheck'})
897 0 6 unless (_verify_input_constraints(\"", undef, undef, \%option))
911 1 1 if (@_ > 3) { }
922 2 3 unless warnings::enabled($category)
925 1 2 $message =~ /\n$/ ? :
933 0 80 unless (&openhandle(\*ARGV))
935 0 0 unless open *ARGV
959 11 0 if (${$input_ref;} =~ /^\R?$/msx and exists $opt_ref->{'-def'})
960 1 10 if $opt_ref->{'-def_nocheck'}
967 4 116 if ($opt_ref->{'-integer'} and not $input =~ /$INTEGER_PAT/)
972 2 114 if (not $failed and $opt_ref->{'-number'} and not $input =~ /$NUMBER_PAT/)
979 0 36 /^\d+[.:]?\s*(.*)/s ? :
995 62 52 if (not $failed and keys %constraint_for)
999 40 22 if eval { do { no warnings; local $_ = $input; match($input, $constraint) } }
1004 5 15 $msg =~ /\A \W /msx ? :
2 20 $msg =~ /\A [[:upper:]] /msx ? :
1011 28 92 if ($failed)
1013 0 28 unless $outputter_ref
1023 0 28 if (defined $fake_input and length $fake_input > 0)
1045 0 97 if ($has_timeout and $fileno >= 0)
1052 4 93 if (defined $fake_input and length $fake_input > 0)
1062 125 0 if (not $has_timeout or select $readbits, undef, undef, $timeout) { }
1066 121 4 if (not defined $local_fake_input) { }
1080 0 4 if ($input =~ /^ \s* (?: \cD | \cZ ) /msx)
1085 0 125 if (exists $opt_ref->{'-cancel'})
1088 0 0 if match($nextchar, $opt_ref->{'-cancel'})
1092 115 10 if (defined $input)
1099 6 91 defined $input && $opt_ref->{'-single'} ? :
1148 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*$/) { }
1188 0 0 if (/\A (.*?) \R \Z/x) { }
1198 0 0 unless $common_length
1207 0 0 if @candidates <= 1
1238 97 0 unless (-t $in_fh and $has_readkey)
1248 0 0 $^O eq 'MSWin32' ? :
1258 0 0 $opt_ref->{'-timeout'} == 0 ? :
0 0 !defined($opt_ref->{'-timeout'}) ? :
1264 0 0 unless &openhandle($in_fh)
1269 0 0 if defined $prev_SIGINT and $prev_SIGINT eq "IGNORE"
1271 0 0 if not defined $prev_SIGINT or $prev_SIGINT eq "DEFAULT"
1283 0 0 if (defined $fake_input and length $fake_input > 0)
1288 0 0 exists $opt_ref->{'-prefill'} ? :
1289 0 0 if (exists $opt_ref->{'-prefill'})
1290 0 0 if (exists $opt_ref->{'-monitor'})
1314 0 0 if (exists $opt_ref->{'-cancel'} and match($next, $opt_ref->{'-cancel'}))
1320 0 0 unless (($next // "") =~ / $COMPLETE_INIT | $COMPLETE_CYCLE /msx)
1329 0 0 if (defined $next)
1334 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/) { }
1357 0 0 if ($next =~ /$COMPLETE_INIT/ and index($completion_type, $next) == -1) { }
1358 0 0 index($COMPLETE_KEY, $next) != -1 ? :
1366 0 0 if ($completion_level == 1)
1367 0 0 index($COMPLETE_KEY, $next) != -1 ? :
1376 0 0 if (@completion_list)
1382 0 0 if ($mode =~ /longest/) { }
0 0 elsif ($mode =~ /full/) { }
1389 0 0 unless ($completion_ring_first)
1390 0 0 if ($next eq $COMPLETE_PREV) { }
1403 0 0 $mode =~ /list/ ? :
1415 0 0 if (@completion_list <= 1)
1424 0 0 if (not length $input) { }
0 0 elsif ($insert_offset) { }
1429 0 0 if $insert_offset >= length $input
1450 0 0 if ($faking)
1466 0 0 length $input ? :
1474 0 0 if ($lookahead eq $FAKE_ESC) { }
1489 0 0 if ($faking and length $local_fake_input)
1507 0 0 if ($input =~ /\A\R?\Z/msx and defined $opt_ref->{'-def'})
1511 0 0 if (exists $opt_ref->{'-menu_curr_level'})
1513 0 0 if (match($def_val, $opt_ref->{'-menu_curr_level'}{$key}))
1531 0 0 if ($faking and $input =~ /^ (?: \cD | \cZ) /msx)
1541 0 0 if ($faking)
1542 0 0 length $local_fake_input ? :
1548 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'}) { }
1549 0 0 $insert_offset < length $input ? :
1552 0 0 $insert_offset > 0 ? :
1564 0 0 if (exists $opt_ref->{'-guarantee'})
1565 0 0 unless ($input . $next) =~ /$opt_ref->{'-guarantee'}/
1569 0 0 if ($insert_offset) { }
1580 0 0 if ($insert_offset or $prev_insert_offset) { }
0 0 elsif (not $next =~ /$EDIT_KEY/) { }
1608 0 0 if ($opt_ref->{'-single'} or not defined $next or $input =~ m[\Q$/\E$])
1610 0 0 if (defined $next)
1621 0 0 if (not defined $next and length $input == 0 or exists $opt_ref->{'-cancel'} and match($next, $opt_ref->{'-cancel'}))
1623 0 0 if $opt_ref->{'-verbatim'}
1631 0 0 if ($opt_ref->{'-single'} and exists $opt_ref->{'-return'} and not $input =~ /\A\R\z/)
1642 0 0 if ($opt_ref->{'-monitor'})
1650 0 0 if (not defined eval { do { $opt_ref->{'-monitor'}->($input_copy, \%opts) } } or $output_pos != &$outputter_ref(-(tell)))
1679 0 1 if ($source_type eq 'HASH') { }
0 1 elsif ($source_type eq 'SCALAR') { }
1681 0 0 $is_numeric ? :
1691 1 0 $is_numeric ? :
1692 1 0 unless (keys %value_for)
1703 0 1 if (@source)
1709 0 0 $final =~ /[A-Z]/ ? :
1 0 $is_numeric ? :
1712 1 0 $is_numeric ? :
1768 0 0 if (ref $spec eq 'ARRAY') { }
0 0 elsif (ref $spec eq 'HASH') { }
1787 0 0 $2 || exists $synonyms{$3} ? :
1793 0 0 @style ? :
1804 0 0 if (eval { do { require Term::ANSIColor } }) { }
1807 0 0 if $style eq -(tell)
1809 0 0 if ($indent_mode eq "-indent")
1816 0 0 if $style eq -(tell)
1818 0 0 if ($indent_mode eq "-indent")