blib/lib/Devel/Caller/Util.pm

filter: Statementstmt 82.6% 38 / 46 Branchbran 53.5% 15 / 28 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 73.2% 63 / 86 CC 16 SCAR 31.2
CC
16
Cov
71%
callers
28.0
BEGIN
1.0
BEGIN
1.0
CRAP 22.6
↑ Summary
1 package Devel::Caller::Util;
2  
3 2 our $DATE = '2019-04-12'; # DATE
4 2 our $VERSION = '0.042'; # VERSION
5  
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 our @EXPORT_OK = qw(caller callers);
11  
12 2 my $_is_caller;
13  
14 8 ▶sub callers {
Subroutine callers: called CC=16 SCAR=33.3
Pod documented
15 8 my ($start, $with_args, $packages_to_ignore, $subroutines_to_ignore) = @_;
16 8 ▶ $start = 0 unless defined $start;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $start 1 7 8
17  
18 8 my @res;
19 8 my $i = 1;
20  
21 8 while (1) {
22 11 my @caller;
23 11 ▶ if ($with_args) {
Branch: 1 branch
BranchTrueFalseTotal
if ($with_args) { } 0 11 11
24 {
25 0 package # hide from PAUSE
26 DB;
27 0 @caller = caller($i);
28 0 ▶ $caller[11] = [@DB::args] if @caller;
Branch: 1 branch
BranchTrueFalseTotal
if @caller 0 0 0
29 }
30 } else {
31 11 @caller = caller($i);
32 }
33 11 ▶ last unless @caller;
Branch: 1 branch
BranchTrueFalseTotal
unless @caller 5 6 11
34 6 $i++;
35  
36 6 ▶ if ($packages_to_ignore) {
Branch: 1 branch
BranchTrueFalseTotal
if ($packages_to_ignore) 3 3 6
37 3 ▶ if (ref $packages_to_ignore eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $packages_to_ignore eq 'ARRAY') { } 3 0 3
38 3 ▶ next if grep { $_ eq $caller[0] } @$packages_to_ignore;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ eq $caller[0];} @$packages_to_ignore 1 2 3
39 } else {
40 0 ▶ next if $caller[0] =~ $packages_to_ignore;
Branch: 1 branch
BranchTrueFalseTotal
if $caller[0] =~ /$packages_to_ignore/ 0 0 0
41 }
42 }
43  
44 5 ▶ if ($subroutines_to_ignore) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subroutines_to_ignore) 0 5 5
45 0 ▶ if (ref $subroutines_to_ignore eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $subroutines_to_ignore eq 'ARRAY') { } 0 0 0
46 0 ▶ next if grep { $_ eq $caller[3] } @$subroutines_to_ignore;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ eq $caller[3];} @$subroutines_to_ignore 0 0 0
47 } else {
48 0 ▶ next if $caller[3] =~ $subroutines_to_ignore;
Branch: 1 branch
BranchTrueFalseTotal
if $caller[3] =~ /$subroutines_to_ignore/ 0 0 0
49 }
50 }
51  
52 5 push @res, \@caller;
53 5 ▶ do { $_is_caller = 0; return @caller } if $_is_caller && @res == $start+1;
Branch: 1 branch
BranchTrueFalseTotal
if ($_is_caller and @res == $start + 1) 3 2 5
Condition66%2/3
$_is_caller and @res == $start + 1
!ll&&!rl&&r
023
MC/DC50%1/2
$_is_caller and @res == $start + 1
$_is_caller @res == $start + 1
Truth table66%2/3
A and B
A= $_is_callerB= @res == $start + 1
ABresult
0X0
100
111
54 }
55  
56 5 ▶ splice @res, 0, $start if $start;
Branch: 1 branch
BranchTrueFalseTotal
if $start 3 2 5
57 5 $_is_caller = 0;
58 5 @res;
59 }
60  
61 8 ▶sub caller {
Subroutine caller: called CC=1 SCAR=0.0
Pod documented
62 8 $_is_caller = 1; # "local" doesn't work here
63 8 goto &callers;
64 }
65  
66 2 1;
67 # ABSTRACT: caller()-related utility routines
68  
69 __END__
↑ Summary