« /usr/local/lib/perl5/5.44.0/x86_64-linux/attributes.pm
↑ Summary
/usr/local/lib/perl5/site_perl/5.44.0/Pod/Coverage.pm »
| 1 | package experimental; | ||||||||||||||||||||||||||||||
| 2 | 7 | $experimental::VERSION = '0.036'; | |||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use version (); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | BEGIN { eval { require feature } }; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Carp qw/croak carp/; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||
| 10 | 7 | my %warnings = map { $_ => 1 } grep { /^experimental::/ } keys %warnings::Offsets; | |||||||||||||||||||||||||||||
| 11 | 7 | my %removed_warnings = map { $_ => 1 } grep { /^experimental::/ } keys %warnings::NoOp; | |||||||||||||||||||||||||||||
| 12 | 7 | ▶ | my %features = map { $_ => 1 } $] > 5.015006 ? keys %feature::feature : do { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 13 | 0 | my @features; | |||||||||||||||||||||||||||||
| 14 | 0 | ▶ | if ($] >= 5.010) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 15 | 0 | push @features, qw/switch say state/; | |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | push @features, 'unicode_strings' if $] > 5.011002; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||
| 18 | 0 | @features; | |||||||||||||||||||||||||||||
| 19 | }; | ||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||
| 21 | 7 | my %min_version = ( | |||||||||||||||||||||||||||||
| 22 | args_array_with_signatures => '5.20.0', | ||||||||||||||||||||||||||||||
| 23 | array_base => '5', | ||||||||||||||||||||||||||||||
| 24 | autoderef => '5.14.0', | ||||||||||||||||||||||||||||||
| 25 | bitwise => '5.22.0', | ||||||||||||||||||||||||||||||
| 26 | builtin => '5.35.7', | ||||||||||||||||||||||||||||||
| 27 | class => '5.37.9', | ||||||||||||||||||||||||||||||
| 28 | const_attr => '5.22.0', | ||||||||||||||||||||||||||||||
| 29 | current_sub => '5.16.0', | ||||||||||||||||||||||||||||||
| 30 | declared_refs => '5.26.0', | ||||||||||||||||||||||||||||||
| 31 | defer => '5.35.4', | ||||||||||||||||||||||||||||||
| 32 | evalbytes => '5.16.0', | ||||||||||||||||||||||||||||||
| 33 | extra_paired_delimiters => '5.35.9', | ||||||||||||||||||||||||||||||
| 34 | fc => '5.16.0', | ||||||||||||||||||||||||||||||
| 35 | for_list => '5.35.5', | ||||||||||||||||||||||||||||||
| 36 | isa => '5.31.7', | ||||||||||||||||||||||||||||||
| 37 | keyword_all => '5.41.7', | ||||||||||||||||||||||||||||||
| 38 | keyword_any => '5.41.7', | ||||||||||||||||||||||||||||||
| 39 | lexical_topic => '5.10.0', | ||||||||||||||||||||||||||||||
| 40 | lexical_subs => '5.18.0', | ||||||||||||||||||||||||||||||
| 41 | postderef => '5.20.0', | ||||||||||||||||||||||||||||||
| 42 | postderef_qq => '5.20.0', | ||||||||||||||||||||||||||||||
| 43 | refaliasing => '5.22.0', | ||||||||||||||||||||||||||||||
| 44 | regex_sets => '5.18.0', | ||||||||||||||||||||||||||||||
| 45 | say => '5.10.0', | ||||||||||||||||||||||||||||||
| 46 | smartmatch => '5.10.0', | ||||||||||||||||||||||||||||||
| 47 | signatures => '5.20.0', | ||||||||||||||||||||||||||||||
| 48 | state => '5.10.0', | ||||||||||||||||||||||||||||||
| 49 | switch => '5.10.0', | ||||||||||||||||||||||||||||||
| 50 | try => '5.34.0', | ||||||||||||||||||||||||||||||
| 51 | unicode_eval => '5.16.0', | ||||||||||||||||||||||||||||||
| 52 | unicode_strings => '5.12.0', | ||||||||||||||||||||||||||||||
| 53 | win32_perlio => '5.8.0', | ||||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||
| 55 | 7 | my %removed_in_version = ( | |||||||||||||||||||||||||||||
| 56 | array_base => '5.30.0', | ||||||||||||||||||||||||||||||
| 57 | autoderef => '5.24.0', | ||||||||||||||||||||||||||||||
| 58 | lexical_topic => '5.24.0', | ||||||||||||||||||||||||||||||
| 59 | win32_perlio => '5.36.0', | ||||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||
| 62 | 7 | $_ = version->new($_) for values %min_version; | |||||||||||||||||||||||||||||
| 63 | 7 | $_ = version->new($_) for values %removed_in_version; | |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||
| 65 | 7 | my %additional = ( | |||||||||||||||||||||||||||||
| 66 | postderef => ['postderef_qq'], | ||||||||||||||||||||||||||||||
| 67 | switch => ['smartmatch'], | ||||||||||||||||||||||||||||||
| 68 | declared_refs => ['refaliasing'], | ||||||||||||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||
| 71 | 7 | ▶ | sub _enable { | ||||||||||||||||||||||||||||
|
Subroutine
_enable: called CC=12 SCAR=44.3
| |||||||||||||||||||||||||||||||
| 72 | 7 | my $pragma = shift; | |||||||||||||||||||||||||||||
| 73 | 7 | ▶ | if ($warnings{"experimental::$pragma"}) { | ||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||
| 74 | 7 | warnings->unimport("experimental::$pragma"); | |||||||||||||||||||||||||||||
| 75 | 7 | ▶ | feature->import($pragma) if exists $features{$pragma}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | _enable(@{ $additional{$pragma} }) if $additional{$pragma}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||
| 78 | elsif ($features{$pragma}) { | ||||||||||||||||||||||||||||||
| 79 | 0 | feature->import($pragma); | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | _enable(@{ $additional{$pragma} }) if $additional{$pragma}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||
| 82 | elsif ($removed_warnings{"experimental::$pragma"}) { | ||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | _enable(@{ $additional{$pragma} }) if $additional{$pragma}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||
| 85 | elsif (not exists $min_version{$pragma}) { | ||||||||||||||||||||||||||||||
| 86 | 0 | croak "Can't enable unknown feature $pragma"; | |||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||
| 88 | elsif ($] < $min_version{$pragma}) { | ||||||||||||||||||||||||||||||
| 89 | 0 | my $stable = $min_version{$pragma}->stringify; | |||||||||||||||||||||||||||||
| 90 | 0 | $stable =~ s/^ 5\. ([0-9]?[13579]) \. \d+ $/"5." . ($1 + 1) . ".0"/xe; | |||||||||||||||||||||||||||||
| 91 | 0 | croak "Need perl $stable or later for feature $pragma"; | |||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||
| 93 | ▶ | elsif ($] >= ($removed_in_version{$pragma} || 7)) { | |||||||||||||||||||||||||||||
|
Condition0%0/2
$removed_in_version{$pragma} || 7
MC/DC0%0/1
$removed_in_version{$pragma} || 7
$removed_in_version{$pragma}
Truth table0%0/2
A
A= $removed_in_version{$pragma}
| |||||||||||||||||||||||||||||||
| 94 | 0 | croak "Experimental feature $pragma has been removed from perl in version $removed_in_version{$pragma}"; | |||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||
| 98 | 7 | ▶ | sub import { | ||||||||||||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 99 | 7 | my ($self, @pragmas) = @_; | |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||
| 101 | 7 | for my $pragma (@pragmas) { | |||||||||||||||||||||||||||||
| 102 | 7 | _enable($pragma); | |||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||
| 104 | 7 | return; | |||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub _disable { | ||||||||||||||||||||||||||||
|
Subroutine
_disable: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||
| 108 | 0 | my $pragma = shift; | |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ($warnings{"experimental::$pragma"}) { | ||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||
| 110 | 0 | warnings->import("experimental::$pragma"); | |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | feature->unimport($pragma) if exists $features{$pragma}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | _disable(@{ $additional{$pragma} }) if $additional{$pragma}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||
| 114 | elsif ($features{$pragma}) { | ||||||||||||||||||||||||||||||
| 115 | 0 | feature->unimport($pragma); | |||||||||||||||||||||||||||||
| 116 | 0 | ▶ | _disable(@{ $additional{$pragma} }) if $additional{$pragma}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||
| 118 | elsif (not exists $min_version{$pragma}) { | ||||||||||||||||||||||||||||||
| 119 | 0 | carp "Can't disable unknown feature $pragma, ignoring"; | |||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub unimport { | ||||||||||||||||||||||||||||
|
Subroutine
unimport: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||
| 124 | 0 | my ($self, @pragmas) = @_; | |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||
| 126 | 0 | for my $pragma (@pragmas) { | |||||||||||||||||||||||||||||
| 127 | 0 | _disable($pragma); | |||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||
| 129 | 0 | return; | |||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||
| 132 | 7 | 1; | |||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||
| 134 | #ABSTRACT: Experimental features made easy | ||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||
| 136 | __END__ | ||||||||||||||||||||||||||||||