Farly/IPv4/ICMPType.pm

filter: Statementstmt 100% 37 / 37 Branchbran 68.7% 11 / 16 Conditioncond 66.6% 6 / 9 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 100% 11 / 11 Podpod 85.7% 6 / 7 totaltotal 84.8% 73 / 86 CC 12 SCAR 12.4
CC
12
Cov
87%
new
7.3
contains
3.0
intersects
3.0
CRAP 3.5
« Farly/ASA/Annotator.pm ↑ Summary Farly/IPv4/Address.pm »
1 package Farly::IPv4::ICMPType;
2
3 17 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 17 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 17 our $VERSION = '0.26';
9
10 92 ▶sub new {
Subroutine new: called CC=6 SCAR=19.9
Pod documented
11 92 my ( $class, $type ) = @_;
12
13 92 ▶ confess "type number required" unless ( defined $type );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 92 92
14
15 92 $type =~ s/\s+//g;
16
17 92 ▶ confess "$type is not a number"
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /^\d+$/ or $type =~ /^-1$/ 0 92 92
Condition66%2/3
$type =~ /^\d+$/ or $type =~ /^-1$/
l!l&&r!l&&!r
23690
MC/DC0%0/2
$type =~ /^\d+$/ or $type =~ /^-1$/
$type =~ /^\d+$/ $type =~ /^-1$/
Truth table66%2/3
A or B
A= $type =~ /^\d+$/B= $type =~ /^-1$/
ABresult
1X1
011
000
18 unless ( $type =~ /^\d+$/ || $type =~ /^-1$/ );
19
20 92 ▶ confess "invalid type $type"
Branch: 1 branch
BranchTrueFalseTotal
unless $type >= -1 and $type <= 255 0 92 92
Condition33%1/3
$type >= -1 and $type <= 255
!ll&&!rl&&r
0092
MC/DC0%0/2
$type >= -1 and $type <= 255
$type >= -1 $type <= 255
Truth table33%1/3
A and B
A= $type >= -1B= $type <= 255
ABresult
0X0
100
111
21 unless ( ( $type >= -1 && $type <= 255 ) );
22
23 92 return bless( \$type, $class );
24 }
25
26 66 ▶sub type {
Subroutine type: called CC=1 SCAR=0.0
Pod documented
27 66 return ${ $_[0] };
28 }
29
30 21 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
31 21 return ${ $_[0] };
32 }
33
34 23 ▶sub equals {
Subroutine equals: called CC=2 SCAR=6.9
Pod documented
35 23 my ( $self, $other ) = @_;
36
37 23 ▶ if ( $other->isa('Farly::IPv4::ICMPType') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other->isa("Farly::IPv4::ICMPType")) 15 8 23
38
39 15 return $self->type() == $other->type();
40 }
41 }
42
43 16 ▶sub contains {
Subroutine contains: called CC=3 SCAR=11.0
Pod documented
44 16 my ( $self, $other ) = @_;
45
46 16 ▶ if ( $other->isa('Farly::IPv4::ICMPType') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other->isa("Farly::IPv4::ICMPType")) 16 0 16
47
48 16 ▶ if ( $self->type() == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->type == -1) 3 13 16
49 3 return 1;
50 }
51
52 13 return $self->equals($other);
53 }
54 }
55
56 3 ▶sub intersects {
Subroutine intersects: called CC=3 SCAR=11.0
Pod documented
57 3 my ( $self, $other ) = @_;
58
59 3 ▶ if ( $self->contains($other) || $other->contains($self) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->contains($other) or $other->contains($self)) 2 1 3
Condition100%3/3
$self->contains($other) or $other->contains($self)
l!l&&r!l&&!r
111
MC/DC100%2/2
$self->contains($other) or $other->contains($self)
$self->contains($other) $other->contains($self)
Truth table100%3/3
A or B
A= $self->contains($other)B= $other->contains($self)
ABresult
1X1
011
000
60 2 return 1;
61 }
62 }
63
64 10 ▶sub compare {
Subroutine compare: called CC=2 SCAR=7.1
Pod undocumented
65 10 my ( $self, $other ) = @_;
66
67 10 ▶ if ( $other->isa('Farly::IPv4::ICMPType') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other->isa("Farly::IPv4::ICMPType")) 10 0 10
68 10 return $self->type() <=> $other->type();
69 }
70 }
71
72 17 1;
73 __END__
« Farly/ASA/Annotator.pm ↑ Summary Farly/IPv4/Address.pm »