File Coverage

blib/lib/PPIx/QuoteLike/Token/Delimiter.pm
Criterion Covered Total %
statement 26 26 100.0
branch 4 4 100.0
condition n/a
subroutine 9 9 100.0
pod 2 2 100.0
total 41 41 100.0


line stmt bran cond sub pod time code
1             package PPIx::QuoteLike::Token::Delimiter;
2              
3 7     7   807 use 5.006;
  7         21  
4              
5 7     7   55 use strict;
  7         13  
  7         227  
6 7     7   38 use warnings;
  7         13  
  7         195  
7              
8 7     7   32 use base qw{ PPIx::QuoteLike::Token::Structure };
  7         11  
  7         2628  
9              
10 7     7   41 use PPIx::QuoteLike::Constant qw{ MINIMUM_PERL @CARP_NOT };
  7         9  
  7         567  
11              
12             our $VERSION = '0.022_01';
13              
14             # Perl 5.29.0 disallows unassigned code points and combining code points
15             # as delimiters. Unfortunately for me non-characters and illegal
16             # characters are explicitly allowed. Still more unfortunately, these
17             # match /\p{Unassigned}/. So before I match a deprecated characer, I
18             # have to assert that the character is neither a non-character
19             # (\p{Noncharacter_code_point}) nor an illegal Unicode character
20             # (\P{Any}).
21 7     7   528 use constant WEIRD_CHAR_RE => eval ## no critic (ProhibitStringyEval,RequireCheckingReturnValueOfEval)
  7         3577  
  7         229  
  7         136  
22             'qr<
23             (?! [\p{Noncharacter_code_point}\P{Any}] )
24             [\p{Unassigned}\p{Mark}]
25 7     7   36 >smx';
  7         13  
26              
27             =head2 perl_version_introduced
28              
29             Experimentation with weird delimiters shows that they did not actually
30             work until Perl 5.8.3, so we return C<'5.008003'> for such delimiters.
31              
32             =cut
33              
34             sub perl_version_introduced {
35 38     38 1 54 my ( $self ) = @_;
36 38 100       59 $self->content() =~ m/ \A [[:^ascii:]] \z /smx
37             and return '5.008003';
38 37         75 return MINIMUM_PERL;
39             }
40              
41             =head2 perl_version_removed
42              
43             Perl 5.29.0 made fatal the use of non-standalone graphemes as string
44             delimiters. Because non-characters and permanently unassigned code points
45             are still allowed per F, I take this to mean characters
46             that match C (i.e. combining diacritical marks). But this
47             regular expression does not compile under Perl 5.6.
48              
49             So:
50              
51             This method returns C<'5.029'> for such delimiters B the
52             requisite regular expression compiles. Otherwise it return C.
53              
54             =cut
55              
56             sub perl_version_removed {
57 20     20 1 30 my ( $self ) = @_;
58 20 100       33 WEIRD_CHAR_RE
59             and $self->content() =~ WEIRD_CHAR_RE
60             and return '5.029';
61             # I respectfully disagree with Perl Best Practices on the
62             # following. When this method is called in list context it MUST
63             # return undef if that's the right answer, NOT an empty list.
64             # Otherwise hash constructors have the wrong number of elements.
65 19         49 return undef; ## no critic (ProhibitExplicitReturnUndef)
66             }
67              
68             1;
69              
70             __END__