File Coverage

blib/lib/Class/Void.pm
Criterion Covered Total %
statement 20 21 95.2
branch 2 2 100.0
condition n/a
subroutine 10 11 90.9
pod 0 2 0.0
total 32 36 88.8


line stmt bran cond sub pod time code
1             package Class::Void;
2 1     1   15813 use strict;
  1         2  
  1         32  
3 1     1   4 use warnings;
  1         2  
  1         30  
4 1     1   4 use vars qw($VERSION $Nothin $new);
  1         4  
  1         95  
5             $VERSION = 0.05;
6              
7 9     9   428 use overload q("") => sub { "" }, # stringify to the empty string (returning undef is poised to create warnings)
8 1     1   1631 "nomethod" => sub { shift->new }; # call new for all other overloadable operators
  1     18   1036  
  1         11  
  18         1433  
9              
10             $new = sub {
11             # private sub so my name space doesnt get polluted which anything that could stop the AUTOLOAD sub from executing
12             my $scalar; # allocate an empty scalar
13             bless \$scalar, shift; # bless it into the calling package, and return it
14             };
15              
16             sub new {
17 27 100   27 0 731 $Nothin = $new->(shift) unless defined $Nothin; # define $Nothin once
18 27         81 return $Nothin;
19             }
20              
21             sub can {
22 1     1 0 616 my $class = shift;
23 1     1   229 sub { $class->new }
24 1         6 }
25              
26 7     7   642 sub AUTOLOAD { shift->new };
27              
28 0     0     sub DESTROY {}; # autoloading DESTROY would lead to an infinite loop because it'd create
29             # a new object which in turn calls destroy immediately and so on
30            
31             q
32              
33             __END__