QuoteLike/Token/Interpolation.pm

filter: Statementstmt 100% 50 / 50 Branchbran 85.7% 12 / 14 Conditioncond 33.3% 5 / 15 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 100% 11 / 11 Podpod 100% 2 / 2 totaltotal 80.8% 80 / 99 CC 13 SCAR 20.9
CC
13
Cov
85%
ppi
14.4
__perl_version_introduced
2.0
BEGIN
1.0
CRAP 8.1
« QuoteLike.pm ↑ Summary QuoteLike/Token.pm »
1 package PPIx::QuoteLike::Token::Interpolation;
2  
3 7 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 ▶use PPI::Document;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶use PPIx::QuoteLike::Constant qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
11 LOCATION_COLUMN
12 LOCATION_LOGICAL_LINE
13 LOCATION_LOGICAL_FILE
14 @CARP_NOT
15 7 };
16 7 ▶use PPIx::QuoteLike::Utils qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
17 __normalize_interpolation_for_ppi
18 __variables
19 7 };
20  
21 7 ▶use base qw{ PPIx::QuoteLike::Token };
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 7 our $VERSION = '0.024';
24  
25 57 ▶sub ppi {
Subroutine ppi: called CC=12 SCAR=26.7
Pod documented
26 57 my ( $self ) = @_;
27 57 ▶ unless ( $self->{ppi} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"ppi"}) 34 23 57
28 34 my $content;
29 34 my $location = $self->{location};
30 34 ▶ if ( $location ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($location) 13 21 34
31 13 my $fn;
32 13 ▶ if( defined( $fn = $location->[LOCATION_LOGICAL_FILE] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($fn = $location->[4])) { } 1 12 13
33 1 $fn =~ s/ (?= [\\"] ) /\\/smxg;
34 1 $content = qq{#line $location->[LOCATION_LOGICAL_LINE] "$fn"\n};
35 } else {
36 12 $content = qq{#line $location->[LOCATION_LOGICAL_LINE]\n};
37 }
38 13 $content .= ' ' x ( $location->[LOCATION_COLUMN] - 1 );
39 }
40  
41 34 $content .= __normalize_interpolation_for_ppi( $self->content() );
42  
43 34 $self->{ppi} = PPI::Document->new( \$content );
44  
45 34 ▶ if ( $location ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($location) 13 21 34
46 # Generate locations now.
47 13 $self->{ppi}->location();
48 # Remove the stuff we originally injected. NOTE that we can
49 # only get away with doing this if the removal does not
50 # invalidate the locations of the other tokens that we just
51 # generated.
52 13 my $elem;
53 # Remove the '#line' directive if we find it
54 13 ▶ $elem = $self->{ppi}->child( 0 )
Branch: 1 branch
BranchTrueFalseTotal
$elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Comment") and $elem->content =~ / \A \#line\b /msx and $elem->remove 13 0 13
Condition33%2/6
$elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Comment") and $elem->content =~ / \A \#line\b /msx
!ll&&!rl&&r
0013
$elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Comment")
!ll&&!rl&&r
0013
MC/DC0%0/3
$elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Comment") and $elem->content =~ / \A \#line\b /msx
$elem = $self->{"ppi"}->child(0) $elem->isa("PPI::Token::Comment") $elem->content =~ / \A \#line\b /msx
Truth table25%1/4
A and B and C
A= $elem = $self->{"ppi"}->child(0)B= $elem->isa("PPI::Token::Comment")C= $elem->content =~ / \A \#line\b /msx
ABCresult
0XX0
10X0
1100
1111
55 and $elem->isa( 'PPI::Token::Comment' )
56 and $elem->content() =~ m/ \A \#line\b /smx
57 and $elem->remove();
58 # Remove the white space if we find it, and if it in fact
59 # represents only the white space we injected to get the
60 # column numbers right.
61 13 my $wid = $location->[LOCATION_COLUMN] - 1;
62 $wid
63 13 ▶ and $elem = $self->{ppi}->child( 0 )
Branch: 1 branch
BranchTrueFalseTotal
$wid and $elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Whitespace") and $wid == length $elem->content and $elem->remove 13 0 13
Condition33%3/9
$wid and $elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Whitespace") and $wid == length $elem->content
!ll&&!rl&&r
0013
$wid and $elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Whitespace")
!ll&&!rl&&r
0013
$wid and $elem = $self->{"ppi"}->child(0)
!ll&&!rl&&r
0013
MC/DC0%0/4
$wid and $elem = $self->{"ppi"}->child(0) and $elem->isa("PPI::Token::Whitespace") and $wid == length $elem->content
$wid $elem = $self->{"ppi"}->child(0) $elem->isa("PPI::Token::Whitespace") $wid == length $elem->content
Truth table20%1/5
A and B and C and D
A= $widB= $elem = $self->{"ppi"}->child(0)C= $elem->isa("PPI::Token::Whitespace")D= $wid == length $elem->content
ABCDresult
0XXX0
10XX0
110X0
11100
11111
64 and $elem->isa( 'PPI::Token::Whitespace' )
65 and $wid == length $elem->content()
66 and $elem->remove();
67 }
68 }
69 57 return $self->{ppi};
70 }
71  
72 56 ▶sub variables {
Subroutine variables: called CC=1 SCAR=0.0
Pod documented
73 56 my ( $self ) = @_;
74 56 return __variables( $self->ppi() );
75 }
76  
77 16 ▶sub __perl_version_introduced {
Subroutine __perl_version_introduced: called CC=2 SCAR=6.9
78 16 my ( $self ) = @_;
79 $self->{postderef}
80 16 ▶ and return '5.019005';
Branch: 1 branch
BranchTrueFalseTotal
$self->{"postderef"} and return "5.019005" 7 9 16
81 9 return;
82 }
83  
84 7 1;
85  
86 __END__
« QuoteLike.pm ↑ Summary QuoteLike/Token.pm »