File Coverage

blib/lib/UNIVERSAL/source_location_for.pm
Criterion Covered Total %
statement 22 22 100.0
branch 3 4 75.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 31 33 93.9


line stmt bran cond sub pod time code
1             package UNIVERSAL::source_location_for;
2 2     2   54756 use 5.008_001;
  2         7  
  2         79  
3 2     2   12 use strict;
  2         5  
  2         63  
4 2     2   9 use warnings;
  2         8  
  2         110  
5              
6             our $VERSION = '0.11';
7              
8 2     2   11 use B ();
  2         2  
  2         41  
9 2     2   9 use Carp qw(carp);
  2         3  
  2         422  
10              
11             sub UNIVERSAL::source_location_for {
12 3     3 0 4066 my($self, $method) = @_;
13 3         35 my $entity = $self->can($method);
14              
15 3 100       12 unless ($entity) {
16 1 50       328 carp ("Undefined subroutine " . (ref $self ? ref $self : $self) . "::" . $method);
17 1         8 return();
18             }
19              
20 2         29 my $gv = B::svref_2object($entity)->GV;
21 2         31 return($gv->FILE, $gv->LINE);
22             }
23              
24             1;
25             __END__