Branch Coverage

blib/lib/Expect.pm
Criterion Covered Total %
branch 218 534 40.8


line true false branch
62 0 0 if defined $version and $version > $Expect::VERSION
65 0 0 if defined $version and $version < 1.03
73 0 126 if ref $class
77 0 126 unless $self
86 64 62 if (@args)
100 111 15 if (ref $class) { }
107 1 125 if exists ${*$self;}{'exp_Command'}
111 0 125 unless pipe FROM_CHILD, TO_PARENT
112 0 125 unless pipe FROM_PARENT, TO_CHILD
119 0 125 unless (defined $pid)
120 0 0 if $^W
124 108 17 if ($pid) { }
132 17 91 if $self->raw_pty and isatty($self)
137 0 108 unless defined $errstatus
139 13 95 if ($errstatus)
141 0 13 if $^W
151 0 17 unless my $slv = $self->slave
154 4 13 if $self->raw_pty
160 0 17 unless defined $errstatus
164 0 17 unless open STDIN, '<&' . $slv->fileno
167 0 17 unless open STDOUT, '>&' . $slv->fileno
170 0 17 unless open STDERR, '>&' . $slv->fileno
184 0 95 if (${*$self;}{'exp_Debug'} or ${*$self;}{'exp_Exp_Internal'})
203 0 0 unless defined $self->fileno
214 0 0 if $self->fileno == fileno STDIN
216 0 0 if ${*$self;}{'exp_Debug'}
269 0 324 unless my $type = ref $self
276 0 324 unless (exists $Readable_Vars{$name})
281 196 128 if exists ${*$self;}{$varname}
283 76 248 if (@args)
284 76 0 if (exists $Writeable_Vars{$name}) { }
286 0 76 if ($ref eq 'ARRAY') { }
0 76 elsif ($ref eq 'HASH') { }
294 0 0 if $^W
300 6 0 wantarray ? :
6 318 if $ref eq 'ARRAY'
301 0 0 wantarray ? :
0 318 if $ref eq 'HASH'
313 0 0 if (not defined $function or $function eq 'undef')
319 0 0 if (${*$self;}{'exp_Debug'})
331 0 0 unless (defined $args[0])
332 0 0 if (defined ${*$self;}{'exp_Listen_Group'}) { }
341 0 0 unless ($self->_get_mode =~ /r/)
348 0 0 unless ($write_handle->_get_mode =~ /w/)
363 0 65 if @_ < 2
367 9 56 if (${*$self;}{'exp_Log_File'} and ref ${*$self;}{'exp_Log_File'} ne 'CODE')
371 26 39 unless $file
373 23 16 unless (ref $file)
376 0 23 unless $fh = 'IO::File'->new($file, $mode)
379 23 16 if (ref $file ne 'CODE')
380 0 23 unless $fh->can('print')
396 0 0 unless defined $mode
397 0 0 unless (defined $INC{'IO/Stty.pm'})
402 0 0 if (${*$self;}{'exp_Debug'})
405 0 0 unless (POSIX::isatty($self))
406 0 0 if (${*$self;}{'exp_Debug'} or $^W)
464 0 4811 if $Expect::Debug
465 4811 0 if (defined $_[0])
466 4811 0 if (ref $_[0] and $_[0]->isa('Expect')) { }
0 0 elsif ($_[0] eq 'Expect') { }
472 0 4811 if @_ < 1
484 4811 0 if ($self) { }
491 0 0 if $_[0] ne '-i'
500 0 14323 if $Expect::Debug
502 14214 109 if (ref $parm) { }
503 14214 0 if (ref $parm eq 'ARRAY') { }
508 0 14214 if @timeout_list > 1
512 9336 4878 if $timeout_list[-1]
513 0 14214 if $err
521 21 88 if (substr($parm, 0, 1) eq '-') { }
524 0 21 if $Expect::Debug
526 0 21 if ($parm eq '-i') { }
21 0 elsif ($parm eq '-re' or $parm eq '-ex') { }
529 0 0 if (scalar @$curr_list)
530 0 0 unless exists $patterns{"$curr_list"}
537 0 0 if (ref $_[0] eq 'ARRAY') { }
545 0 21 if (ref $_[1] eq 'CODE') { }
557 0 88 if (ref $_[0] eq 'CODE') { }
558 0 0 if ($parm eq 'timeout') { }
0 0 elsif ($parm eq 'eof') { }
560 0 0 if @timeout_list > 1
565 0 0 if $timeout_list[-1]
572 0 88 if $Expect::Debug
582 0 4811 unless $curr_list
583 4811 0 unless exists $patterns{"$curr_list"}
586 4811 0 $self ? :
587 4811 0 $self ? :
591 0 4811 if (@Expect::Before_List)
592 0 0 if $debug or $internal
597 0 4811 if $debug or $internal
605 0 4811 if (@Expect::After_List)
606 0 0 if $debug or $internal
611 0 4811 wantarray ? :
620 4720 91 if ($timeout_hook)
621 0 4720 unless ref $timeout_hook eq 'CODE' or ref $timeout_hook eq 'ARRAY'
630 0 4811 if (exists ${*$exp;}{'exp_Max_Accum'} and ${*$exp;}{'exp_Max_Accum'})
638 0 0 defined $timeout ? :
0 4811 if $Expect::Debug
647 0 4811 if (${*$exp;}{'exp_Exp_Internal'})
650 0 0 defined $$pattern[0] ? :
684 9833 0 if (defined $timeout)
686 1 9832 if $time_left < 0
700 9833 0 if defined $fn
702 44 9789 unless ${*$exp;}{'exp_New_Data'}
719 0 9789 if ${*$exp;}{'exp_Exp_Internal'}
734 0 0 defined $$pattern[0] ? :
0 14795 if ${*$exp;}{'exp_Exp_Internal'}
737 119 14676 if ($$pattern[1] eq '-ex') { }
9803 4873 elsif ($$pattern[1] eq '-re') { }
742 29 90 if ($match_index > -1)
761 9789 14 if ($Expect::Multiline_Matching) { }
768 4798 5005 if (@matchlist)
773 0 4798 if $start == -1
790 4827 9968 if ($exp_matched)
792 4782 45 unless ${*$exp;}{'exp_NoTransfer'}
794 0 4827 if ${*$exp;}{'exp_Exp_Internal'}
811 0 4827 if ${*$exp;}{'exp_Exp_Internal'}
814 4778 49 if ($$pattern[3])
818 0 4778 if ${*$exp;}{'exp_Exp_Internal'} or $Expect::Debug
820 0 4778 if ($#{$pattern;} > 3) { }
828 64 4763 if ($exp_cont and $exp_cont eq exp_continue()) { }
0 4763 elsif ($exp_cont and $exp_cont eq exp_continue_timeout()) { }
830 0 64 if ${*$exp;}{'exp_Exp_Internal'} or $Expect::Debug
838 0 0 if ${*$exp;}{'exp_Exp_Internal'} or $Expect::Debug
844 0 9968 if ${*$exp;}{'exp_Exp_Internal'}
846 0 4962 if ${*$exp;}{'exp_Exp_Internal'}
854 0 0 defined $time_left ? :
0 5006 if $Expect::Exp_Internal or $Expect::Debug
862 0 5006 if ($nfound < 0)
863 0 0 if ($!{'EINTR'} and $Expect::IgnoreEintr)
864 0 0 if $Expect::Exp_Internal or $Expect::Debug
868 0 0 if $Expect::Exp_Internal or $Expect::Debug
878 69 4937 if ($nfound == 0)
885 0 69 unless defined $exp->fileno
886 36 33 unless ${*$exp;}{'exp_Error'}
889 0 69 if $Expect::Debug or $Expect::Exp_Internal
891 46 23 if ($timeout_hook)
893 0 46 if $Expect::Debug or $Expect::Exp_Internal
895 0 46 if (ref $timeout_hook eq 'CODE') { }
898 0 46 if ($#{$timeout_hook;} > 3) { }
907 44 2 if ($ret and $ret eq exp_continue())
918 0 4937 unless defined $exp->fileno
919 4937 0 if ($bits[$exp->fileno])
920 0 4937 if $Expect::Debug
928 23 4914 unless defined $nread
930 23 4914 if ($nread == 0)
931 0 23 if $Expect::Debug
940 0 9 if $Expect::Debug
942 0 9 if ($#{$eof_pat;} > 3) { }
949 0 9 if ($ret and $ret eq exp_continue() || $ret eq exp_continue_timeout())
959 23 0 if (defined ${*$exp;}{'exp_Pid'})
962 23 0 if ($ret == ${*$exp;}{'exp_Pid'})
965 0 23 if $Expect::Debug
974 0 23 if $Expect::Debug
979 0 4914 if $Expect::Debug
984 1280 3634 unless ${*$exp;}{'exp_Raw_Pty'}
988 0 4914 if (exists ${*$exp;}{'exp_Max_Accum'} and ${*$exp;}{'exp_Max_Accum'})
1000 0 4914 if exists ${*$exp;}{'exp_Continue'} and ${*$exp;}{'exp_Continue'}
1010 0 4937 if $exp_cont and $exp_cont eq exp_continue()
1017 0 4811 if ($Expect::Debug or $Expect::Exp_Internal)
1018 0 0 if ($exp_matched) { }
1023 0 0 ${*$exp_matched;}{'exp_Error'} ? :
0 0 ${*$exp_matched;}{'exp_Error'} ? :
1031 0 0 if ($Expect::Debug and $exp_matched)
1033 0 0 if (${*$exp_matched;}{'exp_Error'}) { }
1047 4763 48 if ($exp_matched)
1054 4763 0 wantarray ? :
1057 48 0 wantarray ? :
1073 0 14214 unless (ref $parm eq 'ARRAY')
1077 0 14214 if ($$parm[0] =~ /\A-/) { }
1080 0 0 if ($$parm[0] ne '-re' and $$parm[0] ne '-ex')
1086 4720 9494 if ($$parm[0] eq 'timeout') { }
4720 4774 elsif ($$parm[0] eq 'eof') { }
1087 4720 0 if (defined $timeoutlistref)
1089 4720 0 $store_parm_nr ? :
1099 9491 3 if (@$parm > 2) { }
1100 0 9491 if (ref $$parm[2] ne 'CODE')
1110 9494 0 $store_parm_nr ? :
1130 0 0 if (not defined $infile) { }
0 0 elsif (fileno $infile == fileno STDIN) { }
1147 0 0 if (defined $outfile) { }
1157 0 0 if defined $escape_sequence
1183 0 0 unless (@old_group)
1211 0 0 if ($Expect::Debug)
1227 0 0 unless (${*$handle;}{'exp_Manual_Stty'})
1232 0 0 if ${*$handle;}{'exp_Debug'}
1236 0 0 unless (${*$write_handle;}{'exp_Manual_Stty'})
1240 0 0 if ${*$handle;}{'exp_Debug'}
1246 0 0 if $Expect::Debug
1260 0 0 if exists ${*$read_handle;}{'exp_Pid'} and ${*$read_handle;}{'exp_Pid'}
1261 0 0 if (exists ${*$read_handle;}{'exp_Pid'} and ${*$read_handle;}{'exp_Pid'} and not kill(0, ${*$read_handle;}{'exp_Pid'}))
1267 0 0 if ${*$read_handle;}{'exp_Debug'}
1269 0 0 unless defined ${${*$read_handle;}{'exp_Function'};}{'EOF'}
1272 0 0 unless &{${${*$read_handle;}{'exp_Function'};}{'EOF'};}(@{${${*$read_handle;}{'exp_Parameters'};}{'EOF'};})
1280 0 0 if not defined $nfound or $nfound < 1
1284 0 0 unless defined $eout
1289 0 0 if ($bits[$read_handle->fileno])
1296 0 0 unless defined $nread
1298 0 0 if ${*$read_handle;}{'exp_Debug'} > 1
1302 0 0 unless defined $escape_character_buffer
1307 0 0 if ${*$read_handle;}{'exp_Debug'} > 1
1313 0 0 if ${*$read_handle;}{'exp_Max_Accum'}
1314 0 0 if ($escape_character_buffer =~ /($escape_sequence)/)
1316 0 0 if (${*$read_handle;}{'exp_Debug'})
1335 0 0 if (${*$read_handle;}{'exp_Pty_Buffer'} =~ /([\w\W]*)($escape_sequence)/) { }
1350 0 0 unless &{${${*$read_handle;}{'exp_Function'};}{$escape_sequence};}(@{${${*$read_handle;}{'exp_Parameters'};}{$escape_sequence};})
1353 0 0 unless defined $nread
1356 0 0 if defined ${*$read_handle;}{'exp_Pid'} and ${*$read_handle;}{'exp_Pid'}
1357 0 0 if ($nread == 0)
1359 0 0 if ${*$read_handle;}{'exp_Debug'}
1361 0 0 unless defined ${${*$read_handle;}{'exp_Function'};}{'EOF'}
1364 0 0 unless &{${${*$read_handle;}{'exp_Function'};}{'EOF'};}(@{${${*$read_handle;}{'exp_Parameters'};}{'EOF'};})
1366 0 0 if $nread < 0
1385 0 0 unless (${*$handle;}{'exp_Manual_Stty'})
1389 0 0 unless (${*$write_handle;}{'exp_Manual_Stty'})
1402 4809 132 if (${*$self;}{'exp_Log_File'})
1403 48 4761 if (ref ${*$self;}{'exp_Log_File'} eq 'CODE') { }
1418 0 4624 unless defined $self->fileno
1419 0 4624 if (${*$self;}{'exp_Exp_Internal'})
1442 0 24 unless defined $self->fileno
1455 0 1040 if ${*$self;}{'exp_Debug'} > 1
1458 1040 0 if (${*$self;}{'exp_Log_Stdout'} or ${*$self;}{'exp_Log_Group'})
1466 0 24 if not defined $ret or $ret == 0
1474 0 24 if ${*$self;}{'exp_Max_Accum'}
1479 0 24 if ${*$self;}{'exp_Debug'} > 1
1496 0 0 unless defined $allmask
1500 0 0 unless $nfound
1510 0 0 if (defined $bits[$handle->fileno] and $bits[$handle->fileno])
1530 0 7 if ${*$self;}{'exp_Debug'}
1531 0 7 unless defined $self->fileno
1532 7 0 unless (exists ${*$self;}{'exp_Has_EOF'} and ${*$self;}{'exp_Has_EOF'})
1538 0 10 if $select_time < 0
1542 0 10 unless defined $nfound and $nfound
1546 7 3 unless (defined $nread and $nread)
1548 0 7 if ${*$self;}{'exp_Debug'}
1553 0 7 if ($end_time <= time and ${*$self;}{'exp_Debug'})
1558 0 7 if ($close_status and ${*$self;}{'exp_Debug'})
1563 0 7 unless defined ${*$self;}{'exp_Pid'}
1571 7 0 if (defined $returned_pid and $returned_pid)
1573 0 7 if (${*$self;}{'exp_Debug'})
1588 0 0 if (${*$self;}{'exp_Debug'})
1597 0 0 if (defined $returned_pid and $returned_pid)
1599 0 0 if (${*$self;}{'exp_Debug'})
1621 0 167 if ${*$self;}{'exp_Debug'}
1625 0 167 if ($close_status and ${*$self;}{'exp_Debug'})
1630 89 78 unless defined ${*$self;}{'exp_Pid'}
1638 78 25 if (defined $returned_pid and $returned_pid)
1640 0 78 if (${*$self;}{'exp_Debug'})
1655 0 0 if (${*$self;}{'exp_Debug'})
1664 0 0 if (defined $returned_pid and $returned_pid)
1666 0 0 if (${*$self;}{'exp_Debug'})
1685 0 0 if (defined $returned_pid and $returned_pid)
1687 0 0 if (${*$self;}{'exp_Debug'})
1712 0 126 if defined $Expect::Log_Stdout
1739 0 0 unless defined $s
1767 2 15 unless defined $string
1773 0 7 if defined $self and ${*$self;}{'exp_Debug'} >= 3 and not defined $length
1775 5 10 $length ? :
1777 7 8 if $length >= length $string
1790 4941 0 if (${*$self;}{'exp_Log_Group'})
1792 0 0 unless defined $print_this
1798 0 0 if ${*$handle;}{'exp_Debug'} > 1
1805 138 4803 if ${*$self;}{'exp_Log_Stdout'}
1819 0 0 unless defined $fcntl_flags
1821 0 0 if ($fcntl_flags | 2) { }
0 0 elsif ($fcntl_flags | 1) { }
1845 0 109 if (${*$self;}{'exp_Do_Soft_Close'})