blib/lib/Linux/Event/WebSocket/_State.pm

filter: Statementstmt 100% 25 / 25 Branchbran 56.2% 9 / 16 Conditioncond 44.0% 11 / 25 MC/DCmcdc 8.3% 1 / 12 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 60.7% 51 / 84 CC 18 SCAR 34.2
CC
18
Cov
68%
new
37.1
BEGIN
1.0
BEGIN
1.0
CRAP 30.5
↑ Summary blib/lib/Linux/Event/WebSocket/_Handshake.pm »
1 package Linux::Event::WebSocket::_State;
2 7 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 7 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 15 ▶sub new ($class, %option) {
Subroutine new: called CC=18 SCAR=36.1
Pod undocumented
9 15 my $endpoint_type = delete $option{endpoint_type};
10 15 ▶ croak 'new(): endpoint_type must be client or server'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $endpoint_type or $endpoint_type ne "client" and $endpoint_type ne "server" 0 15 15
Condition50%3/6
not defined $endpoint_type or $endpoint_type ne "client" and $endpoint_type ne "server"
l!l&&r!l&&!r
0015
$endpoint_type ne "client" and $endpoint_type ne "server"
!ll&&!rl&&r
780
MC/DC0%0/3
not defined $endpoint_type or $endpoint_type ne "client" and $endpoint_type ne "server"
not defined $endpoint_type $endpoint_type ne "client" $endpoint_type ne "server"
Truth table50%2/4
not(A) or B and C
A= not defined $endpoint_typeB= $endpoint_type ne "client"C= $endpoint_type ne "server"
ABCresult
1XX1
0111
00X0
0100
11 if !defined($endpoint_type)
12 || ($endpoint_type ne 'client' && $endpoint_type ne 'server');
13  
14 15 ▶ my $callbacks = delete($option{callbacks}) // {};
Condition50%1/2
delete $option{"callbacks"} // {}
l!l
150
MC/DC0%0/1
delete $option{"callbacks"} // {}
delete $option{"callbacks"}
Truth table50%1/2
A
A= delete $option{"callbacks"}
Aresult
11
00
15 15 ▶ croak 'new(): callbacks must be a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
if ref $callbacks ne "HASH" 0 15 15
16 if ref($callbacks) ne 'HASH';
17  
18 15 ▶ my $subprotocols = delete($option{subprotocols}) // [];
Condition100%2/2
delete $option{"subprotocols"} // []
l!l
141
MC/DC100%1/1
delete $option{"subprotocols"} // []
delete $option{"subprotocols"}
Truth table100%2/2
A
A= delete $option{"subprotocols"}
Aresult
11
00
19 15 ▶ croak 'new(): subprotocols must be an array reference'
Branch: 1 branch
BranchTrueFalseTotal
if ref $subprotocols ne "ARRAY" 0 15 15
20 if ref($subprotocols) ne 'ARRAY';
21  
22 my $close_timeout = exists($option{close_timeout})
23 15 ▶ ? delete($option{close_timeout}) : 5;
Branch: 1 branch
BranchTrueFalseTotal
exists $option{'close_timeout'} ? : 15 0 15
24 15 ▶ croak 'new(): close_timeout must be a non-negative number'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $close_timeout or ref $close_timeout or not $close_timeout =~ /\A(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)\z/u 0 15 15
Condition33%2/6
not defined $close_timeout or ref $close_timeout or not $close_timeout =~ /\A(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)\z/u
l!l&&r!l&&!r
0015
not defined $close_timeout or ref $close_timeout
l!l&&r!l&&!r
0015
MC/DC0%0/3
not defined $close_timeout or ref $close_timeout or not $close_timeout =~ /\A(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)\z/u
not defined $close_timeout ref $close_timeout not $close_timeout =~ /\A(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)\z/u
Truth table25%1/4
not(A) or B or not(C)
A= not defined $close_timeoutB= ref $close_timeoutC= not $close_timeout =~ /\A(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)\z/u
ABCresult
1XX1
01X1
0011
0000
25 if !defined($close_timeout) || ref($close_timeout)
26 || $close_timeout !~ /\A(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)\z/;
27  
28 15 my $max_message_size = delete $option{max_message_size};
29 15 ▶ croak 'new(): max_message_size must be a positive integer'
Branch: 1 branch
BranchTrueFalseTotal
if defined $max_message_size and ref $max_message_size || !("$max_message_size" =~ /\A[0-9]+\z/u) || $max_message_size < 1 0 15 15
Condition33%3/9
defined $max_message_size and ref $max_message_size || !("$max_message_size" =~ /\A[0-9]+\z/u) || $max_message_size < 1
!ll&&!rl&&r
0150
ref $max_message_size or not "$max_message_size" =~ /\A[0-9]+\z/u or $max_message_size < 1
l!l&&r!l&&!r
0015
ref $max_message_size or not "$max_message_size" =~ /\A[0-9]+\z/u
l!l&&r!l&&!r
0015
MC/DC0%0/4
defined $max_message_size and ref $max_message_size || !("$max_message_size" =~ /\A[0-9]+\z/u) || $max_message_size < 1
defined $max_message_size ref $max_message_size not "$max_message_size" =~ /\A[0-9]+\z/u $max_message_size < 1
Truth table20%1/5
A and B or not(C) or D
A= defined $max_message_sizeB= ref $max_message_sizeC= not "$max_message_size" =~ /\A[0-9]+\z/uD= $max_message_size < 1
ABCDresult
0XXX0
10000
11XX1
101X1
10011
30 if defined($max_message_size)
31 && (ref($max_message_size)
32 || "$max_message_size" !~ /\A[0-9]+\z/
33 || $max_message_size < 1);
34  
35 my $self = bless {
36 endpoint_type => $endpoint_type,
37 callbacks => { %$callbacks },
38 subprotocols => [ @$subprotocols ],
39 data => delete $option{data},
40 handshake => delete $option{handshake},
41 request => delete $option{request},
42 response => delete $option{response},
43 secure => delete($option{secure}) ? 1 : 0,
44 url => delete $option{url},
45 15 ▶ close_timeout => 0 + $close_timeout,
Branch: 1 branch
BranchTrueFalseTotal
delete $option{'secure'} ? : 2 13 15
46 max_message_size => $max_message_size,
47 engine => undef,
48 open => 0,
49 closing => 0,
50 close_notified => 0,
51 close_timer => undef,
52 }, $class;
53  
54 15 ▶ croak 'new(): unknown option(s): ' . join(', ', sort keys %option)
Branch: 1 branch
BranchTrueFalseTotal
if %option 0 15 15
55 if %option;
56  
57 15 return $self;
58 }
59  
60 7 1;
↑ Summary blib/lib/Linux/Event/WebSocket/_Handshake.pm »