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 2     2   208030 use strict;
  2         13  
  2         57  
4 2     2   10 use warnings;
  2         2  
  2         73  
5              
6             our $VERSION = '0.02';
7              
8 2     2   11 use XSLoader;
  2         4  
  2         731  
9             XSLoader::load(__PACKAGE__);
10              
11             sub is_compile_time {
12 7     7 1 9446 my $current_phase = current_phase();
13 7 100       40 return 1 if $current_phase == PERL_PHASE_CONSTRUCT();
14 6 100       21 return 1 if $current_phase == PERL_PHASE_START();
15 5 100       14 return 1 if $current_phase == PERL_PHASE_CHECK();
16 4         16 return;
17             }
18              
19             sub is_run_time {
20 7     7 1 26533 my $current_phase = current_phase();
21 7 100       38 return 1 if $current_phase == PERL_PHASE_INIT();
22 6 100       23 return 1 if $current_phase == PERL_PHASE_RUN();
23 5 100       13 return 1 if $current_phase == PERL_PHASE_END();
24 4 100       12 return 1 if $current_phase == PERL_PHASE_DESTRUCT();
25 3         12 return;
26             }
27              
28             sub assert_is_run_time {
29 2 100   2 1 5968 return 1 if is_run_time();
30              
31 1         10 my @caller = caller(1);
32 1 50       5 if (@caller) {
33 1         11 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 5412 return 1 if is_compile_time();
44              
45 1         11 my @caller = caller(1);
46 1 50       5 if (@caller) {
47 1         9 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__