blib/lib/IO/Busy.pm

filter: Statementstmt 38.8% 21 / 54 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 6 / 8 Podpod 100% 1 / 1 totaltotal 38.8% 28 / 72 CC 4 SCAR 20.8
CC
4
Cov
34%
busy
20.0
_input_pending_on
2.0
BEGIN
1.0
CRAP 8.0
↑ Summary
1 package IO::Busy;
2  
3 2 ▶use version; $VERSION = qv('0.0.3');
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Perl6::Export::Attrs;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub _input_pending_on {
Subroutine _input_pending_on: not called CC=1 SCAR=6.9
12 0 my ($fh) = @_;
13 0 my $read_bits = "";
14 0 vec($read_bits, fileno($fh), 1) = 1;
15 0 select $read_bits, undef, undef, 0.1;
16 0 return $read_bits;
17 }
18  
19 2 my @warning = (
20 "That input was ignored. Please don't press any keys yet.\n",
21 "That input was ignored. Please wait a little longer.\n",
22 "That input was also ignored. You might as well just wait, you know.\n",
23 # "Look, there's no point typing yet. Your input isn't going anywhere.\n",
24 #"Are you learning impaired? DON'T. TYPE. YET.\n",
25 #"Okay, fine. Type whatever you like. Whatever makes you happy.\n",
26 #"La la la la. I can't hear you.\n",
27 "",
28 );
29  
30 0 ▶sub busy (&) :Export(:MANDATORY) {
Subroutine busy: not called CC=4 SCAR=30.0
Pod documented
31 0 my ($block_ref) = @_;
32 0 my $count = 0;
33  
34 0 my ($read, $write);
35 0 pipe $read, $write;
36 0 my $child = fork;
37 0 ▶ if (!$child) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($child) 0 0 0
38 0 close $read;
39 0 $write->autoflush(1);
40 0 while (1) {
41 0 ▶ if (_input_pending_on(\*STDIN)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_input_pending_on(\*STDIN)) 0 0 0
42 0 my $res = <STDIN>;
43 0 print {$write} $res;
44 0 print {*STDERR} "\n";
45 0 ▶ print {*STDERR} $warning[$count++] || $warning[-1];
Condition0%0/3
$warning[$count++] || $warning[-1]
l!l&&r!l&&!r
000
MC/DC0%0/2
$warning[$count++] || $warning[-1]
$warning[$count++] $warning[-1]
Truth table0%0/3
A || B
A= $warning[$count++]B= $warning[-1]
ABresult
1X1
011
000
46 0 print {*STDERR} "\n";
47 }
48 }
49 0 exit;
50 }
51 0 close $write;
52 0 local *ARGV;
53 0 open *ARGV, '<', \"";
54 0 $block_ref->();
55 0 kill 9, $child;
56 0 wait;
57 0 local $/;
58 0 return $read;
59 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61  
62 2 1; # Magic true value required at end of module
63 __END__
↑ Summary