lib/Perl/ToPerl6/Transformer/BasicTypes/Integers/RewriteOctalNumbers.pm

filter: Statementstmt 75.0% 24 / 32 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod 60.0% 3 / 5 totaltotal 77.0% 37 / 48 CC 1 SCAR 0.9
CC
1
Cov
75%
transform
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« lib/Perl/ToPerl6/Transformer/BasicTypes/Integers/RewriteBinaryNumbers.pm ↑ Summary lib/Perl/ToPerl6/Transformer/BasicTypes/Strings/RenameRegex.pm »
1 package Perl::ToPerl6::Transformer::BasicTypes::Integers::RewriteOctalNumbers;
2  
3 17 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 17 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 17 ▶use Perl::ToPerl6::Utils qw{ :characters :severities };
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 17 ▶use base 'Perl::ToPerl6::Transformer';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #-----------------------------------------------------------------------------
13  
14 17 Readonly::Scalar my $DESC => q{Transforms 0o11 and 011 into :8<11>};
15 17 Readonly::Scalar my $EXPL => q{Perl6 octal integers look like :8<0011>};
16  
17 #-----------------------------------------------------------------------------
18  
19 38 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
20 27 ▶sub default_necessity { return $NECESSITY_HIGHEST }
Subroutine default_necessity: called CC=1 SCAR=0.0
Pod documented
21 24 ▶sub default_themes { return qw( core ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
22 5 ▶sub applies_to { return 'PPI::Token::Number::Octal' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
23  
24 #-----------------------------------------------------------------------------
25  
26 #
27 # 0123 --> :8<0123>
28 # 0123_4567 --> :8<0123_4567>
29 #
30 0 ▶sub transform {
Subroutine transform: not called CC=1 SCAR=6.9
Pod undocumented
31 0 my ($self, $elem, $doc) = @_;
32  
33 0 my $old_content = $elem->content;
34  
35 #
36 # Remove leading '0' and optional leading underscore
37 #
38 0 $old_content =~ s{^0[_]?}{}i;
39 0 $old_content =~ s{[_]$}{};
40 0 $old_content =~ s{[_]+}{_}g;
41  
42 0 my $new_content = ':8<' . $old_content . '>';
43 0 $elem->set_content( $new_content );
44  
45 0 return $self->transformation( $DESC, $EXPL, $elem );
46 }
47  
48 17 1;
49  
50 #-----------------------------------------------------------------------------
51  
52 __END__
« lib/Perl/ToPerl6/Transformer/BasicTypes/Integers/RewriteBinaryNumbers.pm ↑ Summary lib/Perl/ToPerl6/Transformer/BasicTypes/Strings/RenameRegex.pm »