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

filter: Statementstmt 72.7% 24 / 33 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 90.9% 10 / 11 Podpod 60.0% 3 / 5 totaltotal 66.0% 37 / 56 CC 3 SCAR 12.6
CC
3
Cov
63%
transform
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.5
« lib/Perl/ToPerl6/Transformer/Subroutines/RemovePrototypes.pm ↑ Summary lib/Perl/ToPerl6/Transformer/BasicTypes/Rationals/AddTrailingZero.pm »
1 package Perl::ToPerl6::Transformer::BasicTypes::Integers::RewriteHexNumbers;
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{ :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 0x0123 into :16<0123>};
15 17 Readonly::Scalar my $EXPL => q{Perl6 hexadecimal integers look like :16<0123>};
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::Hex' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
23  
24 #-----------------------------------------------------------------------------
25  
26 0 ▶sub transform {
Subroutine transform: not called CC=3 SCAR=24.8
Pod undocumented
27 0 my ($self, $elem, $doc) = @_;
28 0 ▶ return unless $elem and $elem->content; # XXX Shouldn't be required, but it is.
Branch: 1 branch
BranchTrueFalseTotal
unless $elem and $elem->content 0 0 0
Condition0%0/3
$elem and $elem->content
!ll&&!rl&&r
000
MC/DC0%0/2
$elem and $elem->content
$elem $elem->content
Truth table0%0/3
A and B
A= $elemB= $elem->content
ABresult
0X0
100
111
29  
30 0 my $old_content = $elem->content;
31  
32 #
33 # Remove leading '0x' and optional leading underscore
34 #
35 0 $old_content =~ s{^0x[_]?}{}i;
36 0 $old_content =~ s{[_]$}{};
37 0 $old_content =~ s{[_]+}{_}g;
38  
39 0 my $new_content = ':16<' . $old_content . '>';
40 0 $elem->set_content( $new_content );
41  
42 0 return $self->transformation( $DESC, $EXPL, $elem );
43 }
44  
45 17 1;
46  
47 #-----------------------------------------------------------------------------
48  
49 __END__
« lib/Perl/ToPerl6/Transformer/Subroutines/RemovePrototypes.pm ↑ Summary lib/Perl/ToPerl6/Transformer/BasicTypes/Rationals/AddTrailingZero.pm »