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   42 use strict;
  12     2   15  
  12         283  
  2         379  
  2         16  
  2         27  
9 12     12   43 use warnings;
  12     2   14  
  12         286  
  2         3  
  2         22  
  2         21  
10              
11 12     12   37 use Carp ();
  12     2   14  
  12         828  
  2         3  
  2         69  
  2         107  
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   43 no warnings 'redefine'; ## no critic (ProhibitNoWarnings)
  12     1   15  
  12         769  
  2         4  
  2         58  
  1         59  
30              
31             sub import {
32 1     1   709 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__