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 3     3   11 use utf8;
  3         3  
  3         33  
2 3     3   76 use strict;
  3         2  
  3         51  
3 3     3   9 use warnings;
  3         3  
  3         351  
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   1312 '""' => sub { ${ $_[0] } },
  4         16  
13 3     3   2536 ;
  3         3048  
  3         27  
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 8057 my ($self) = @_;
22 10 100       272 pack 'C', $$self ? 0xC3 : 0xC2;
23             }
24              
25             sub new {
26 6     6 0 8 my ($class, $v) = @_;
27 6 100       13 $v = $v ? 1 : 0;
28 6   33     91 bless \$v => ref($class) || $class;
29             }
30              
31             package DR::Msgpuck::True;
32 3     3   742 BEGIN { our @ISA = ('DR::Msgpuck::Bool'); }
33              
34             sub new {
35 3     3   1749 my ($class) = @_;
36 3         24 $class->SUPER::new(1);
37             }
38              
39             package DR::Msgpuck::False;
40 3     3   139 BEGIN { our @ISA = ('DR::Msgpuck::Bool'); }
41              
42             sub new {
43 3     3   980 my ($class) = @_;
44 3         12 $class->SUPER::new(0);
45             }
46              
47             1;
48              
49             __END__