Data/Printer/Filter/GLOB.pm

filter: Statementstmt 100% 54 / 54 Branchbran 78.5% 11 / 14 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 95.1% 79 / 83 CC 9 SCAR 16.6
CC
9
Cov
96%
parse
9.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.2
« Data/Printer/Theme.pm ↑ Summary Data/Printer/Filter/REF.pm »
1 package Data::Printer::Filter::GLOB;
2 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 35 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 35 ▶use Data::Printer::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 35 ▶use Data::Printer::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 35 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 35 ▶use Fcntl;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 35 filter 'GLOB' => \&parse;
10  
11  
12 10 ▶sub parse {
Subroutine parse: called CC=9 SCAR=22.0
Pod undocumented
13 10 my ($glob, $ddp) = @_;
14  
15 10 my $string = $ddp->maybe_colorize("$$glob", 'glob');
16  
17 # unfortunately, some systems (like Win32) do not
18 # implement some of these flags (maybe not even
19 # fcntl() itself, so we must wrap it.
20 10 my $extra = '';
21 10 my $flags;
22 35 ▶ eval { no warnings qw( unopened closed ); $flags = fcntl($$glob, F_GETFL, 0) };
Subroutine BEGIN: called CC=1 SCAR=0.0
23 10 ▶ if ($flags) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flags) 10 0 10
24 10 ▶ $extra .= ($flags & O_WRONLY) ? 'write-only'
Branch: 2 branches
BranchTrueFalseTotal
$flags & 1 ? : 2 8 10
$flags & 2 ? : 2 6 8
25 : ($flags & O_RDWR) ? 'read/write'
26 : 'read-only'
27 ;
28  
29 # How to avoid croaking when the system
30 # doesn't implement one of those, without skipping
31 # the whole thing? Maybe there's a better way.
32 # Solaris, for example, doesn't have O_ASYNC :(
33 10 my %flags = ();
34 10 eval { $flags{'append'} = O_APPEND };
35 10 eval { $flags{'async'} = O_ASYNC }; # leont says this is the only one I should care for.
36 10 eval { $flags{'create'} = O_CREAT };
37 10 eval { $flags{'truncate'} = O_TRUNC };
38 10 eval { $flags{'nonblocking'} = O_NONBLOCK };
39  
40 10 ▶ if (my @flags = grep { $flags & $flags{$_} } sort keys %flags) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@flags) = grep({$flags & $flags{$_};} sort(keys %flags))) 2 8 10
41 2 $extra .= ", flags: @flags";
42 }
43 10 $extra .= ', ';
44 }
45 10 my @layers = ();
46 # TODO: try PerlIO::Layers::get_layers (leont)
47 10 ▶ my $error = Data::Printer::Common::_tryme(sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
48 10 @layers = PerlIO::get_layers $$glob
49 10 });
50 10 ▶ $extra .= "layers: @layers" unless $error;
Branch: 1 branch
BranchTrueFalseTotal
unless $error 10 0 10
51 10 ▶ $string .= " ($extra)" if $extra;
Branch: 1 branch
BranchTrueFalseTotal
if $extra 10 0 10
52  
53 10 ▶ if ($ddp->show_tied and my $tie = ref tied *$$glob) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ddp->show_tied and my $tie = ref tied *$$glob) 1 9 10
Condition100%3/3
$ddp->show_tied and my $tie = ref tied *$$glob
!ll&&!rl&&r
181
MC/DC100%2/2
$ddp->show_tied and my $tie = ref tied *$$glob
$ddp->show_tied my $tie = ref tied *$$glob
Truth table100%3/3
A and B
A= $ddp->show_tiedB= my $tie = ref tied *$$glob
ABresult
0X0
100
111
54 1 $string .= " (tied to $tie)"
55 }
56 10 return $string;
57 };
58  
59 35 1;
« Data/Printer/Theme.pm ↑ Summary Data/Printer/Filter/REF.pm »