Mux/Buffer.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 6 / 6 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 6 totaltotal 89.8% 53 / 59 CC 5 SCAR 7.3
CC
5
Cov
100%
shift_data
4.0
push_packet
2.0
BEGIN
1.0
CRAP 2.1
« Mux.pm ↑ Summary
1 package IO::Mux::Buffer ;
2  
3 4 ▶use strict ;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use IO::Mux::Packet ;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Carp ;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 4 our $VERSION = '0.08' ;
9  
10  
11 19 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
12 19 my $class = shift ;
13  
14 19 my $this = {} ;
15 19 $this->{buf} = '' ;
16 19 $this->{closed} = 0 ;
17  
18 19 return bless($this, $class) ;
19 }
20  
21  
22 81 ▶sub get_length {
Subroutine get_length: called CC=1 SCAR=0.0
Pod undocumented
23 81 my $this = shift ;
24  
25 81 return length($this->{buf}) ;
26 }
27  
28  
29 28 ▶sub get_data {
Subroutine get_data: called CC=1 SCAR=0.0
Pod undocumented
30 28 my $this = shift ;
31  
32 28 return $this->{buf} ;
33 }
34  
35  
36 35 ▶sub is_closed {
Subroutine is_closed: called CC=1 SCAR=0.0
Pod undocumented
37 35 my $this = shift ;
38  
39 35 return $this->{closed} ;
40 }
41  
42  
43 34 ▶sub push_packet {
Subroutine push_packet: called CC=2 SCAR=6.9
Pod undocumented
44 34 my $this = shift ;
45 34 my $packet = shift ;
46  
47 34 ▶ if ($packet->is_eof()){
Branch: 1 branch
BranchTrueFalseTotal
if ($packet->is_eof) { } 6 28 34
48 6 $this->{closed} = 1 ;
49 }
50 else {
51 28 $this->{buf} .= $packet->get_data() ;
52 }
53 }
54  
55  
56 28 ▶sub shift_data {
Subroutine shift_data: called CC=4 SCAR=13.9
Pod undocumented
57 28 my $this = shift ;
58 28 ▶ my $len = shift || 0 ;
Condition100%2/2
shift() || 0
l!l
271
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
59  
60 28 ▶ return '' if $len < 0 ;
Branch: 1 branch
BranchTrueFalseTotal
if $len < 0 1 27 28
61  
62 27 ▶ if ($this->get_length() < $len){
Branch: 1 branch
BranchTrueFalseTotal
if ($this->get_length < $len) 1 26 27
63 1 croak("Buffer contains less than '$len' bytes (length is " .
64 $this->get_length() ." bytes)") ;
65 }
66  
67 26 my $data = substr($this->{buf}, 0, $len) ;
68 26 substr($this->{buf}, 0, $len) = '' ;
69  
70 26 return $data ;
71 }
72  
73  
74  
75 4 1 ;
« Mux.pm ↑ Summary