blib/lib/Caller/Hide.pm

filter: Statementstmt 97.6% 42 / 43 Branchbran 81.2% 13 / 16 Conditioncond 100% 5 / 5 MC/DCmcdc 100% 3 / 3 Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 94.8% 74 / 78 CC 11 SCAR 17.7
CC
11
Cov
94%
__ANON__
10.1
reveal_package
2.0
BEGIN
1.0
CRAP 5.9
↑ Summary
1 package Caller::Hide;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use version 0.77; our $VERSION = version->declare('v0.0.1');
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our @EXPORT_OK = qw[ hide_package reveal_package ];
9 2 our %EXPORT_TAGS = (ALL => \@EXPORT_OK);
10  
11 2 my %hidden;
12  
13 { # adapted from Hook::LexWrap
14 2 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 74 ▶ *CORE::GLOBAL::caller = sub (;$) {
Subroutine __ANON__: called CC=10 SCAR=23.1
16 74 ▶ my ($height) = ($_[0] || 0);
Condition100%2/2
$_[0] || 0
l!l
5321
MC/DC100%1/1
$_[0] || 0
$_[0]
Truth table100%2/2
A
A= $_[0]
Aresult
11
00
17 74 my $i = 1;
18 74 my $name_cache;
19 74 while (1) {
20 my @caller
21 = CORE::caller() eq 'DB'
22 0 ▶ ? do { package DB; CORE::caller($i++) }
Branch: 1 branch
BranchTrueFalseTotal
caller() eq 'DB' ? : 0 319 319
23 : CORE::caller($i++);
24 319 ▶ return if not @caller;
Branch: 1 branch
BranchTrueFalseTotal
unless @caller 17 302 319
25 302 ▶ $caller[3] = $name_cache if $name_cache;
Branch: 1 branch
BranchTrueFalseTotal
if $name_cache 86 216 302
26 302 ▶ $name_cache = $hidden{ $caller[0] } ? $caller[3] : '';
Branch: 1 branch
BranchTrueFalseTotal
$hidden{$caller[0]} ? : 92 210 302
27 302 ▶ next if $name_cache || $height-- != 0;
Branch: 1 branch
BranchTrueFalseTotal
if $name_cache or $height-- != 0 245 57 302
Condition100%3/3
$name_cache or $height-- != 0
l!l&&r!l&&!r
9215357
MC/DC100%2/2
$name_cache or $height-- != 0
$name_cache $height-- != 0
Truth table100%3/3
A or B
A= $name_cacheB= $height-- != 0
ABresult
1X1
011
000
28 57 ▶ return wantarray ? @_ ? @caller : @caller[ 0 .. 2 ] : $caller[0];
Branch: 2 branches
BranchTrueFalseTotal
wantarray ? : 4 53 57
@_ ? : 4 0 4
29 }
30 2 };
31 }
32  
33 6 ▶sub hide_package {
Subroutine hide_package: called CC=1 SCAR=0.0
Pod documented
34 6 my ($package) = @_;
35 6 $hidden{$package} = 1;
36 6 return;
37 }
38  
39 6 ▶sub reveal_package {
Subroutine reveal_package: called CC=2 SCAR=7.0
Pod documented
40 6 my ($package) = @_;
41 6 ▶ Carp::carp "$package not hidden" if not $hidden{$package};
Branch: 1 branch
BranchTrueFalseTotal
unless $hidden{$package} 0 6 6
42  
43 6 delete $hidden{$package};
44 6 return;
45 }
46  
47 2 1;
48 __END__
↑ Summary