File Coverage

blib/lib/T2.pm
Criterion Covered Total %
statement 38 318 11.9
branch 13 212 6.1
condition 3 279 1.0
subroutine 7 99 7.0
pod 0 94 0.0
total 61 1002 6.0


line stmt bran cond sub pod time code
1             package T2;
2 1     1   239619 use strict;
  1         2  
  1         39  
3 1     1   5 use warnings;
  1         4  
  1         503  
4              
5             our $VERSION = '0.002';
6              
7             my $INIT;
8             my $HANDLE;
9 0     0 0 0 sub handle { $HANDLE }
10              
11             sub import {
12 1     1   11 my $class = shift;
13 1         3 my ($handle) = @_;
14              
15 1         4 my ($caller, $file, $line) = caller;
16              
17 1 50       5 die "The ${ \__PACKAGE__ } namespace has already been initialized (Originally initiated at $INIT->[1] line $INIT->[2]) at $file line $line.\n"
  0         0  
18             if $INIT;
19              
20 1 50       3 unless ($handle) {
21 1 50       12 die "The '$caller' package does not provide a T2 handler at $file line $line.\n"
22             unless $caller->can('T2');
23              
24 1 50       4 $handle = $caller->T2 or die "Could not get handle via '$caller\->T2()' at $file line $line.\n";
25             }
26              
27 1 50       9 die "'$handle' is not a Test2::Handle instance at $file line $line.\n"
28             unless $handle->isa('Test2::Handle');
29              
30 1         3 $INIT = [$caller, $file, $line];
31 1         1 $HANDLE = $handle;
32              
33 1         7 for my $sym ($HANDLE->HANDLE_SUBS) {
34 93 50       718 next if $sym eq 'import';
35 93 50       183 next if $sym eq 'handle';
36              
37 93         285 my $code = $HANDLE->HANDLE_NAMESPACE->can($sym);
38 93         1073 my $proto = prototype($code);
39              
40 93 100       270 my $header = defined($proto) ? "sub $sym($proto) {" : "sub $sym {";
41              
42 93         125 my $line = __LINE__ + 3;
43 93 50       143 my $sub = eval <<" EOT" or die $@;
44 93         8821 #line $line ${ \__FILE__ }
45             $header
46 0     0 0 0 my (\$f) = \@_;
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  1     1 0 684  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  1     1 0 303  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  0     0 0 0  
  2     2 0 169255  
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
  0     0 0    
47 0 0 0     0 shift if \$f && "\$f" eq "$class";
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  1 50 33     49  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  1 50 33     11  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  0 0 0     0  
  2 50 33     16  
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
  0 0 0        
48 0         0 goto &\$code;
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         6  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  1         8  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  2         13  
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
49             };
50              
51             \\&$sym;
52             EOT
53              
54 1     1   11 no strict 'refs';
  1         2  
  1         391  
55 93         2528 *$sym = $sub;
56             }
57             }
58              
59             sub AUTOLOAD {
60 0     0     my ($this) = @_;
61              
62 0 0         if ($this) {
63 0 0         shift if "$this" eq 'T2';
64 0 0         shift if ref($this) eq 'T2';
65             }
66              
67 0           my ($name) = (our $AUTOLOAD =~ m/^(?:.*::)?([^:]+)$/);
68              
69 0           my @caller = caller;
70 0 0         my $sub = $HANDLE->HANDLE_NAMESPACE->can($name) or die qq{"$name" is not provided by this T2 handle at $caller[1] line $caller[2].\n};
71 0           goto &$sub;
72             }
73              
74             1;
75              
76             __END__