lib/DR/Tnt/Msgpack/Types/Int.pm

filter: Statementstmt 86.4% 32 / 37 Branchbran 45.8% 11 / 24 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 67.5% 52 / 77 SCAR 29.9
CC
14
Cov
69%
TO_MSGPACK
21.3
new
4.8
TO_JSON
2.0
CRAP 20.0
« lib/DR/Tnt/Test.pm ↑ Summary lib/DR/Tnt/Dumper.pm »
1 11 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package DR::Tnt::Msgpack::Types::Int;
6 11 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 $Carp::Internal{ (__PACKAGE__) }++;
8 11 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub new {
11 19 ▶ my ($class, $v) = @_;
Subroutine new: called CC=4 SCAR=15.6
Pod undocumented
12 19 ▶ if (defined $v) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v) 19 0 19
13 19 ▶ croak "$v is not looks_like_number"
Branch: 1 branch
BranchTrueFalseTotal
unless &Scalar::Util::looks_like_number($v) 0 19 19
14 unless Scalar::Util::looks_like_number $v;
15 }
16 19 ▶ bless \$v => ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0190
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
17 }
18  
19  
20 sub TO_MSGPACK {
21 16 ▶ my ($self) = @_;
Subroutine TO_MSGPACK: called CC=10 SCAR=30.6
Pod undocumented
22 16 my $v = $$self;
23  
24 16 ▶ return pack 'C', 0xC0 unless defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 16 16
25 16 ▶ if ($v < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v < 0) 0 16 16
26 0 ▶ return pack 'c', $v if $v >= -0x1F - 1;
Branch: 1 branch
BranchTrueFalseTotal
if $v >= -32 0 0 0
27 0 ▶ return pack 'Cc', 0xD0, $v if $v >= -0x7F - 1;
Branch: 1 branch
BranchTrueFalseTotal
if $v >= -128 0 0 0
28 0 ▶ return pack 'Cs>', 0xD1, $v if $v >= -0x7FFF - 1;
Branch: 1 branch
BranchTrueFalseTotal
if $v >= -32768 0 0 0
29 0 ▶ return pack 'Cl>', 0xD2, $v if $v >= -0x7FFF_FFFF - 1;
Branch: 1 branch
BranchTrueFalseTotal
if $v >= '-2147483648' 0 0 0
30 0 return pack 'cq>', 0xD3, $v;
31 }
32
33 16 ▶ return pack 'C', $v if $v <= 0x7F;
Branch: 1 branch
BranchTrueFalseTotal
if $v <= 127 5 11 16
34 11 ▶ return pack 'Cs>', 0xD1, $v if $v <= 0x7FFF;
Branch: 1 branch
BranchTrueFalseTotal
if $v <= 32767 4 7 11
35 7 ▶ return pack 'Cl>', 0xD2, $v if $v <= 0x7FFF_FFFF;
Branch: 1 branch
BranchTrueFalseTotal
if $v <= 2147483647 4 3 7
36 3 return pack 'Cq>', 0xD3, $v;
37 }
38  
39 sub TO_JSON {
40 1 ▶ my ($self) = @_;
Subroutine TO_JSON: called CC=2 SCAR=7.1
Pod undocumented
41 1 ▶ return undef unless defined $$self;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$self 0 1 1
42 1 return int $$self;
43 }
44  
45  
46 =head1 NAME
47  
48 DR::Tnt::Msgpack::Types::Int - container for integer.
49  
50 =head1 SYNOPSIS
51  
52 use DR::Tnt::Msgpack::Types::Int;
53  
54 my $o = DR::Tnt::Msgpack::Types::Int->new(123);
55 my $blob = msgpack($o);
56  
57 =head1 DESCRIPTION
58  
59 See L<DR::Tnt::Msgpack::Types>.
60  
61 =cut
62  
63 11 1;
« lib/DR/Tnt/Test.pm ↑ Summary lib/DR/Tnt/Dumper.pm »