File Coverage

blib/lib/Alias/Any.pm
Criterion Covered Total %
statement 38 56 67.8
branch 4 10 40.0
condition 2 4 50.0
subroutine 11 13 84.6
pod n/a
total 55 83 66.2


line stmt bran cond sub pod time code
1             package Alias::Any;
2              
3 6     6   303222 use 5.012;
  6         55  
4 6     6   24 use warnings;
  6         7  
  6         204  
5              
6             our $VERSION = '0.000007';
7              
8 6     6   2244 use Keyword::Simple;
  6         107550  
  6         481  
9              
10             # Make 'keyword' and 'unkeyword' no-ops, unless Keyword::Declare is later loaded...
11             BEGIN {
12 0     0   0 sub _delete_source { my $ref = shift; $$ref =~ s{ \A .*? [#]END_OF_ALIAS }{}xms; }
  0         0  
13 6     6   26 Keyword::Simple::define( keyword => \&_delete_source );
14 6         134 Keyword::Simple::define( unkeyword => \&_delete_source );
15             }
16              
17 0         0 sub import {
18             # Below 5.22, alias keyword just injects Data::Alias...
19 7 50   7   309 if ($^V < 5.022) {
20             Keyword::Simple::define(
21             alias => sub {
22 0     0   0 my $ref = shift;
23 0         0 $$ref = q{use Data::Alias; Data::Alias::alias} . $$ref;
24             }
25 0         0 );
26             }
27              
28             # Above 5.22, alias keyword replaced with built-in syntax...
29 6     6   3227 use if $^V >= 5.022, 'Keyword::Declare';
  6         65  
  6         122  
30 7         18  
31 7 50 50     122 keyword alias (Variable|VariableDeclaration $variable, '=', Expr $expr) {{{
32 7         32 use feature 'refaliasing';
33             no warnings 'experimental::refaliasing';
34             \<{$variable}> = \<{$expr}>
35             }}} #END_OF_ALIAS
36 14     14   745639 }
  14         44  
  14         21  
  14         22  
  14         18  
37              
38 0           sub unimport {
39 14         26 # Below 5.22, alias keyword is undefined by Keyword::Simple...
  14         24  
  14         87  
40 7 50   2   62 if ($^V < 5.022) {
  2         462  
41 0         0 Keyword::Simple::undefine('alias');
42 6 0   6   554561 if ($Keyword::Simple::VERSION < 0.04) {
  0         0  
43 0         0 $^H{'Keyword::Simple/keywords'} =~ s{ alias:(?:\d+|-\d*)}{}g;
44             }
45             }
46 0         0  
  0         0  
  0         0  
  0         0  
  0         0  
47             # Above 5.22, alias keyword is unkeyworded by Keyword::Declare...
48 6     6   1163 use if $^V >= 5.022, 'Keyword::Declare';
  6         11  
  6         166  
  2         5  
49 0 50 50     0 unkeyword alias; #END_OF_ALIAS
  0         0  
  0         0  
  2         28  
  2         8  
50 6         44 }
  2         80  
51 6     6   144927  
52 6         653  
53             1; # Magic true value required at end of module
54             __END__