lib/Perl/ToPerl6/Transformer/Variables/QuoteHashKeys.pm

filter: Statementstmt 62.5% 25 / 40 Branchbran 12.5% 1 / 8 Conditioncond 16.6% 3 / 18 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 91.6% 11 / 12 Podpod 60.0% 3 / 5 totaltotal 46.7% 43 / 92 CC 11 SCAR 28.0
CC
11
Cov
44%
transform
42.0
__ANON__
16.7
applies_to
1.2
CRAP 16.5
« lib/Perl/ToPerl6/Document.pm ↑ Summary lib/Perl/ToPerl6/TransformerParameter/Behavior/Integer.pm »
1 package Perl::ToPerl6::Transformer::Variables::QuoteHashKeys;
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{Transform %x{a} to %x{'a'} depending upon mode};
15 17 Readonly::Scalar my $EXPL =>
16 q{Perl6 assumes that braces are code blocks, so any content must be compilable};
17  
18 #-----------------------------------------------------------------------------
19  
20 39 ▶sub supported_parameters {
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
21 return ( {
22 39 name => 'perl6_mode',
23 description => q{Controls whether <> or {''} are used},
24 default_string => 0,
25 behavior => 'boolean'
26 } )
27 }
28 27 ▶sub default_necessity { return $NECESSITY_HIGHEST }
Subroutine default_necessity: called CC=1 SCAR=0.0
Pod documented
29 24 ▶sub default_themes { return qw( core ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
30 5 ▶sub applies_to {
Subroutine applies_to: called CC=1 SCAR=2.2
Pod documented
31 78 ▶ return sub {
Subroutine __ANON__: called CC=6 SCAR=28.1
32 78 ▶ $_[1]->isa('PPI::Structure::Subscript') and
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Structure::Subscript") and $_[1]->start->content eq "{" and $_[1]->finish->content eq "}" and $_[1]->sprevious_sibling->isa("PPI::Token::Symbol") || $_[1]->sprevious_sibling->isa("PPI::Token::Operator") and not $_[1]->schild(0)->schild(0)->isa("PPI::Token::Quote") 0 78 78
Condition25%3/12
$_[1]->isa("PPI::Structure::Subscript") and $_[1]->start->content eq "{" and $_[1]->finish->content eq "}" and $_[1]->sprevious_sibling->isa("PPI::Token::Symbol") || $_[1]->sprevious_sibling->isa("PPI::Token::Operator")
!ll&&!rl&&r
7800
$_[1]->isa("PPI::Structure::Subscript") and $_[1]->start->content eq "{" and $_[1]->finish->content eq "}"
!ll&&!rl&&r
7800
$_[1]->isa("PPI::Structure::Subscript") and $_[1]->start->content eq "{"
!ll&&!rl&&r
7800
$_[1]->sprevious_sibling->isa("PPI::Token::Symbol") or $_[1]->sprevious_sibling->isa("PPI::Token::Operator")
l!l&&r!l&&!r
000
MC/DC0%0/5
$_[1]->isa("PPI::Structure::Subscript") and $_[1]->start->content eq "{" and $_[1]->finish->content eq "}" and $_[1]->sprevious_sibling->isa("PPI::Token::Symbol") || $_[1]->sprevious_sibling->isa("PPI::Token::Operator")
$_[1]->isa("PPI::Structure::Subscript") $_[1]->start->content eq "{" $_[1]->finish->content eq "}" $_[1]->sprevious_sibling->isa("PPI::Token::Symbol") $_[1]->sprevious_sibling->isa("PPI::Token::Operator")
Truth table16%1/6
A and B and C and D or E
A= $_[1]->isa("PPI::Structure::Subscript")B= $_[1]->start->content eq "{"C= $_[1]->finish->content eq "}"D= $_[1]->sprevious_sibling->isa("PPI::Token::Symbol")E= $_[1]->sprevious_sibling->isa("PPI::Token::Operator")
ABCDEresult
0XXXX0
10XXX0
110XX0
111000
1111X1
111011
33 $_[1]->start->content eq '{' and
34 $_[1]->finish->content eq '}' and
35 ( $_[1]->sprevious_sibling->isa('PPI::Token::Symbol') or
36 $_[1]->sprevious_sibling->isa('PPI::Token::Operator') ) and
37 not $_[1]->schild(0)->schild(0)->isa('PPI::Token::Quote')
38 }
39 5 }
40  
41 #-----------------------------------------------------------------------------
42  
43 0 ▶sub transform {
Subroutine transform: not called CC=6 SCAR=37.4
Pod undocumented
44 0 my ($self, $elem, $doc) = @_;
45 0 my $token = $elem;
46  
47 0 ▶ while ( $token and
Branch: 1 branch
BranchTrueFalseTotal
if ($token and $token->isa("PPI::Structure::Subscript")) 0 0 0
Condition0%0/3
$token and $token->isa("PPI::Structure::Subscript")
!ll&&!rl&&r
000
MC/DC0%0/2
$token and $token->isa("PPI::Structure::Subscript")
$token $token->isa("PPI::Structure::Subscript")
Truth table0%0/3
A and B
A= $tokenB= $token->isa("PPI::Structure::Subscript")
ABresult
0X0
100
111
48 $token->isa('PPI::Structure::Subscript') ) {
49 0 ▶ if ( $token->start and
Branch: 1 branch
BranchTrueFalseTotal
if ($token->start and $token->start->content eq "{") 0 0 0
Condition0%0/3
$token->start and $token->start->content eq "{"
!ll&&!rl&&r
000
MC/DC0%0/2
$token->start and $token->start->content eq "{"
$token->start $token->start->content eq "{"
Truth table0%0/3
A and B
A= $token->startB= $token->start->content eq "{"
ABresult
0X0
100
111
50 $token->start->content eq '{' ) {
51 0 ▶ if ( $self->{_perl6_mode} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_perl6_mode'}) { } 0 0 0
52 0 $token->start->set_content('<');
53 0 $token->finish->set_content('>');
54 }
55 else {
56 0 my $bareword = $token->schild(0)->schild(0);
57 0 my $old_content = $bareword->content;
58 0 $old_content =~ s{'}{\\'}g;
59
60 0 my $new_content = "'" . $old_content . "'";
61
62 0 $bareword->insert_after(
63 PPI::Token::Quote::Single->new($new_content)
64 );
65 0 $bareword->delete;
66 }
67 }
68 0 $token = $token->snext_sibling;
69 }
70  
71 0 return $self->transformation( $DESC, $EXPL, $elem );
72 }
73  
74 17 1;
75  
76 #-----------------------------------------------------------------------------
77  
78 __END__
« lib/Perl/ToPerl6/Document.pm ↑ Summary lib/Perl/ToPerl6/TransformerParameter/Behavior/Integer.pm »