File Coverage

blib/lib/warnings/lock.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 18 100.0


line stmt bran cond sub pod time code
1 1     1   16182 use strict;
  1         2  
  1         28  
2 1     1   3 use warnings;
  1         2  
  1         37  
3              
4             package warnings::lock;
5             # ABSTRACT: Lock down the set of warnings active in a lexical scope
6              
7             our $VERSION = '1';
8              
9 1     1   449 use Variable::Magic 'wizard', 'cast';
  1         957  
  1         143  
10              
11              
12             my $hints_key = __PACKAGE__ . '/desired_warning_bits';
13              
14             my $wiz = wizard set => sub {
15             ${^WARNING_BITS} = $^H{$hints_key}
16             if exists $^H{$hints_key};
17             };
18              
19             sub import {
20 1     1   6 $^H |= 0x20000;
21 1         8 $^H{$hints_key} = ${^WARNING_BITS};
22 1         20 cast ${^WARNING_BITS} => $wiz;
23             }
24              
25             sub unimport {
26 1     1   16 delete $^H{$hints_key};
27             }
28              
29             1;
30              
31             __END__