| 1 | package exact; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Perl pseudo pragma to enable strict, warnings, features, mro, filehandle methods | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 13 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 13 | ▶ | use B::Deparse; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 13 | ▶ | use Import::Into; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 13 | ▶ | use Sub::Util 'set_subname'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 13 | ▶ | use Syntax::Keyword::Defer; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 13 | ▶ | use Syntax::Keyword::Try; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 13 | our $VERSION = '1.32'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 13 | ▶ | use feature (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 13 | ▶ | use utf8 (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 13 | ▶ | use mro (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 13 | ▶ | use Carp qw( croak carp confess cluck ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 13 | ▶ | use IO::File (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 13 | ▶ | use IO::Handle (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 13 | ▶ | use Try::Tiny (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 13 | ▶ | use PerlX::Maybe (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 13 | my ($perl_version) = $^V =~ /^v5\.(\d+)/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | my $features_available = ( %feature::feature_bundle and $feature::feature_bundle{all} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ? $feature::feature_bundle{all} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 13 | ▶ | : [ qw( say state switch unicode_strings ) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
%feature::feature_bundle and $feature::feature_bundle{"all"}
MC/DC0%0/2
%feature::feature_bundle and $feature::feature_bundle{"all"}
%feature::feature_bundle
$feature::feature_bundle{"all"}
Truth table33%1/3
A and B
A= %feature::feature_bundleB= $feature::feature_bundle{"all"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 13 | my $functions_available = [ qw( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | nostrict nowarnings | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | nofeatures nobundle noskipexperimentalwarnings | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | noutf8 noc3 nocarp notry trytiny nodefer nomaybe noautoclean | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 13 | my $functions_deprecated = ['noexperiments']; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 13 | my ( $no_parent, $late_parent ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 20 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=43 SCAR=42.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 20 | my ( $self, $caller ) = ( shift, caller() ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 20 | my ( @features, @nofeatures, @functions, @bundles, @classes ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 20 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 7 | ( my $opt = $_ ) =~ s/^\-//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 7 | ▶ | if ( $opt eq 'class' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | push( @classes, $opt ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | elsif ( $opt eq 'cor' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | push( @features, 'class' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | elsif ( $opt eq 'nocor' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | push( @nofeatures, 'class' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 189 | elsif ( grep { $_ eq $opt } @$features_available ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | push( @features, $opt ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 162 | elsif ( my ($nofeature) = grep { 'no' . $_ eq $opt } @$features_available ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | push( @nofeatures, $nofeature ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 70 | elsif ( grep { $_ eq $opt } @$functions_available, @$functions_deprecated ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | ▶ | push( @functions, $opt ) if ( grep { $_ eq $opt } @$functions_available ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ▶ | elsif ( $opt =~ /^:?v?5?\.?(\d+)/ and $1 >= 10 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opt =~ /^:?v?5?\.?(\d+)/u and $1 >= 10
MC/DC50%1/2
$opt =~ /^:?v?5?\.?(\d+)/u and $1 >= 10
$opt =~ /^:?v?5?\.?(\d+)/u
$1 >= 10
Truth table66%2/3
A and B
A= $opt =~ /^:?v?5?\.?(\d+)/uB= $1 >= 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | push( @bundles, $1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | ▶ | push( @classes, $opt ) if ( $opt !~ /^no[a-z]{2}/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 20 | ▶ | strict ->import unless ( grep { $_ eq 'nostrict' } @functions ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 20 | ▶ | warnings->import unless ( grep { $_ eq 'nowarnings' } @functions ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 20 | ▶ | if (@bundles) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | feature->import( ':5.' . $_ ) for (@bundles); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
grep({$_ eq 'nofeatures';} @functions) || grep({$_ eq 'nobundle';} @functions)
MC/DC50%1/2
grep({$_ eq 'nofeatures';} @functions) || grep({$_ eq 'nobundle';} @functions)
grep({$_ eq 'nofeatures';} @functions)
grep({$_ eq 'nobundle';} @functions)
Truth table66%2/3
A || B
A= grep({$_ eq 'nofeatures';} @functions)B= grep({$_ eq 'nobundle';} @functions)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | not grep { $_ eq 'nofeatures' } @functions and | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | not grep { $_ eq 'nobundle' } @functions | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 18 | ▶ | feature->import( $perl_version >= 16 ? ':all' : ':5.' . $perl_version ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 20 | feature->import($_) for (@features); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 20 | feature->unimport($_) for (@nofeatures); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 20 | ▶ | unless ( grep { $_ eq 'noutf8' } @functions ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 20 | utf8->import; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 20 | binmode( $_, ':utf8' ) for ( *STDIN, *STDERR, *STDOUT ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 20 | 'open'->import::into( $caller, ':std', ':utf8' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 20 | ▶ | mro::set_mro( $caller, 'c3' ) unless ( grep { $_ eq 'noc3' } @functions ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | monkey_patch( $self, $caller, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 80 | ( map { $_ => \&{ 'Carp::' . $_ } } qw( croak carp confess cluck ) ), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 40 | ( map { $_ => \&{$_} } qw( deat deattry ) ), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 20 | ▶ | ) unless ( grep { $_ eq 'nocarp' } @functions ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | feature->unimport('try') if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 540 | ▶ | grep { $_ eq 'try' } @$features_available and | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
grep {$_ eq "notry";} @functions or grep {$_ eq "trytiny";} @functions
MC/DC0%0/2
grep {$_ eq "notry";} @functions or grep {$_ eq "trytiny";} @functions
grep {$_ eq "notry";} @functions
grep {$_ eq "trytiny";} @functions
Truth table33%1/3
A or B
A= grep {$_ eq "notry";} @functionsB= grep {$_ eq "trytiny";} @functions
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | grep { $_ eq 'notry' } @functions or | |||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 20 | ▶ | grep { $_ eq 'trytiny' } @functions | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
grep {$_ eq "try";} @$features_available and grep({$_ eq "notry";} @functions) || grep({$_ eq "trytiny";} @functions)
MC/DC0%0/2
grep {$_ eq "try";} @$features_available and grep({$_ eq "notry";} @functions) || grep({$_ eq "trytiny";} @functions)
grep {$_ eq "try";} @$features_available
grep({$_ eq "notry";} @functions) || grep({$_ eq "trytiny";} @functions)
Truth table33%1/3
A and B
A= grep {$_ eq "try";} @$features_availableB= grep({$_ eq "notry";} @functions) || grep({$_ eq "trytiny";} @functions)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | Syntax::Keyword::Try->import_into($caller) if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | $perl_version < 36 and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | not grep { $_ eq 'notry' } @functions and | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | not grep { $_ eq 'trytiny' } @functions | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$perl_version < 36 and not grep({$_ eq "notry";} @functions) and not grep({$_ eq "trytiny";} @functions)
$perl_version < 36 and not grep({$_ eq "notry";} @functions)
MC/DC0%0/3
$perl_version < 36 and not grep({$_ eq "notry";} @functions) and not grep({$_ eq "trytiny";} @functions)
$perl_version < 36
not grep({$_ eq "notry";} @functions)
not grep({$_ eq "trytiny";} @functions)
Truth table25%1/4
A and not(B) and not(C)
A= $perl_version < 36B= not grep({$_ eq "notry";} @functions)C= not grep({$_ eq "trytiny";} @functions)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 20 | ▶ | Try::Tiny->import::into($caller) if ( grep { $_ eq 'trytiny' } @functions ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | Syntax::Keyword::Defer->import_into($caller) if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | $perl_version < 36 and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | not grep { $_ eq 'nodefer' } @functions | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$perl_version < 36 and not grep({$_ eq "nodefer";} @functions)
MC/DC0%0/2
$perl_version < 36 and not grep({$_ eq "nodefer";} @functions)
$perl_version < 36
not grep({$_ eq "nodefer";} @functions)
Truth table33%1/3
A and not(B)
A= $perl_version < 36B= not grep({$_ eq "nodefer";} @functions)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 80 | monkey_patch( $self, $caller, ( map { $_ => \&{ 'PerlX::Maybe::' . $_ } } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | maybe provided provided_deref provided_deref_with_maybe | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 20 | ▶ | ) ) ) unless ( grep { $_ eq 'nomaybe' } @functions ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 20 | my @late_parents = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 3 | ▶ | my $use = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 3 | my ( $class, $pm, $caller, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | my $failed_require; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 3 | ▶ | require "$pm" unless ( do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 13 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 13 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 3 | ${"${caller}::INC"}{$pm}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | catch ($e) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | ▶ | croak($e) unless ( index( $e, qq{Can't locate $pm in } ) == 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | ( $no_parent, $late_parent ) = ( undef, undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | my $is_exact_extension = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 13 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | $is_exact_extension = grep { index( $_, 'exact::' ) == 0 } $class, @{"${class}::ISA"}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | ▶ | $class->import( $params, $caller ) if ( $is_exact_extension and $class->can('import') ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$is_exact_extension and $class->can("import")
MC/DC50%1/2
$is_exact_extension and $class->can("import")
$is_exact_extension
$class->can("import")
Truth table66%2/3
A and B
A= $is_exact_extensionB= $class->can("import")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | ▶ | if ($late_parent) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | push( @late_parents, [ $class, $caller ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | ▶ | elsif ( not $no_parent and index( $class, 'exact::' ) != 0 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
not $no_parent and index($class, "exact::") != 0
MC/DC50%1/2
not $no_parent and index($class, "exact::") != 0
not $no_parent
index($class, "exact::") != 0
Truth table66%2/3
not(A) and B
A= not $no_parentB= index($class, "exact::") != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | $self->add_isa( $class, $caller ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 20 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 20 | for my $class (@classes) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | ▶ | my $params = ( $class =~ s/\(([^\)]+)\)// ) ? $1 : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | ( my $pm = $class ) =~ s{::|'}{/}g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | $pm .= '.pm'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | ▶ | $use->( 'exact::' . $class, 'exact/' . $pm, $caller, $params ) or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
&$use('exact::' . $class, 'exact/' . $pm, $caller, $params) or &$use($class, $pm, $caller, $params)
MC/DC0%0/2
&$use('exact::' . $class, 'exact/' . $pm, $caller, $params) or &$use($class, $pm, $caller, $params)
&$use('exact::' . $class, 'exact/' . $pm, $caller, $params)
&$use($class, $pm, $caller, $params)
Truth table66%2/3
A or B
A= &$use('exact::' . $class, 'exact/' . $pm, $caller, $params)B= &$use($class, $pm, $caller, $params)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | $use->( $class, $pm, $caller, $params ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | croak( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | "Can't locate exact/$pm or $pm in \@INC " . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | "(you may need to install the exact::$class or $class module)" . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | '(@INC contains: ' . join( ' ', @INC ) . ')' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 20 | $self->add_isa(@$_) for @late_parents; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | warnings->unimport('experimental') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 20 | ▶ | unless ( $perl_version < 18 or grep { $_ eq 'noskipexperimentalwarnings' } @functions ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$perl_version < 18 or grep {$_ eq "noskipexperimentalwarnings";} @functions
MC/DC0%0/2
$perl_version < 18 or grep {$_ eq "noskipexperimentalwarnings";} @functions
$perl_version < 18
grep {$_ eq "noskipexperimentalwarnings";} @functions
Truth table33%1/3
A or B
A= $perl_version < 18B= grep {$_ eq "noskipexperimentalwarnings";} @functions
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 20 | ▶ | namespace::autoclean->import( -cleanee => $caller ) unless ( grep { $_ eq 'noautoclean' } @functions ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 45 | ▶ | sub monkey_patch { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
monkey_patch: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 45 | my ( $self, $class, %patch ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 13 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 13 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 45 | *{"${class}::$_"} = set_subname( "${class}::$_", $patch{$_} ) for ( keys %patch ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 45 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 3 | ▶ | sub add_isa { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_isa: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | my ( $self, $parent, $child ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 13 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | ▶ | push( @{"${child}::ISA"}, $parent ) unless ( $child->isa($parent) ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | sub no_parent { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
no_parent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $no_parent = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | sub late_parent { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
late_parent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $late_parent = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | ▶ | sub _patch_import { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_patch_import: called CC=2 SCAR=8.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | my ( $type, $self, @names ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | my $target = ( caller(1) )[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | my $original_import = $target->can('import'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | my %groups; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | ▶ | if ( $type eq 'provide' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | %groups = map { %$_ } grep { ref $_ eq 'HASH' } @names; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | @names = grep { not ref $_ } @names; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | monkey_patch( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | $target, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | import => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=30.2
Subroutine
import: called CC=8 SCAR=30.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | my ( $package, @exports ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if ( $original_import and ref $original_import eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
$original_import and ref $original_import eq "CODE"
$original_import and ref $original_import eq "CODE"
MC/DC0%0/2
$original_import and ref $original_import eq "CODE"
$original_import
ref $original_import eq "CODE"
MC/DC0%0/2
$original_import and ref $original_import eq "CODE"
$original_import
ref $original_import eq "CODE"
Truth table0%0/3
A and B
A= $original_importB= ref $original_import eq "CODE"
Truth table33%1/3
A and B
A= $original_importB= ref $original_import eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ( my $b_deparsed_sub = B::Deparse->new->coderef2text($original_import) ) =~ s/;//g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | $original_import->(@_) if ($b_deparsed_sub); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | if ( $type eq 'force' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | @exports = @names; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | elsif ( $type eq 'provide' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | @exports = grep { defined } map { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | my $name = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | ( grep { $name eq $_ } @names ) ? $name : | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | ( exists $groups{$name} ) ? ( @{ $groups{$name} } ) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } @exports; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | monkey_patch( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | $package, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | ( caller(0) )[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | map { $_ => \&{ $package . '::' . $_ } } @exports | |||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | ▶ | sub export { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
export: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | _patch_import( 'force', @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 1 | ▶ | sub exportable { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exportable: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | _patch_import( 'provide', @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | ▶ | sub deat ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deat: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | ( my $e = reverse $_[0] ) =~ s/^\s*\.\d+\s+enil\s+.*?\s+ta\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 2 | return '' . reverse $e; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 2 | ▶ | sub deattry (&) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deattry: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | return $_[0]->(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 2 | catch ($e) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | die deat $e, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||