| 1 | package experimentals; | ||||||||||||||||||||||||||||
| 2 | 2 | our $VERSION = '0.020'; | |||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use feature (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # Module enables/disables these features... | ||||||||||||||||||||||||||||
| 10 | my %FEATURES | ||||||||||||||||||||||||||||
| 11 | 2 | ▶ | = map { $_ => 1 } ( $] > 5.015006 ? keys %feature::feature | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 12 | : $] >= 5.011002 ? qw< say state switch unicode_strings > | ||||||||||||||||||||||||||||
| 13 | : $] >= 5.010000 ? qw< say state switch > | ||||||||||||||||||||||||||||
| 14 | : qw< > | ||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # Module disables these warnings... | ||||||||||||||||||||||||||||
| 18 | 2 | my %WARNINGS = map { $_ => 1 } grep { /^experimental::/ } keys %warnings::Offsets; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | # In -report mode, the code is not run... | ||||||||||||||||||||||||||||
| 21 | 2 | my $DO_NOT_RUN; | |||||||||||||||||||||||||||
| 22 | { | ||||||||||||||||||||||||||||
| 23 | 2 | ▶ | no warnings 'void'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | INIT { exit if $DO_NOT_RUN; } | ||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # Grab and reformat experimental warnings (when assigned to $SIG{__WARN__})... | ||||||||||||||||||||||||||||
| 28 | 2 | sub _report_experimentals { | |||||||||||||||||||||||||||
| 29 | 0 | ▶ | my $warning = "@_"; | ||||||||||||||||||||||||||
|
Subroutine
_report_experimentals: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # Reformat any experimental warning (ignoring anything else)... | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ($warning =~ m{\A(.*) is experimental\b(?:.*) at (.* line \d+)}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 0 | printf {*STDERR} "%s:\t%s\n", $2, ucfirst $1; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # Handle 'use experimentals'... | ||||||||||||||||||||||||||||
| 38 | sub import { | ||||||||||||||||||||||||||||
| 39 | # Handle deprecation of smartmatching in Perl 5.38..5.40 | ||||||||||||||||||||||||||||
| 40 | 3 | ▶ | warnings->unimport('deprecated::smartmatch') | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=6 SCAR=21.0
Branch: 1 branch
Condition33%1/3
$] >= "5.038" and $] < "5.042"
MC/DC0%0/2
$] >= "5.038" and $] < "5.042"
$] >= "5.038"
$] < "5.042"
Truth table33%1/3
A and B
A= $] >= "5.038"B= $] < "5.042"
| |||||||||||||||||||||||||||||
| 41 | if $] >= 5.038 && $] < 5.042; | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # Always enable all available features... | ||||||||||||||||||||||||||||
| 44 | 3 | feature->import(keys %FEATURES); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # Turn on utf8 if the feature requires it... | ||||||||||||||||||||||||||||
| 47 | 3 | ▶ | if ($FEATURES{ extra_paired_delimiters }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 3 | require utf8; | |||||||||||||||||||||||||||
| 49 | 3 | utf8->import(); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | # Are we reporting??? | ||||||||||||||||||||||||||||
| 53 | 3 | ▶ | my $reporting = grep { defined $_ && lc($_) eq '-report' } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # If not reporting, disable all warnings about experimental features... | ||||||||||||||||||||||||||||
| 56 | 3 | ▶ | if (!$reporting) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 3 | warnings->unimport(keys %WARNINGS); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # Otherwise, set up a filter to grab and reformat experimental warnings... | ||||||||||||||||||||||||||||
| 61 | else { | ||||||||||||||||||||||||||||
| 62 | # Enable the warnings we're going to grab... | ||||||||||||||||||||||||||||
| 63 | 0 | warnings->import(keys %WARNINGS); | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | # Install the code to grab them... | ||||||||||||||||||||||||||||
| 66 | 0 | $SIG{__WARN__} = \&_report_experimentals; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | # Prevent actual code execution... | ||||||||||||||||||||||||||||
| 69 | 0 | $DO_NOT_RUN = 1; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | # Handle 'no experimentals'... | ||||||||||||||||||||||||||||
| 74 | sub unimport { | ||||||||||||||||||||||||||||
| 75 | # Enable features that don't have experimental warnings... | ||||||||||||||||||||||||||||
| 76 | 2 | ▶ | feature->import(grep { !$WARNINGS{"experimental::$_"} } keys %FEATURES); | ||||||||||||||||||||||||||
|
Subroutine
unimport: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | # Enable experimental warnings... | ||||||||||||||||||||||||||||
| 79 | 2 | warnings->import(keys %WARNINGS); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 2 | 1; # Magic true value required at end of module | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||