File Coverage

blib/lib/DR/Msgpuck/Bool.pm
Criterion Covered Total %
statement 25 33 75.7
branch 4 6 66.6
condition 1 3 33.3
subroutine 11 15 73.3
pod 0 3 0.0
total 41 60 68.3


line stmt bran cond sub pod time code
1 4     4   11 use utf8;
  4         25  
  4         17  
2 4     4   114 use strict;
  4         4  
  4         52  
3 4     4   10 use warnings;
  4         6  
  4         382  
4              
5              
6             package DR::Msgpuck::Bool;
7              
8             use overload
9 0     0   0 bool => sub { ${ $_[0] } },
  0         0  
10 0     0   0 int => sub { ${ $_[0] } },
  0         0  
11 0     0   0 '!' => sub { $_[0]->new(!${ $_[0] }) },
  0         0  
12 4     4   1479 '""' => sub { ${ $_[0] } },
  4         15  
13 4     4   2721 ;
  4         3400  
  4         31  
14              
15             sub TO_JSON {
16 0     0 0 0 my ($self) = @_;
17 0 0       0 $$self ? 'true' : 'false';
18             }
19              
20             sub TO_MSGPACK {
21 10     10 0 11392 my ($self) = @_;
22 10 100       343 pack 'C', $$self ? 0xC3 : 0xC2;
23             }
24              
25             sub new {
26 6     6 0 9 my ($class, $v) = @_;
27 6 100       12 $v = $v ? 1 : 0;
28 6   33     72 bless \$v => ref($class) || $class;
29             }
30              
31             package DR::Msgpuck::True;
32 4     4   847 BEGIN { our @ISA = ('DR::Msgpuck::Bool'); }
33              
34             sub new {
35 3     3   986 my ($class) = @_;
36 3         20 $class->SUPER::new(1);
37             }
38              
39             package DR::Msgpuck::False;
40 4     4   144 BEGIN { our @ISA = ('DR::Msgpuck::Bool'); }
41              
42             sub new {
43 3     3   649 my ($class) = @_;
44 3         14 $class->SUPER::new(0);
45             }
46              
47             1;
48              
49             __END__