Branch Coverage

blib/lib/IO/ReadPreProcess.pm
Criterion Covered Total %
branch 308 436 70.6


line true false branch
82 59 0 unless defined $self->{'OutStreams'}{'STDOUT'}
83 59 0 unless defined $self->{'OutStreams'}{'STDERR'}
87 59 0 unless (defined $self->{'DirStartRE'})
96 59 0 unless defined $self->{'Math'}
98 59 0 unless ($self->{'Math'}{'VarHash'}{'_Initialised'})
118 61 57 if (defined $self->{$_})
125 59 0 if (defined $opts{'File'})
126 2 57 if (defined $opts{'Fd'}) { }
130 0 57 unless $self->open('binmode', '', %opts)
148 0 57 unless defined $args{'File'}
156 57 0 if (not defined $args{'Fd'}) { }
157 0 57 unless $Fd = $self->openFile($args{'Name'})
173 0 87 unless $Fd = 'IO::File'->new($name, 'r')
178 0 87 if $self->{'Frame'}{'binmode'}
196 199 259 if (defined $args{'Args'})
207 1157 2049 if defined $args{$p}
209 2281 925 if (defined $self->{'Frame'} and defined $self->{'Frame'}{$p})
210 1535 746 unless defined $f{$p}
241 0 134 unless $self->closeFrame
253 0 458 unless defined $self->{'Frame'}{'Code'} or defined $self->{'Frame'}{'Fd'}
256 0 458 if $self->error
268 201 257 if ($self->{'Frame'}{'LocalVars'})
273 227 226 if defined $alist->{$k}
281 32 234 if $self->{'Frame'}{'Code'} and $old->{'CpMove'}
297 0 0 unless $self->{'Frame'}{'Fd'}
308 0 0 unless $self->{'Fd'}
324 5 27 if (substr($name, 0, 1) eq '$')
325 0 5 unless $name =~ m[^\$(\w+)(/.+)$]i
331 0 5 unless $pt = $self->{'Math'}->Parse($var) and @val = $self->{'Math'}->Eval($pt)
336 0 12 unless $fp
337 5 7 if -e $fp
341 0 0 if $noerr
359 4 35 if index($name, '/') == 0
362 9 26 if (substr($name, 0, 1) eq '#')
373 0 26 if $self->{'TopIsFd'} and @{$self->{'FrameStk'};} == 1
379 0 26 unless $last = $self->GetLastFileName
395 26 22 if exists $self->{'FrameStk'}[$frames]{'Fd'}
411 0 838 if ($2 eq '0') { }
1 837 elsif ($2 eq 'e') { }
837 0 elsif ($2 eq 'v') { }
416 0 837 unless $arg =~ s/^{(\w+|\w+\[\w+\])}//i
420 0 837 unless defined $vv
427 0 2857 if $arg =~ /\\/
445 10 2459 if ($c1 eq '"' or $c1 eq q[']) { }
447 0 10 unless $arg =~ s/^(["'])((\\{2})*|(.*?[^\\](\\{2})*))\1\s*//
459 557 38 if $doEsc
477 0 38 unless $arg ne ''
480 0 38 unless @args = $self->SplitArgs($arg, 0)
485 0 38 unless $code->{'Name'} =~ /^\w+$/
488 0 38 if exists $self->{'subs'}{$code->{'Name'}}
494 9 29 if @args
562 347 219 if ($InLine =~ /^($self->{'DirStartRE'})(\w+)\s*(.*)/ and defined $ctlDirectives{$2} || defined $self->{'subs'}{$2}) { }
564 219 0 unless defined $frame->{'Code'}
572 41 306 if (exists $loops{$dir})
575 3 38 if $arg =~ s/^-i\s*(\d+)\s*//
579 0 41 unless $arg ne ''
583 14 27 if ($dir eq 'for')
586 0 14 unless @e == 3
589 11 3 if $e[0] =~ /\S/
591 0 14 unless $e[1] =~ /\S/
594 11 3 if ($e[2] =~ /\S/)
596 0 11 unless $line->{'For3'} = $self->{'Math'}->Parse($e[2])
604 89 258 if (exists $makeExpr{$dir})
606 43 46 if (substr($arg, 0, length $self->{'DirStart'}) eq $self->{'DirStart'}) { }
610 0 46 unless $arg =~ /\S/ and $line->{'Expr'} = $self->{'Math'}->Parse($arg)
614 100 247 if (defined $blkPairs{$dir}) { }
100 147 elsif (defined $blkPairs{$blocks[-1]{'type'}} and $blkPairs{$blocks[-1]{'type'}} eq $dir) { }
0 147 elsif (defined $endings{$dir}) { }
624 0 100 if $arg =~ /(\S+)/ and $blk->{'type'} ne $1
627 41 59 if (exists $loops{$blk->{'type'}})
642 55 292 if $dir eq 'done' and @blocks == 0
648 0 511 unless ($InLine = $self->{'Frame'}{'Fd'}->getline)
671 112 53 if ($code->{'ArgNames'} and @{$code->{'ArgNames'};})
678 223 5 if @args
694 282 193 if ($esc = exists $replay->{'SubCond'} or substr($arg, 0, length $self->{'DirStart'}) eq $self->{'DirStart'} and $arg =~ /^$self->{'DirStartRE'}(\w+)\s*(.*)/) { }
698 244 38 if $esc
703 66 216 unless (exists $self->{'subs'}{$sub})
705 0 66 unless exists $condDirectives{$sub}
709 141 141 if ($self->{'Frame'}{'CondReRun'}) { }
716 122 19 if ($esc) { }
722 33 108 if ($intDir) { }
740 19 122 unless $esc
743 0 141 if $self->{'Frame'}{'intDir'}
745 122 19 if $esc
750 158 35 if ($replay and exists $replay->{'Expr'}) { }
754 0 35 unless $iftree = $self->{'Math'}->Parse($arg)
760 35 299 if $replay->{'Not'}
773 458 0 unless $self->{'Error'}
781 0 0 unless $self->{'Fd'} and $self->{'Fd'}->opened
796 0 0 if $self->{'OnError'} eq 'die'
797 0 0 if $self->{'OnError'} eq 'warn'
799 0 0 if ($einval)
823 1012 2 if $self->{'out'} eq ''
836 0 5 unless (defined $strm)
841 4 1 if (ref $strm eq 'IO::File' or ref $strm eq 'IO::Handle')
845 1 0 if (ref $strm eq 'CODE')
863 0 1014 unless defined $self->{'Frame'}{'Code'} or defined $self->{'Frame'}{'Fd'}
871 0 3043 if $self->{'Error'}
874 59 2984 unless @{$self->{'FrameStk'};}
880 19 2965 if (defined($_ = pop @{$$frame{'PushedInput'};})) { }
1713 1252 elsif (exists $frame->{'Code'}) { }
886 83 1630 if ($frame->{'CodeLine'} > $frame->{'Code'}{'LastLine'})
899 78 1174 unless ($_)
903 0 78 unless $self->closeFrame
906 78 0 if $self->{'Frame'}
912 0 1174 if ($self->{'Raw'})
933 534 2333 if (/^$self->{'DirStartRE'}#/)
934 0 534 if $self->{'trace'}
938 2333 0 if $self->{'Trim'}
942 616 1717 unless (/^($self->{'DirStartRE'})(\w+)\s*(.*)/ and defined $ctlDirectives{$2} || defined $self->{'subs'}{$2})
944 60 556 unless ($frame->{'Generate'})
949 0 556 if $self->{'trace'} > 1
960 0 0 if $self->{'trace'} and $frame->{'Generate'}
966 100 1617 if ($dir eq 'if' or $dir eq 'unless')
969 77 23 unless $frame->{'CondReRun'}
976 100 0 if ($frame->{'Generate'})
980 0 100 unless defined $gen
982 23 77 if $frame->{'CondReRun'}
988 29 1588 if ($dir eq 'elseif' or $dir eq 'elsif')
990 0 29 unless $frame->{'Type'} eq 'if' or $frame->{'Type'} eq 'unless'
992 0 29 if $frame->{'Else'}
999 27 2 if ($frame->{'ParentGenerate'} and not $frame->{'DidGenerate'}) { }
1002 0 27 unless defined $gen
1005 12 15 if $frame->{'CondReRun'}
1013 41 1547 if ($dir eq 'else')
1016 0 41 unless $frame->{'Type'} eq 'if' or $frame->{'Type'} eq 'unless'
1018 0 41 if $frame->{'Else'}
1022 26 15 if ($frame->{'DidGenerate'}) { }
1030 73 1474 if ($dir eq 'fi')
1032 0 73 unless $frame->{'Type'} eq 'if' or $frame->{'Type'} eq 'unless'
1039 25 1449 unless $frame->{'Generate'}
1041 151 1298 if ($dir eq 'let')
1043 87 64 if ($replay and exists $replay->{'Expr'}) { }
1047 0 64 unless $iftree = $self->{'Math'}->Parse($arg)
1056 399 899 if ($dir eq 'echo')
1062 348 551 if (exists $loops{$dir})
1075 90 106 unless ($doneDone or $frame->{'CondReRun'})
1081 17 331 unless (exists $frame->{'Code'})
1082 0 17 unless $code = $self->ReadLoop($dir, $_, $arg)
1089 90 106 unless ($doneDone or $frame->{'CondReRun'})
1101 15 75 if exists $replay->{'Init'}
1106 242 106 unless ($frame->{'CondReRun'})
1109 0 242 if $frame->{'LoopMax'} and ++$frame->{'LoopCnt'} > $frame->{'LoopMax'}
1112 86 156 if exists $replay->{'For3'} and $frame->{'LoopCnt'} != 1
1117 106 242 if $frame->{'CondReRun'}
1118 52 190 unless $bool
1124 122 429 if ($dir eq 'done')
1126 0 122 unless exists $frame->{'LoopMax'}
1134 27 402 if ($dir eq 'break' or $dir eq 'last')
1136 1 26 if $arg =~ /\s*(\d+)/
1143 0 28 if exists $self->{'Frame'}{'ReturnFrom'}
1147 0 28 unless $self->closeFrame
1152 30 372 if ($dir eq 'continue' or $dir eq 'next')
1154 10 20 if $arg =~ /\s*(\d+)/
1160 0 40 if exists $self->{'Frame'}{'ReturnFrom'}
1162 30 10 if ($ls = exists $self->{'Frame'}{'LoopStart'} and --$loops <= 0)
1168 0 10 unless $self->closeFrame
1176 16 356 if ($dir eq 'local')
1188 42 314 if ($dir eq 'include')
1192 8 34 if ($arg =~ s/^-s\s*(\w+)\s*//)
1195 0 8 if exists $self->{'Streams'}{$stream}
1198 0 42 unless @args = $self->SplitArgs($arg, 1)
1199 0 42 unless @args
1203 2 40 if (not defined $stream and $fn =~ /^-p(\d*)$/)
1204 1 1 $1 eq '' ? :
1207 0 2 if $level > @{$self->{'FrameStk'};}
1208 0 2 unless @args
1213 12 30 if (substr($fn, 0, 1) eq '|') { }
1215 0 12 unless $self->{'PipeOK'}
1218 6 6 $fn eq '|' ? :
1221 0 12 unless $fd
1230 0 30 unless defined($fn = $self->ResolveFilename($fn))
1231 0 30 unless $fd = $self->openFile($fn)
1236 8 34 if (defined $stream) { }
1240 32 2 unless $level
1241 2 32 if ($level)
1252 0 314 if ($dir eq 'exit')
1254 0 0 if ($arg ne '')
1256 0 0 unless ($code =~ /^\d+$/)
1266 3 311 if ($dir eq 'print')
1268 0 3 if $arg =~ s/^-e\b\s*//
1269 3 0 if $arg =~ s/^-o\s*(\w+)\b\s*//
1271 0 3 unless defined($arg = $self->ProcEscapes($arg))
1277 3 308 if ($dir eq 'out')
1278 1 2 if ($arg eq '') { }
2 0 elsif ($arg =~ s/^(\w+)\s*$//) { }
1281 2 0 if (defined $self->{'OutStreams'}{$1}) { }
1294 130 178 if ($dir eq 'return')
1297 127 3 if $arg =~ /\S/
1300 0 130 unless $self->close
1306 44 134 if ($dir eq 'eval')
1307 0 44 unless $_ = $self->ProcEscapes($arg)
1308 0 44 if /^$self->{'DirStartRE'}#/
1314 8 126 if ($dir eq 'close')
1315 0 8 unless $arg =~ s/^-s\s*(\w+)\s*//
1321 0 8 unless exists $self->{'Streams'}{$stream}
1329 28 98 if ($dir eq 'read')
1332 23 5 if $arg =~ s/^-s\s*(\w+)\s+//
1335 0 28 unless $vname
1338 23 5 if (defined $stream) { }
1340 0 23 unless $fd = $self->{'Streams'}{$stream}
1352 21 7 if ($_ = $fd->getline) { }
1355 21 0 if $self->{'Trim'}
1367 1 97 if $dir eq 'noop'
1370 38 59 if ($dir eq 'sub')
1372 0 38 unless $self->readSub($dir, $_, $arg)
1376 2 57 if ($dir eq 'test')
1380 0 2 unless @args and exists $an{$args[0]} and @args == $an{$args[0]}
1382 2 0 if ($args[0] eq '-f')
1385 2 0 if ($fn = $self->ResolveFilename($args[1], 1) and @stat = stat $fn)
1394 0 57 if ($dir eq 'error')
1395 0 0 if $arg eq ''
1399 0 57 if ($dir eq 'set')
1401 0 0 unless $arg =~ /^(\w+)=(\d+)/ and $options{$1}
1406 0 57 if $dir eq 'function' or $dir eq 'do' or $dir eq 'case' or $dir eq 'switch' or $dir eq 'endswitch'
1411 57 0 if (exists $self->{'subs'}{$dir})
1429 0 0 unless $self->{'Fd'}
1431 0 0 unless wantarray