| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | } else { | ||||||||||||||||||||||||||||
| 31 | 11 | @caller = caller($i); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | 11 | ▶ | last unless @caller; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 6 | $i++; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 6 | ▶ | if ($packages_to_ignore) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 3 | ▶ | if (ref $packages_to_ignore eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 3 | ▶ | next if grep { $_ eq $caller[0] } @$packages_to_ignore; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | } else { | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | next if $caller[0] =~ $packages_to_ignore; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 5 | ▶ | if ($subroutines_to_ignore) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if (ref $subroutines_to_ignore eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | next if grep { $_ eq $caller[3] } @$subroutines_to_ignore; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | } else { | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | next if $caller[3] =~ $subroutines_to_ignore; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
$_is_caller and @res == $start + 1
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
| |||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 5 | ▶ | splice @res, 0, $start if $start; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||