| 1 | package Linux::Event::Framer::Delimiter; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 45 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 45 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 45 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 45 | our $VERSION = '0.120'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 45 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 45 | ▶ | use bytes (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 83 | ▶ | sub _build_definition ($class, $delimiter = undef, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_definition: called CC=11 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 83 | ▶ | croak 'Delimiter requires a delimiter byte string' if !defined $delimiter; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 83 | ▶ | croak 'Delimiter must not be empty' if $delimiter eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 83 | ▶ | croak 'Delimiter options must be key/value pairs' if @args % 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 83 | my %opt = @args; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 83 | ▶ | my $include_delimiter = delete $opt{include_delimiter} // 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $opt{"include_delimiter"} // 0
MC/DC100%1/1
delete $opt{"include_delimiter"} // 0
delete $opt{"include_delimiter"}
Truth table100%2/2
A
A= delete $opt{"include_delimiter"}
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 83 | my $max_frame = delete $opt{max_frame}; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 83 | ▶ | croak 'max_frame must be a non-negative integer' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $max_frame and !($max_frame =~ /\A\d+\z/u) || $max_frame < 0
not $max_frame =~ /\A\d+\z/u or $max_frame < 0
MC/DC0%0/3
defined $max_frame and !($max_frame =~ /\A\d+\z/u) || $max_frame < 0
defined $max_frame
not $max_frame =~ /\A\d+\z/u
$max_frame < 0
Truth table50%2/4
A and not(B) or C
A= defined $max_frameB= not $max_frame =~ /\A\d+\z/uC= $max_frame < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | if defined($max_frame) && ($max_frame !~ /\A\d+\z/ || $max_frame < 0); | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 83 | ▶ | croak 'unknown Delimiter options: ' . join(', ', sort keys %opt) if %opt; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 83 | ▶ | my $native = { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | read_mode => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 24 | delimiter => $delimiter, | ||||||||||||||||||||||||||||||||||||||||||
| 25 | include_delimiter => $include_delimiter ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | max_frame => $max_frame, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 83 | return { native => $native, frame => \&_frame }; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 16326 | ▶ | sub _frame ($config, $payload) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_frame: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 16326 | ▶ | $payload = '' if !defined $payload; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 16326 | my $length = bytes::length($payload); | |||||||||||||||||||||||||||||||||||||||||
| 34 | croak "send(): payload length $length exceeds max_frame=$config->{max_frame}" | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 16326 | ▶ | if defined($config->{max_frame}) && $length > $config->{max_frame}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $config->{"max_frame"} and $length > $config->{"max_frame"}
MC/DC50%1/2
defined $config->{"max_frame"} and $length > $config->{"max_frame"}
defined $config->{"max_frame"}
$length > $config->{"max_frame"}
Truth table66%2/3
A and B
A= defined $config->{"max_frame"}B= $length > $config->{"max_frame"}
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 16325 | return $payload . $config->{delimiter}; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 45 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | __END__ | ||||||||||||||||||||||||||||||||||||||||||