| 1 | package Linux::Event::Framer::DecimalLength; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 9 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | our $VERSION = '0.119'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use bytes (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 11 | ▶ | sub _build_definition ($class, @args) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_definition: called CC=11 SCAR=24.6
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 11 | ▶ | croak 'DecimalLength options must be key/value pairs' if @args % 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 11 | my %opt = @args; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 11 | ▶ | my $separator = delete $opt{separator} // ' '; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $opt{"separator"} // " "
MC/DC100%1/1
delete $opt{"separator"} // " "
delete $opt{"separator"}
Truth table100%2/2
A
A= delete $opt{"separator"}
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 11 | ▶ | croak 'separator must be exactly one byte' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | if bytes::length($separator) != 1; | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 10 | ▶ | croak 'separator must not be an ASCII digit' if $separator =~ /[0-9]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 9 | ▶ | my $include_prefix = delete $opt{include_prefix} // 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $opt{"include_prefix"} // 0
MC/DC100%1/1
delete $opt{"include_prefix"} // 0
delete $opt{"include_prefix"}
Truth table100%2/2
A
A= delete $opt{"include_prefix"}
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 9 | my $max_frame = delete $opt{max_frame}; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 9 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | if defined($max_frame) && ($max_frame !~ /\A\d+\z/ || $max_frame < 0); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 9 | ▶ | croak 'unknown DecimalLength options: ' . join(', ', sort keys %opt) if %opt; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 9 | ▶ | my $native = { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | read_mode => 7, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | delimiter => $separator, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | include_prefix => $include_prefix ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | max_frame => $max_frame, | ||||||||||||||||||||||||||||||||||||||||||
| 29 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 9 | return { native => $native, frame => \&_frame }; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | ▶ | sub _frame ($config, $payload) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_frame: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | ▶ | $payload = '' if !defined $payload; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | my $length = bytes::length($payload); | |||||||||||||||||||||||||||||||||||||||||
| 36 | croak "send(): payload length $length exceeds max_frame=$config->{max_frame}" | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | return $length . $config->{delimiter} . $payload; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||||||||||||||||||||||||