File Coverage

blib/lib/_.pm
Criterion Covered Total %
statement 25 25 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod n/a
total 34 34 100.0


line stmt bran cond sub pod time code
1             # this matches, but perlcritic seems to use retarded regexes that don't get this.
2             ## no critic (Modules::RequireFilenameMatchesPackage)
3             package _;
4              
5             # PODNAME: _.pm
6             # ABSTRACT: do not use this module directly
7              
8 12     12   79 use strict;
  12     2   27  
  12         333  
  2         601  
  2         18  
  2         33  
9 12     12   66 use warnings;
  12     2   26  
  12         360  
  2         6  
  2         22  
  2         32  
10              
11 12     12   66 use Carp ();
  12     2   29  
  12         932  
  2         6  
  2         88  
  2         160  
12              
13             my $blow_up = sub {
14              
15             # Unload ourselves, so that "require _" gets trapped each time.
16             # However, this is only respected by Perl in the $_WE_COME_IN_PEACE mode.
17             delete $INC{'_.pm'};
18              
19             # be silent if this is being loaded by Util::Underscore
20             ## no critic (ProtectPrivateVars)
21             return 1 if ($Util::Underscore::_WE_COME_IN_PEACE // q[]) eq 'pinky swear';
22              
23             # loudly complain otherwise.
24             Carp::confess qq(The "_" package is internal to Util::Underscore)
25             . qq(and must not be imported directly.\n);
26             };
27              
28             {
29 12     12   67 no warnings 'redefine'; ## no critic (ProhibitNoWarnings)
  12     1   24  
  12         791  
  2         9  
  2         72  
  1         65  
30              
31             sub import {
32 1     1   838 return $blow_up->();
33             }
34             }
35              
36             # End with a true value in the $_WE_COME_IN_PEACE mode,
37             # otherwise use this as a chance to blow up
38             # – "import" has already been compiled after all.
39             ## no critic (Modules::RequireEndWithOne)
40             $blow_up->();
41              
42             __END__