File Coverage

blib/lib/Perl/Phase/AtRunTime.pm
Criterion Covered Total %
statement 32 32 100.0
branch 1 2 50.0
condition n/a
subroutine 10 10 100.0
pod n/a
total 43 44 97.7


line stmt bran cond sub pod time code
1             package Perl::Phase::AtRunTime;
2              
3 1     1   500 use strict;
  1         2  
  1         23  
4 1     1   4 use warnings;
  1         2  
  1         114  
5              
6             our $VERSION = '0.03';
7              
8             sub import {
9 2     2   2355 my ( $class, @runtime_calls ) = @_;
10              
11 2         5 my $caller = caller();
12 2         4 for my $rt_call (@runtime_calls) {
13              
14             # can not simply do:
15             # $rt_call->() if Perl::Phase::is_run_time();
16             # because then the code is not executed when the caller is loaded at compile time
17              
18 2         2 local $@;
19              
20             ## no critic qw(BuiltinFunctions::ProhibitStringyEval)
21 1     1   5 eval qq{
  1     1   2  
  1     1   29  
  1     1   4  
  1     1   1  
  1     1   47  
  1     1   6  
  1         1  
  1         27  
  1         6  
  1         1  
  1         91  
  1         6  
  1         2  
  1         52  
  1         5  
  1         2  
  1         29  
  1         83  
  2         106  
22             package $caller {
23             { # for use()
24             no warnings; ## no critic qw(TestingAndDebugging::ProhibitNoWarnings)
25             INIT {
26             use warnings;
27             \$rt_call->();
28             }
29             }
30              
31             # for require(), when its too late to run INIT
32             if( \${^GLOBAL_PHASE} eq 'RUN') {
33             use warnings; # for consistency w/ the INIT version
34             \$rt_call->();
35             }
36             };
37             };
38 2 50       18 die if $@;
39             }
40              
41 2         1476 return;
42             }
43              
44             1;
45              
46             __END__