ClassFile/Util/ArrayStringification.pm

filter: Statementstmt 48.1% 13 / 27 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 1 totaltotal 43.2% 16 / 37 SCAR 15.6
CC
3
Cov
42%
arrayStringificator
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.8
« ClassFile/BNF/OpCodeArray.pm ↑ Summary ClassFile/Util/AccessFlagsStringification.pm »
1 29 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 29 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package MarpaX::Java::ClassFile::Util::ArrayStringification;
5 29 ▶use Exporter 'import'; # gives you Exporter's import() method directly
Subroutine BEGIN: called CC=1 SCAR=0.0
6 29 our @EXPORT_OK = qw/arrayStringificator/;
7  
8 # ABSTRACT: Unblessed array stringification helper
9  
10 29 our $VERSION = '0.008'; # VERSION
11  
12 29 our $AUTHORITY = 'cpan:JDDPAUSE'; # AUTHORITY
13  
14 sub arrayStringificator {
15 # my ($self, $arrayRef) = @_;
16 #
17 # If the array ref is empty, bypass the following
18 #
19 0 ▶ return '[]' if (! @{$_[1]});
Subroutine arrayStringificator: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
unless @{$_[1];} 0 0 0
20 #
21 # Current recursivity level in OUR stringification routines
22 #
23 0 ▶ my $currentLevel = $MarpaX::Java::ClassFile::Struct::STRINGIFICATION_LEVEL // 0;
Condition0%0/2
$MarpaX::Java::ClassFile::Struct::STRINGIFICATION_LEVEL // 0
l!l
00
MC/DC0%0/1
$MarpaX::Java::ClassFile::Struct::STRINGIFICATION_LEVEL // 0
$MarpaX::Java::ClassFile::Struct::STRINGIFICATION_LEVEL
Truth table0%0/2
A
A= $MarpaX::Java::ClassFile::Struct::STRINGIFICATION_LEVEL
Aresult
11
00
24 0 my $localIndent = ' ' x $currentLevel;
25 #
26 # To have a pretty printing of indices
27 #
28 0 my $maxIndice = $#{$_[1]};
29 0 my $lengthMaxIndice = length($maxIndice);
30 #
31 # Call for stringification
32 #
33 0 my $innerIndent = ' ' . $localIndent;
34 my $rc = "[\n" . join(",\n",
35 map {
36 #
37 # Say to any other overload stub that we fake a new level because we
38 # managed ourself the fact that this is a deployed array
39 #
40 0 local $MarpaX::Java::ClassFile::Struct::STRINGIFICATION_LEVEL = $currentLevel + 1;
41 0 sprintf('%s#%*d %s',
42 $innerIndent,
43 -$lengthMaxIndice,
44 $_,
45 $_[1]->[$_]
46 )
47 }
48 0 grep { defined($_[1]->[$_]) } # A cp can be undef
49 0 (0..$#{$_[1]})) . "\n$localIndent]";
50 0 $rc
51 }
52  
53 29 1;
54  
55 __END__
56  
57 =pod
58  
59 =encoding UTF-8
60  
61 =head1 NAME
62  
63 MarpaX::Java::ClassFile::Util::ArrayStringification - Unblessed array stringification helper
64  
65 =head1 VERSION
66  
67 version 0.008
68  
69 =head1 AUTHOR
70  
71 Jean-Damien Durand <jeandamiendurand@free.fr>
72  
73 =head1 COPYRIGHT AND LICENSE
74  
75 This software is copyright (c) 2016 by Jean-Damien Durand.
76  
77 This is free software; you can redistribute it and/or modify it under
78 the same terms as the Perl 5 programming language system itself.
79  
80 =cut
« ClassFile/BNF/OpCodeArray.pm ↑ Summary ClassFile/Util/AccessFlagsStringification.pm »