| 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
Condition50%3/6
not defined $endpoint_type or $endpoint_type ne "client" and $endpoint_type ne "server"
$endpoint_type ne "client" and $endpoint_type ne "server"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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"} // {}
MC/DC0%0/1
delete $option{"callbacks"} // {}
delete $option{"callbacks"}
Truth table50%1/2
A
A= delete $option{"callbacks"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 15 | ▶ | croak 'new(): callbacks must be a hash reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | if ref($callbacks) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 15 | ▶ | my $subprotocols = delete($option{subprotocols}) // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $option{"subprotocols"} // []
MC/DC100%1/1
delete $option{"subprotocols"} // []
delete $option{"subprotocols"}
Truth table100%2/2
A
A= delete $option{"subprotocols"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 15 | ▶ | croak 'new(): subprotocols must be an array reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 15 | ▶ | croak 'new(): close_timeout must be a non-negative number' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
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 or ref $close_timeout
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%3/9
defined $max_message_size and ref $max_message_size || !("$max_message_size" =~ /\A[0-9]+\z/u) || $max_message_size < 1
ref $max_message_size or not "$max_message_size" =~ /\A[0-9]+\z/u or $max_message_size < 1
ref $max_message_size or not "$max_message_size" =~ /\A[0-9]+\z/u
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | if %option; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 15 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||