lib/DR/Tnt/Dumper.pm

filter: Statementstmt 46.5% 20 / 43 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 2 totaltotal 39.3% 26 / 66 SCAR 29.6
CC
7
Cov
37%
pkt_dump
56.0
dump
2.0
BEGIN
1.0
CRAP 19.2
« lib/DR/Tnt/Msgpack/Types/Int.pm ↑ Summary blib/lib/DR/Tnt/Role/Logging.pm »
1 20 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package DR::Tnt::Dumper;
6 20 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 20 our @EXPORT = qw(pkt_dump dump);
8 20 ▶use constant DUMP_LINE_LEN => 16;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 20 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub pkt_dump($$) {
12 0 ▶ my ($name, $pkt) = @_;
Subroutine pkt_dump: not called CC=7 SCAR=40.3
Pod undocumented
13  
14 0 $name .= sprintf ' (%s octets)', length $pkt;
15 0 my @lines;
16  
17 0 ▶ while (DUMP_LINE_LEN < length $pkt) {
Branch: 1 branch
BranchTrueFalseTotal
if (16 < length $pkt) 0 0 0
18 0 push @lines, substr $pkt, 0, DUMP_LINE_LEN, '';
19 }
20 0 ▶ push @lines => $pkt if length $pkt;
Branch: 1 branch
BranchTrueFalseTotal
if length $pkt 0 0 0
21  
22 0 for (@lines) {
23  
24 0 $_ = [ $_, $_ ];
25  
26 0 $_->[0] =~ s/(.)/sprintf '%02X ', ord $1/ges;
27  
28 0 ▶ while (length($_->[0]) < (3 * DUMP_LINE_LEN)) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $_->[0] < 48) 0 0 0
29 0 $_->[0] .= ' ';
30 }
31 0 ▶ $_->[1] =~ s/(.)/((ord($1) >= 0x20) and (ord($1) <= 0x7F)) ? $1 : '.'/ges;
Branch: 1 branch
BranchTrueFalseTotal
ord $1 >= 32 && ord $1 <= 127 ? : 0 0 0
Condition0%0/3
ord $1 >= 32 and ord $1 <= 127
!ll&&!rl&&r
000
MC/DC0%0/2
ord $1 >= 32 and ord $1 <= 127
ord $1 >= 32 ord $1 <= 127
Truth table0%0/3
A and B
A= ord $1 >= 32B= ord $1 <= 127
ABresult
0X0
100
111
32  
33 0 $_ = "$_->[0] $_->[1]";
34 }
35 0 return join "\n", "request $name", @lines, "";
36 }
37  
38 sub dump($) {
39 0 ▶ my ($o) = @_;
Subroutine dump: not called CC=1 SCAR=6.9
Pod undocumented
40 0 local $Data::Dumper::Indent = 1;
41 0 local $Data::Dumper::Terse = 1;
42 0 local $Data::Dumper::Useqq = 1;
43 0 local $Data::Dumper::Deepcopy = 1;
44 0 local $Data::Dumper::Maxdepth = 0;
45 0 return Data::Dumper->Dump([$o]);
46 }
47  
48 20 1;
49  
50  
« lib/DR/Tnt/Msgpack/Types/Int.pm ↑ Summary blib/lib/DR/Tnt/Role/Logging.pm »