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   49 use strict;
  12     2   16  
  12         297  
  2         458  
  2         18  
  2         27  
9 12     12   48 use warnings;
  12     2   13  
  12         329  
  2         5  
  2         25  
  2         28  
10              
11 12     12   42 use Carp ();
  12     2   21  
  12         873  
  2         5  
  2         101  
  2         128  
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   47 no warnings 'redefine'; ## no critic (ProhibitNoWarnings)
  12     1   18  
  12         820  
  2         5  
  2         70  
  1         62  
30              
31             sub import {
32 1     1   914 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__