File Coverage

blib/lib/Perl/Phase.pm
Criterion Covered Total %
statement 28 32 87.5
branch 20 22 90.9
condition n/a
subroutine 7 7 100.0
pod 4 4 100.0
total 59 65 90.7


line stmt bran cond sub pod time code
1             package Perl::Phase;
2              
3 3     3   289433 use strict;
  3         20  
  3         73  
4 3     3   12 use warnings;
  3         4  
  3         92  
5              
6             our $VERSION = '0.03';
7              
8 3     3   13 use XSLoader;
  3         4  
  3         841  
9             XSLoader::load(__PACKAGE__);
10              
11             sub is_compile_time {
12 7     7 1 7792 my $current_phase = current_phase();
13 7 100       32 return 1 if $current_phase == PERL_PHASE_CONSTRUCT();
14 6 100       19 return 1 if $current_phase == PERL_PHASE_START();
15 5 100       11 return 1 if $current_phase == PERL_PHASE_CHECK();
16 4         13 return;
17             }
18              
19             sub is_run_time {
20 7     7 1 21701 my $current_phase = current_phase();
21 7 100       33 return 1 if $current_phase == PERL_PHASE_INIT();
22 6 100       17 return 1 if $current_phase == PERL_PHASE_RUN();
23 5 100       13 return 1 if $current_phase == PERL_PHASE_END();
24 4 100       10 return 1 if $current_phase == PERL_PHASE_DESTRUCT();
25 3         11 return;
26             }
27              
28             sub assert_is_run_time {
29 2 100   2 1 4866 return 1 if is_run_time();
30              
31 1         9 my @caller = caller(1);
32 1 50       4 if (@caller) {
33 1         8 die "$caller[3]() called at compile time at $caller[1] line $caller[2]\n";
34             }
35             else {
36 0         0 die "This code should not be executed at compile time";
37             }
38              
39 0         0 return;
40             }
41              
42             sub assert_is_compile_time {
43 2 100   2 1 4432 return 1 if is_compile_time();
44              
45 1         10 my @caller = caller(1);
46 1 50       4 if (@caller) {
47 1         7 die "$caller[3]() called at run time at $caller[1] line $caller[2]\n";
48             }
49             else {
50 0           die "This code should not be executed at run time";
51             }
52              
53 0           return;
54             }
55              
56             1;
57              
58             __END__