File Coverage

blib/lib/bitflags.pm
Criterion Covered Total %
statement 17 20 85.0
branch 5 6 83.3
condition n/a
subroutine 3 4 75.0
pod n/a
total 25 30 83.3


line stmt bran cond sub pod time code
1             package bitflags;
2              
3 1     1   519 use strict;
  1         2  
  1         180  
4              
5             my $i = .5;
6              
7              
8             sub import {
9 4     4   19 my $self = shift;
10 4         10 my $caller = (caller)[0];
11              
12 4 100       17 if ($_[0] =~ /^:start=(\^?)(\d+)$/) {
13 2 100       10 if ($1) { $i = 2 ** ($2-1) }
  1 50       2  
14             elsif ($2 & ($2 - 1)) {
15 0         0 require Carp;
16 0         0 Carp::croak("$2 is not a power of two");
17             }
18 1         3 else { $i = $2/2 }
19 2         2 shift;
20             }
21              
22 1     1   5 no strict 'refs';
  1         2  
  1         150  
23 4         8 for (@_) {
24 10         14 my $j = ($i *= 2);
25 10     0   236 *{"${caller}::$_"} = sub () { $j };
  10         2169  
  0            
26             }
27             }
28              
29              
30             1;
31              
32             __END__