File Coverage

blib/lib/Pointy/Counter.pm
Criterion Covered Total %
statement 31 33 93.9
branch 4 6 66.6
condition n/a
subroutine 11 12 91.6
pod 4 4 100.0
total 50 55 90.9


line stmt bran cond sub pod time code
1             package Pointy::Counter;
2              
3 4     4   100498 use 5.006;
  4         14  
  4         435  
4 4     4   24 use strict;
  4         6  
  4         533  
5              
6             our (@EXPORT, @ISA);
7             BEGIN
8             {
9 4     4   24 require Exporter;
10 4         61 @ISA = qw/Exporter/;
11 4         12 @EXPORT = qw/counter/;
12            
13 4         6 $Pointy::Counter::AUTHORITY = 'cpan:TOBYINK';
14 4         8 $Pointy::Counter::VERSION = '0.002';
15            
16 4 0       8 eval { require Object::AUTHORITY and import Object::AUTHORITY };
  4         2142  
17             }
18              
19             use overload
20 26     26   8026 '--' => sub { my ($self) = @_; $$self++ },
  26         78  
21 23     23   31 '>' => sub { my ($self, $other) = @_; $$self < $other },
  23         91  
22 20     20   1805 '""' => sub { my ($self) = @_; $$self },
  20         160  
23 0     0   0 '+0' => sub { my ($self) = @_; $$self },
  0         0  
24 4         59 fallback => 1,
25 4     4   7283 ;
  4         4154  
26              
27             sub new
28             {
29 5     5 1 23 my ($class, $initial) = @_;
30 5 100       23 $initial = 0 unless defined $initial;
31 5         21 bless \$initial, $class;
32             }
33              
34             sub counter
35             {
36 4     4 1 58 __PACKAGE__->new(@_);
37             }
38              
39             sub continue
40             {
41 1     1 1 16 my ($self) = @_;
42 1         4 --$$self;
43             }
44              
45             sub value :lvalue
46             {
47 8     8 1 28 my ($self) = shift;
48 8 100       24 $$self = shift if scalar @_;
49 8         110 $$self;
50             }
51              
52             __FILE__
53             __END__