Exporter.pm

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 32 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 126 CC 25 SCAR 62.0
CC
25
Cov
0%
import
650.0
as_heavy
2.0
export
2.0
CRAP 492.9
« Exporter/Heavy.pm ↑ Summary
1 package Exporter;
2  
3 require 5.006;
4  
5 # Be lean.
6 #use strict;
7 #no strict 'refs';
8  
9 our $Debug = 0;
10 our $ExportLevel = 0;
11 our $Verbose ||= 0;
12 our $VERSION = '5.60_01';
13 our (%Cache);
14 # Carp does this now for us, so we can finally live w/o Carp
15 #$Carp::Internal{Exporter} = 1;
16  
17 sub as_heavy {
18 0 ▶ require Exporter::Heavy;
Subroutine as_heavy: not called CC=1 SCAR=6.9
Pod undocumented
19 # Unfortunately, this does not work if the caller is aliased as *name = \&foo
20 # Thus the need to create a lot of identical subroutines
21 0 my $c = (caller(1))[3];
22 0 $c =~ s/.*:://;
23 0 \&{"Exporter::Heavy::heavy_$c"};
24 }
25  
26 sub export {
27 0 ▶ goto &{as_heavy()};
Subroutine export: not called CC=1 SCAR=6.9
Pod undocumented
28 }
29  
30 sub import {
31 0 ▶ my $pkg = shift;
Subroutine import: not called CC=25 SCAR=64.8
32 0 my $callpkg = caller($ExportLevel);
33  
34 0 ▶ if ($pkg eq "Exporter" and @_ and $_[0] eq "import") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg eq "Exporter" and @_ and $_[0] eq "import") 0 0 0
Condition0%0/6
$pkg eq "Exporter" and @_ and $_[0] eq "import"
!ll&&!rl&&r
000
$pkg eq "Exporter" and @_
!ll&&!rl&&r
000
MC/DC0%0/3
$pkg eq "Exporter" and @_ and $_[0] eq "import"
$pkg eq "Exporter" @_ $_[0] eq "import"
Truth table0%0/4
A and B and C
A= $pkg eq "Exporter"B= @_C= $_[0] eq "import"
ABCresult
0XX0
10X0
1100
1111
35 0 *{$callpkg."::import"} = \&import;
36 0 return;
37 }
38  
39 # We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-(
40 0 my($exports, $fail) = (\@{"$pkg\::EXPORT"}, \@{"$pkg\::EXPORT_FAIL"});
41 0 ▶ return export $pkg, $callpkg, @_
Branch: 1 branch
BranchTrueFalseTotal
if $Verbose or $Debug or @$fail > 1 0 0 0
Condition0%0/6
$Verbose or $Debug or @$fail > 1
l!l&&r!l&&!r
000
$Verbose or $Debug
l!l&&r!l&&!r
000
MC/DC0%0/3
$Verbose or $Debug or @$fail > 1
$Verbose $Debug @$fail > 1
Truth table0%0/4
A or B or C
A= $VerboseB= $DebugC= @$fail > 1
ABCresult
1XX1
01X1
0011
0000
42 if $Verbose or $Debug or @$fail > 1;
43 0 ▶ my $export_cache = ($Cache{$pkg} ||= {});
Condition0%0/2
$Cache{$pkg} ||= {}
l!l
00
MC/DC0%0/1
$Cache{$pkg} ||= {}
$Cache{$pkg}
Truth table0%0/2
A
A= $Cache{$pkg}
Aresult
11
00
44 0 ▶ my $args = @_ or @_ = @$exports;
Branch: 1 branch
BranchTrueFalseTotal
my $args = @_ or @_ = @$exports 0 0 0
45  
46 0 local $_;
47 0 ▶ if ($args and not %$export_cache) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args and not %$export_cache) 0 0 0
Condition0%0/3
$args and not %$export_cache
!ll&&!rl&&r
000
MC/DC0%0/2
$args and not %$export_cache
$args not %$export_cache
Truth table0%0/3
A and not(B)
A= $argsB= not %$export_cache
ABresult
0X0
100
111
48 s/^&//, $export_cache->{$_} = 1
49 0 foreach (@$exports, @{"$pkg\::EXPORT_OK"});
50 }
51 0 my $heavy;
52 # Try very hard not to use {} and hence have to enter scope on the foreach
53 # We bomb out of the loop with last as soon as heavy is set.
54 0 ▶ if ($args or $fail) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args or $fail) { } 0 0 0
Condition0%0/3
$args or $fail
l!l&&r!l&&!r
000
MC/DC0%0/2
$args or $fail
$args $fail
Truth table0%0/3
A or B
A= $argsB= $fail
ABresult
1X1
011
000
55 ($heavy = (/\W/ or $args and not exists $export_cache->{$_}
56 or @$fail and $_ eq $fail->[0])) and last
57 0 ▶ foreach (@_);
Branch: 1 branch
BranchTrueFalseTotal
$heavy = /\W/ || $args && !exists $export_cache->{$_} || @$fail && $_ eq $fail->[0] and last 0 0 0
Condition0%0/12
/\W/ || $args && !exists $export_cache->{$_} || @$fail && $_ eq $fail->[0]
l!l&&r!l&&!r
000
/\W/ or $args and not exists $export_cache->{$_}
l!l&&r!l&&!r
000
$args and not exists $export_cache->{$_}
!ll&&!rl&&r
000
@$fail and $_ eq $fail->[0]
!ll&&!rl&&r
000
MC/DC0%0/5
/\W/ || $args && !exists $export_cache->{$_} || @$fail && $_ eq $fail->[0]
/\W/ $args not exists $export_cache->{$_} @$fail $_ eq $fail->[0]
Truth table0%0/8
A or B and not(C) || D and E
A= /\W/B= $argsC= not exists $export_cache->{$_}D= @$failE= $_ eq $fail->[0]
ABCDEresult
1XXXX1
011XX1
00X111
010111
00X0X0
00X100
0100X0
010100
58 } else {
59 ($heavy = /\W/) and last
60 0 ▶ foreach (@_);
Branch: 1 branch
BranchTrueFalseTotal
$heavy = /\W/ and last 0 0 0
61 }
62 0 ▶ return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy;
Branch: 2 branches
BranchTrueFalseTotal
if $heavy 0 0 0
$args ? : 0 0 0
63 local $SIG{__WARN__} =
64 0 ▶ sub {require Carp; &Carp::carp};
Subroutine __ANON__: not called CC=1 SCAR=6.9
65 # shortcut for the common case of no type character
66 0 *{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_;
67 }
68  
69 # Default methods
70  
71 sub export_fail {
72 0 ▶ my $self = shift;
Subroutine export_fail: not called CC=1 SCAR=6.9
Pod undocumented
73 0 @_;
74 }
75  
76 # Unfortunately, caller(1)[3] "does not work" if the caller is aliased as
77 # *name = \&foo. Thus the need to create a lot of identical subroutines
78 # Otherwise we could have aliased them to export().
79  
80 sub export_to_level {
81 0 ▶ goto &{as_heavy()};
Subroutine export_to_level: not called CC=1 SCAR=6.9
Pod undocumented
82 }
83  
84 sub export_tags {
85 0 ▶ goto &{as_heavy()};
Subroutine export_tags: not called CC=1 SCAR=6.9
Pod undocumented
86 }
87  
88 sub export_ok_tags {
89 0 ▶ goto &{as_heavy()};
Subroutine export_ok_tags: not called CC=1 SCAR=6.9
Pod undocumented
90 }
91  
92 sub require_version {
93 0 ▶ goto &{as_heavy()};
Subroutine require_version: not called CC=1 SCAR=6.9
Pod undocumented
94 }
95  
96 1;
97 __END__
« Exporter/Heavy.pm ↑ Summary