File Coverage

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


line stmt bran cond sub pod time code
1             package PPIx::QuoteLike::Token::Delimiter;
2              
3 7     7   1204 use 5.006;
  7         18  
4              
5 7     7   27 use strict;
  7         9  
  7         142  
6 7     7   22 use warnings;
  7         24  
  7         310  
7              
8 7     7   81 use base qw{ PPIx::QuoteLike::Token::Structure };
  7         10  
  7         3002  
9              
10 7     7   35 use PPIx::QuoteLike::Constant qw{ MINIMUM_PERL @CARP_NOT };
  7         11  
  7         758  
11              
12             our $VERSION = '0.024';
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         1588 use constant WEIRD_CHAR_RE => eval ## no critic (ProhibitStringyEval,RequireCheckingReturnValueOfEval)
22             'qr<
23             (?! [\p{Noncharacter_code_point}\P{Any}] )
24             [\p{Unassigned}\p{Mark}]
25 7     7   36 >smx';
  7         10  
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 49 my ( $self ) = @_;
36 38 100       55 $self->content() =~ m/ \A [[:^ascii:]] \z /smx
37             and return '5.008003';
38 37         72 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 22 my ( $self ) = @_;
58 20 100       47 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         39 return undef; ## no critic (ProhibitExplicitReturnUndef)
66             }
67              
68             1;
69              
70             __END__