SDK/Storage/Tables/EntityProperty.pm

filter: Statementstmt 97.5% 78 / 80 Branchbran 70.2% 52 / 74 Conditioncond 40.0% 24 / 60 MC/DCmcdc 13.3% 4 / 30 Subroutinesub 100% 21 / 21 Podpod 0.0% 0 / 10 totaltotal 65.0% 179 / 275 CC 58 SCAR 41.3
CC
58
Cov
72%
__ANON__
115.9
odata_literal
13.1
_valid_int64
9.6
CRAP 62.4
« SDK/AppConfiguration/ConfigurationSnapshot.pm ↑ Summary SDK/AppConfiguration/ConnectionString.pm »
1 6 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 6 ▶use feature 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶no warnings 'experimental::class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 6 class Azure::SDK::Storage::Tables::EntityProperty {
6 6 ▶ use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶ use bytes ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶ use JSON::PP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶ use MIME::Base64 qw(encode_base64);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶ use Scalar::Util qw(looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
11
12 6 ▶ use constant MAX_VALUE_BYTES => 64 * 1024;
Subroutine BEGIN: called CC=1 SCAR=0.0
13
14 6 field $type :param :reader;
15 6 field $value :param :reader;
16
17 336 ▶ ADJUST {
Subroutine __ANON__: called CC=40 SCAR=47.5
18 336 ▶ croak 'Table entity property type is required'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type and not ref $type and length $type 0 336 336
Condition33%2/6
defined $type and not ref $type and length $type
!ll&&!rl&&r
00336
defined $type and not ref $type
!ll&&!rl&&r
00336
MC/DC0%0/3
defined $type and not ref $type and length $type
defined $type not ref $type length $type
Truth table25%1/4
A and not(B) and C
A= defined $typeB= not ref $typeC= length $type
ABCresult
0XX0
10X0
1100
1111
19 unless defined $type && !ref $type && length $type;
20 336 ▶ croak "Unsupported Table entity property type '$type'"
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /\AEdm\.(?:Binary|Boolean|DateTime|Double|Guid|Int32|Int64|String)\z/u 0 336 336
21 unless $type =~ /\AEdm\.(?:Binary|Boolean|DateTime|Double|Guid|Int32|Int64|String)\z/;
22
23 336 ▶ if ($type eq 'Edm.Binary') {
Branch: 7 branches
BranchTrueFalseTotal
if ($type eq 'Edm.Binary') { } 6 330 336
elsif ($type eq 'Edm.Boolean') { } 5 325 330
elsif ($type eq 'Edm.Int32') { } 21 304 325
elsif ($type eq 'Edm.Int64') { } 6 298 304
elsif ($type eq 'Edm.Double') { } 3 295 298
elsif ($type eq 'Edm.Guid') { } 5 290 295
elsif ($type eq 'Edm.DateTime') { } 4 286 290
24 6 ▶ croak 'Edm.Binary value must be a byte string'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value and not utf8::is_utf8($value) 0 6 6
Condition33%2/6
defined $value and not ref $value and not utf8::is_utf8($value)
!ll&&!rl&&r
006
defined $value and not ref $value
!ll&&!rl&&r
006
MC/DC0%0/3
defined $value and not ref $value and not utf8::is_utf8($value)
defined $value not ref $value not utf8::is_utf8($value)
Truth table25%1/4
A and not(B) and not(C)
A= defined $valueB= not ref $valueC= not utf8::is_utf8($value)
ABCresult
0XX0
10X0
1100
1111
25 unless defined $value && !ref $value && !utf8::is_utf8($value);
26 6 ▶ croak 'Edm.Binary value exceeds 64 KiB'
Branch: 1 branch
BranchTrueFalseTotal
if &bytes::length($value) > 65536 1 5 6
27 if bytes::length($value) > MAX_VALUE_BYTES;
28 }
29 elsif ($type eq 'Edm.Boolean') {
30 5 ▶ croak 'Edm.Boolean value must be 0 or 1'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value and "$value" =~ /\A(?:0|1)\z/u 0 5 5
Condition33%2/6
defined $value and not ref $value and "$value" =~ /\A(?:0|1)\z/u
!ll&&!rl&&r
005
defined $value and not ref $value
!ll&&!rl&&r
005
MC/DC0%0/3
defined $value and not ref $value and "$value" =~ /\A(?:0|1)\z/u
defined $value not ref $value "$value" =~ /\A(?:0|1)\z/u
Truth table25%1/4
A and not(B) and C
A= defined $valueB= not ref $valueC= "$value" =~ /\A(?:0|1)\z/u
ABCresult
0XX0
10X0
1100
1111
31 unless defined $value && !ref $value && "$value" =~ /\A(?:0|1)\z/;
32 5 ▶ $value = $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 5 0 5
33 }
34 elsif ($type eq 'Edm.Int32') {
35 21 ▶ croak 'Edm.Int32 value must be an integer from -2147483648 to 2147483647'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value and "$value" =~ /\A-?[0-9]+\z/u and $value >= '-2147483648' and $value <= 2147483647 1 20 21
Condition41%5/12
defined $value and not ref $value and "$value" =~ /\A-?[0-9]+\z/u and $value >= '-2147483648' and $value <= 2147483647
!ll&&!rl&&r
0120
defined $value and not ref $value and "$value" =~ /\A-?[0-9]+\z/u and $value >= '-2147483648'
!ll&&!rl&&r
0021
defined $value and not ref $value and "$value" =~ /\A-?[0-9]+\z/u
!ll&&!rl&&r
0021
defined $value and not ref $value
!ll&&!rl&&r
0021
MC/DC20%1/5
defined $value and not ref $value and "$value" =~ /\A-?[0-9]+\z/u and $value >= '-2147483648' and $value <= 2147483647
defined $value not ref $value "$value" =~ /\A-?[0-9]+\z/u $value >= '-2147483648' $value <= 2147483647
Truth table33%2/6
A and not(B) and C and D and E
A= defined $valueB= not ref $valueC= "$value" =~ /\A-?[0-9]+\z/uD= $value >= '-2147483648'E= $value <= 2147483647
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
36 unless defined $value
37 && !ref $value
38 && "$value" =~ /\A-?[0-9]+\z/
39 && $value >= -2147483648
40 && $value <= 2147483647;
41 20 $value = 0 + $value;
42 }
43 elsif ($type eq 'Edm.Int64') {
44 6 ▶ croak 'Edm.Int64 value must be an integer from -9223372036854775808 to 9223372036854775807'
Branch: 1 branch
BranchTrueFalseTotal
unless _valid_int64($value) 1 5 6
45 unless _valid_int64($value);
46 5 $value = "$value";
47 }
48 elsif ($type eq 'Edm.Double') {
49 3 ▶ croak 'Edm.Double value must be a finite number'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value and &looks_like_number($value) and not "$value" =~ /(?:nan|inf)/iu 0 3 3
Condition33%3/9
defined $value and not ref $value and &looks_like_number($value) and not "$value" =~ /(?:nan|inf)/iu
!ll&&!rl&&r
003
defined $value and not ref $value and &looks_like_number($value)
!ll&&!rl&&r
003
defined $value and not ref $value
!ll&&!rl&&r
003
MC/DC0%0/4
defined $value and not ref $value and &looks_like_number($value) and not "$value" =~ /(?:nan|inf)/iu
defined $value not ref $value &looks_like_number($value) not "$value" =~ /(?:nan|inf)/iu
Truth table20%1/5
A and not(B) and C and not(D)
A= defined $valueB= not ref $valueC= &looks_like_number($value)D= not "$value" =~ /(?:nan|inf)/iu
ABCDresult
0XXX0
10XX0
110X0
11100
11111
50 unless defined $value
51 && !ref $value
52 && looks_like_number($value)
53 && "$value" !~ /(?:nan|inf)/i;
54 3 $value = 0 + $value;
55 }
56 elsif ($type eq 'Edm.Guid') {
57 5 ▶ croak 'Edm.Guid value must use canonical 8-4-4-4-12 hexadecimal form'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value and $value =~ /\A[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}\z/u 1 4 5
Condition50%3/6
defined $value and not ref $value and $value =~ /\A[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}\z/u
!ll&&!rl&&r
014
defined $value and not ref $value
!ll&&!rl&&r
005
MC/DC33%1/3
defined $value and not ref $value and $value =~ /\A[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}\z/u
defined $value not ref $value $value =~ /\A[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}\z/u
Truth table50%2/4
A and not(B) and C
A= defined $valueB= not ref $valueC= $value =~ /\A[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}\z/u
ABCresult
0XX0
10X0
1100
1111
58 unless defined $value
59 && !ref $value
60 && $value =~ /\A[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}\z/;
61 }
62 elsif ($type eq 'Edm.DateTime') {
63 4 ▶ croak 'Edm.DateTime value must be an ISO 8601 UTC timestamp'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value and $value =~ /\A[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,7})?Z\z/u 1 3 4
Condition50%3/6
defined $value and not ref $value and $value =~ /\A[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,7})?Z\z/u
!ll&&!rl&&r
013
defined $value and not ref $value
!ll&&!rl&&r
004
MC/DC33%1/3
defined $value and not ref $value and $value =~ /\A[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,7})?Z\z/u
defined $value not ref $value $value =~ /\A[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,7})?Z\z/u
Truth table50%2/4
A and not(B) and C
A= defined $valueB= not ref $valueC= $value =~ /\A[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,7})?Z\z/u
ABCresult
0XX0
10X0
1100
1111
64 unless defined $value
65 && !ref $value
66 && $value =~ /\A[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]{1,7})?Z\z/;
67 }
68 else {
69 286 ▶ croak 'Edm.String value must be a scalar'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value 0 286 286
Condition33%1/3
defined $value and not ref $value
!ll&&!rl&&r
00286
MC/DC0%0/2
defined $value and not ref $value
defined $value not ref $value
Truth table33%1/3
A and not(B)
A= defined $valueB= not ref $value
ABresult
0X0
100
111
70 unless defined $value && !ref $value;
71 286 my $bytes = "$value";
72 286 ▶ utf8::encode($bytes) if utf8::is_utf8($bytes);
Branch: 1 branch
BranchTrueFalseTotal
if utf8::is_utf8($bytes) 0 286 286
73 286 ▶ croak 'Edm.String UTF-8 representation exceeds 64 KiB'
Branch: 1 branch
BranchTrueFalseTotal
if &bytes::length($bytes) > 65536 0 286 286
74 if bytes::length($bytes) > MAX_VALUE_BYTES;
75 286 $value = "$value";
76 }
77 }
78
79 2 ▶ sub binary ($class, $value) { return $class->new(type => 'Edm.Binary', value => $value); }
Subroutine binary: called CC=1 SCAR=0.0
Pod undocumented
80 1 ▶ sub boolean ($class, $value) { return $class->new(type => 'Edm.Boolean', value => $value); }
Subroutine boolean: called CC=1 SCAR=0.0
Pod undocumented
81 2 ▶ sub datetime ($class, $value) { return $class->new(type => 'Edm.DateTime', value => $value); }
Subroutine datetime: called CC=1 SCAR=0.0
Pod undocumented
82 1 ▶ sub double ($class, $value) { return $class->new(type => 'Edm.Double', value => $value); }
Subroutine double: called CC=1 SCAR=0.0
Pod undocumented
83 3 ▶ sub guid ($class, $value) { return $class->new(type => 'Edm.Guid', value => $value); }
Subroutine guid: called CC=1 SCAR=0.0
Pod undocumented
84 7 ▶ sub int32 ($class, $value) { return $class->new(type => 'Edm.Int32', value => $value); }
Subroutine int32: called CC=1 SCAR=0.0
Pod undocumented
85 2 ▶ sub int64 ($class, $value) { return $class->new(type => 'Edm.Int64', value => $value); }
Subroutine int64: called CC=1 SCAR=0.0
Pod undocumented
86 2 ▶ sub string ($class, $value) { return $class->new(type => 'Edm.String', value => $value); }
Subroutine string: called CC=1 SCAR=0.0
Pod undocumented
87
88 93 ▶ method json_value () {
Subroutine json_value: called CC=4 SCAR=13.9
Pod undocumented
89 93 ▶ return encode_base64($value, '') if $type eq 'Edm.Binary';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Edm.Binary" 1 92 93
90 92 ▶ return $value ? JSON::PP::true : JSON::PP::false
Branch: 2 branches
BranchTrueFalseTotal
if $type eq "Edm.Boolean" 1 91 92
$value ? : 1 0 1
91 if $type eq 'Edm.Boolean';
92 91 return $value;
93 }
94
95 4 ▶ method odata_literal () {
Subroutine odata_literal: called CC=9 SCAR=25.7
Pod undocumented
96 4 ▶ if ($type eq 'Edm.String') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "Edm.String") 2 2 4
97 2 my $escaped = $value;
98 2 $escaped =~ s/'/''/g;
99 2 return "'$escaped'";
100 }
101 2 ▶ return $value ? 'true' : 'false' if $type eq 'Edm.Boolean';
Branch: 2 branches
BranchTrueFalseTotal
if $type eq "Edm.Boolean" 0 2 2
$value ? : 0 0 0
102 2 ▶ return "$value" if $type eq 'Edm.Int32' || $type eq 'Edm.Double';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Edm.Int32" or $type eq "Edm.Double" 1 1 2
Condition66%2/3
$type eq "Edm.Int32" or $type eq "Edm.Double"
l!l&&r!l&&!r
101
MC/DC50%1/2
$type eq "Edm.Int32" or $type eq "Edm.Double"
$type eq "Edm.Int32" $type eq "Edm.Double"
Truth table66%2/3
A or B
A= $type eq "Edm.Int32"B= $type eq "Edm.Double"
ABresult
1X1
011
000
103 1 ▶ return $value . 'L' if $type eq 'Edm.Int64';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Edm.Int64" 0 1 1
104 1 ▶ return "guid'$value'" if $type eq 'Edm.Guid';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Edm.Guid" 1 0 1
105 0 ▶ return "datetime'$value'" if $type eq 'Edm.DateTime';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Edm.DateTime" 0 0 0
106 0 croak 'Edm.Binary values are not supported in Table filters';
107 }
108
109 6 ▶ sub _valid_int64 ($candidate) {
Subroutine _valid_int64: called CC=8 SCAR=22.6
110 6 ▶ return 0 unless defined $candidate && !ref $candidate;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $candidate and not ref $candidate 0 6 6
Condition33%1/3
defined $candidate and not ref $candidate
!ll&&!rl&&r
006
MC/DC0%0/2
defined $candidate and not ref $candidate
defined $candidate not ref $candidate
Truth table33%1/3
A and not(B)
A= defined $candidateB= not ref $candidate
ABresult
0X0
100
111
111 6 my $text = "$candidate";
112 6 ▶ return 0 unless $text =~ /\A(-?)([0-9]+)\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $text =~ /\A(-?)([0-9]+)\z/u 0 6 6
113 6 my ($negative, $digits) = ($1, $2);
114 6 $digits =~ s/\A0+(?=[0-9])//;
115 6 ▶ my $limit = $negative ? '9223372036854775808' : '9223372036854775807';
Branch: 1 branch
BranchTrueFalseTotal
$negative ? : 0 6 6
116 6 ▶ return 1 if length($digits) < length($limit);
Branch: 1 branch
BranchTrueFalseTotal
if length $digits < length $limit 0 6 6
117 6 ▶ return 0 if length($digits) > length($limit);
Branch: 1 branch
BranchTrueFalseTotal
if length $digits > length $limit 0 6 6
118 6 ▶ return $digits le $limit ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$digits le $limit ? : 5 1 6
119 }
120 }
121
122 6 1;
123
124 __END__
« SDK/AppConfiguration/ConfigurationSnapshot.pm ↑ Summary SDK/AppConfiguration/ConnectionString.pm »