QuoteLike/Token/Delimiter.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 100% 39 / 39 CC 3 SCAR 3.4
CC
3
Cov
100%
perl_version_introduced
2.0
perl_version_removed
2.0
BEGIN
1.0
CRAP 1.4
« QuoteLike/Token.pm ↑ Summary QuoteLike/Constant.pm »
1 package PPIx::QuoteLike::Token::Delimiter;
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 base qw{ PPIx::QuoteLike::Token::Structure };
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 7 ▶use PPIx::QuoteLike::Constant qw{ MINIMUM_PERL @CARP_NOT };
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 7 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 ▶use constant WEIRD_CHAR_RE => eval ## no critic (ProhibitStringyEval,RequireCheckingReturnValueOfEval)
Subroutine BEGIN: called CC=1 SCAR=0.0
22 'qr<
23 (?! [\p{Noncharacter_code_point}\P{Any}] )
24 [\p{Unassigned}\p{Mark}]
25 7 >smx';
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 38 ▶sub perl_version_introduced {
Subroutine perl_version_introduced: called CC=2 SCAR=6.9
Pod documented
35 38 my ( $self ) = @_;
36 38 ▶ $self->content() =~ m/ \A [[:^ascii:]] \z /smx
Branch: 1 branch
BranchTrueFalseTotal
$self->content =~ / \A [[:^ascii:]] \z /msx and return "5.008003" 1 37 38
37 and return '5.008003';
38 37 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<perldeprecation>, I take this to mean characters
46 that match C</\p{Mark}/> (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<provided> the
52 requisite regular expression compiles. Otherwise it return C<undef>.
53  
54 =cut
55  
56 20 ▶sub perl_version_removed {
Subroutine perl_version_removed: called CC=2 SCAR=6.9
Pod documented
57 20 my ( $self ) = @_;
58 20 ▶ WEIRD_CHAR_RE
Branch: 1 branch
BranchTrueFalseTotal
$self->content =~ / (?! [\p{Noncharacter_code_point}\P{Any}] ) [\p{Unassigned}\p{Mark}] /msx and return "5.029" 1 19 20
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 return undef; ## no critic (ProhibitExplicitReturnUndef)
66 }
67  
68 7 1;
69  
70 __END__
« QuoteLike/Token.pm ↑ Summary QuoteLike/Constant.pm »