File Coverage

blib/lib/PPIx/QuoteLike/Token.pm
Criterion Covered Total %
statement 49 57 85.9
branch 10 16 62.5
condition 1 3 33.3
subroutine 19 21 90.4
pod 13 13 100.0
total 92 110 83.6


line stmt bran cond sub pod time code
1             package PPIx::QuoteLike::Token;
2              
3 7     7   797 use 5.006;
  7         20  
4              
5 7     7   57 use strict;
  7         10  
  7         139  
6 7     7   28 use warnings;
  7         12  
  7         172  
7              
8 7     7   28 use Carp;
  7         13  
  7         382  
9 7     7   38 use PPIx::QuoteLike::Constant qw{ MINIMUM_PERL @CARP_NOT };
  7         18  
  7         555  
10 7         3189 use PPIx::QuoteLike::Utils qw{
11             column_number
12             line_number
13             logical_filename
14             logical_line_number
15             statement
16             visual_column_number
17 7     7   1937 };
  7         14  
18              
19             our $VERSION = '0.022_01';
20              
21             # Private to this package.
22             sub __new {
23 332     332   3510 my ( $self, %arg ) = @_;
24             defined $arg{content}
25 332 50       606 or croak 'Content required';
26 332   33     1158 return bless \%arg, ref $self || $self;
27             }
28              
29             sub content {
30 558     558 1 12683 my ( $self ) = @_;
31 558         1791 return $self->{content};
32             }
33              
34             sub error {
35 46     46 1 130 my ( $self ) = @_;
36 46         181 return $self->{error};
37             }
38              
39             sub location {
40 27     27 1 896 my ( $self ) = @_;
41 27 50       52 return $self->{location} ? [ @{ $self->{location} } ] : undef;
  27         147  
42             }
43              
44             sub parent {
45 47     47 1 127 my ( $self ) = @_;
46 47         218 return $self->{parent};
47             }
48              
49             sub next_sibling {
50 46     46 1 130 my ( $self ) = @_;
51             $self->{next_sibling}
52 46 100       174 or return;
53 21         60 return $self->{next_sibling};
54             }
55              
56             sub perl_version_introduced {
57 80     80 1 112 my ( $self ) = @_;
58             # TODO use '//' when we can require Perl 5.10.
59             defined $self->{perl_version_introduced}
60 80 100       142 and return $self->{perl_version_introduced};
61 65         107 my $vers = $self->__perl_version_introduced();
62 65 100       100 defined $vers
63             or $vers = MINIMUM_PERL;
64 65         127 return ( $self->{perl_version_introduced} = $vers );
65             }
66              
67             sub __perl_version_introduced {
68 44     44   52 return;
69             }
70              
71             sub perl_version_removed {
72 62     62 1 115 return undef; ## no critic (ProhibitExplicitReturnUndef)
73             }
74              
75             sub previous_sibling {
76 46     46 1 117 my ( $self ) = @_;
77             $self->{previous_sibling}
78 46 100       178 or return;
79 20         48 return $self->{previous_sibling};
80             }
81              
82             sub significant {
83 21     21 1 34 return 1;
84             }
85              
86             sub snext_sibling {
87 0     0 1 0 my ( $sib ) = @_;
88 0         0 while ( $sib = $sib->next_sibling() ) {
89 0 0       0 $sib->significant()
90             and return $sib;
91             }
92 0         0 return;
93             }
94              
95             sub sprevious_sibling {
96 0     0 1 0 my ( $sib ) = @_;
97 0         0 while ( $sib = $sib->previous_sibling() ) {
98 0 0       0 $sib->significant()
99             and return $sib;
100             }
101 0         0 return;
102             }
103              
104             sub top {
105 1     1 1 3 my ( $self ) = @_;
106 1         2 my $kid = $self;
107 1         12 while ( defined ( my $parent = $kid->parent() ) ) {
108 1         4 $kid = $parent;
109             }
110 1         2 return $kid;
111             }
112              
113             sub variables {
114 45     45 1 104 return;
115             }
116              
117             1;
118              
119             __END__