| 1 | package Net::Amazon::DynamoDB::Marshaler; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use 5.008_005; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = '0.07'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use parent qw(Exporter); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | our @EXPORT = qw(dynamodb_marshal dynamodb_unmarshal); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use boolean qw(true false isBoolean); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Types::Standard qw(StrictNum); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 25 | ▶ | sub dynamodb_marshal { | ||||||||||||||||||||||||||
|
Subroutine
dynamodb_marshal: called CC=7 SCAR=21.5
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | 25 | my ($attrs, %args) = @_; | |||||||||||||||||||||||||||
| 16 | 25 | ▶ | my $force_type = $args{force_type} || {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$args{'force_type'} || {}
MC/DC100%1/1
$args{'force_type'} || {}
$args{'force_type'}
Truth table100%2/2
A
A= $args{'force_type'}
| |||||||||||||||||||||||||||||
| 17 | 25 | ▶ | die __PACKAGE__.'::dynamodb_marshal(): argument must be a hashref' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $attrs and ref $attrs eq "HASH"
MC/DC0%0/2
ref $attrs and ref $attrs eq "HASH"
ref $attrs
ref $attrs eq "HASH"
Truth table33%1/3
A and B
A= ref $attrsB= ref $attrs eq "HASH"
| |||||||||||||||||||||||||||||
| 18 | unless ( | ||||||||||||||||||||||||||||
| 19 | ref $attrs | ||||||||||||||||||||||||||||
| 20 | && ref $attrs eq 'HASH' | ||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||
| 22 | 25 | ▶ | die __PACKAGE__.'::dynamodb_marshal(): force_type must be a hashref' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $force_type and ref $force_type eq "HASH"
MC/DC0%0/2
ref $force_type and ref $force_type eq "HASH"
ref $force_type
ref $force_type eq "HASH"
Truth table33%1/3
A and B
A= ref $force_typeB= ref $force_type eq "HASH"
| |||||||||||||||||||||||||||||
| 23 | unless ( | ||||||||||||||||||||||||||||
| 24 | ref $force_type | ||||||||||||||||||||||||||||
| 25 | && ref $force_type eq 'HASH' | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | die __PACKAGE__.qq|::dynamodb_marshal(): invalid force_type value for "$_"| | ||||||||||||||||||||||||||||
| 29 | 25 | for grep { | |||||||||||||||||||||||||||
| 30 | 19 | $force_type->{$_} !~ /^[SN]$/; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | keys %$force_type; | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 24 | return _marshal_hashref($attrs, $force_type); | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 10 | ▶ | sub dynamodb_unmarshal { | ||||||||||||||||||||||||||
|
Subroutine
dynamodb_unmarshal: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 10 | my ($attrs) = @_; | |||||||||||||||||||||||||||
| 39 | 10 | ▶ | die __PACKAGE__.'::dynamodb_unmarshal(): argument must be a hashref' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $attrs and ref $attrs eq "HASH"
MC/DC0%0/2
ref $attrs and ref $attrs eq "HASH"
ref $attrs
ref $attrs eq "HASH"
Truth table33%1/3
A and B
A= ref $attrsB= ref $attrs eq "HASH"
| |||||||||||||||||||||||||||||
| 40 | unless ( | ||||||||||||||||||||||||||||
| 41 | ref $attrs | ||||||||||||||||||||||||||||
| 42 | && ref $attrs eq 'HASH' | ||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||
| 44 | 10 | return _unmarshal_hashref($attrs); | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 36 | ▶ | sub _marshal_hashref { | ||||||||||||||||||||||||||
|
Subroutine
_marshal_hashref: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 48 | 36 | my ($attrs, $force_types) = @_; | |||||||||||||||||||||||||||
| 49 | 36 | ▶ | $force_types ||= {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$force_types ||= {}
MC/DC0%0/1
$force_types ||= {}
$force_types
Truth table50%1/2
A
A= $force_types
| |||||||||||||||||||||||||||||
| 50 | 36 | my %marshalled; | |||||||||||||||||||||||||||
| 51 | 36 | for my $key (keys %$attrs) { | |||||||||||||||||||||||||||
| 52 | 111 | my $val = $attrs->{$key}; | |||||||||||||||||||||||||||
| 53 | 111 | my $force_type = $force_types->{$key}; | |||||||||||||||||||||||||||
| 54 | 111 | my $new_val = _marshal_val($val, $force_type); | |||||||||||||||||||||||||||
| 55 | 107 | ▶ | if ($new_val) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 100 | $marshalled{$key} = $new_val; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | 32 | return \%marshalled; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 15 | ▶ | sub _unmarshal_hashref { | ||||||||||||||||||||||||||
|
Subroutine
_unmarshal_hashref: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 63 | 15 | my ($attrs) = @_; | |||||||||||||||||||||||||||
| 64 | 15 | return { map { $_ => _unmarshal_attr_val($attrs->{$_}) } keys %$attrs }; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 144 | ▶ | sub _marshal_val { | ||||||||||||||||||||||||||
|
Subroutine
_marshal_val: called CC=19 SCAR=29.4
| |||||||||||||||||||||||||||||
| 68 | 144 | my ($val, $force_type) = @_; | |||||||||||||||||||||||||||
| 69 | 144 | ▶ | $force_type ||= ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$force_type ||= ""
MC/DC100%1/1
$force_type ||= ""
$force_type
Truth table100%2/2
A
A= $force_type
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | # Calculate the type according to our rules. | ||||||||||||||||||||||||||||
| 72 | 144 | my $type = _val_type($val); | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # Subref to build string value result | ||||||||||||||||||||||||||||
| 75 | 142 | ▶ | my $marshalled_string = sub {{ S => "$_[0]" }}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | # Subref to build number value result | ||||||||||||||||||||||||||||
| 78 | 142 | ▶ | my $marshalled_num = sub {{ N => $_[0] }}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | # Handle strings | ||||||||||||||||||||||||||||
| 81 | 142 | ▶ | if ($type eq 'S') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | # Strip these out if we're force-typing to number | ||||||||||||||||||||||||||||
| 83 | 39 | ▶ | if ($force_type eq 'N') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 3 | return undef; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | 36 | return $marshalled_string->($val); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | # Handle numbers | ||||||||||||||||||||||||||||
| 90 | 103 | ▶ | if ($type eq 'N') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | # Force-stringify if asked | ||||||||||||||||||||||||||||
| 92 | 42 | ▶ | if ($force_type eq 'S') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 9 | return $marshalled_string->($val); | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | 33 | return $marshalled_num->($val); | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | # Handle nulls | ||||||||||||||||||||||||||||
| 99 | 61 | ▶ | if ($type eq 'NULL') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | # Strip these out if we're force-typing | ||||||||||||||||||||||||||||
| 101 | 14 | ▶ | if ($force_type) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 7 | return undef; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | 7 | return { NULL => 1 }; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | # Handle booleans | ||||||||||||||||||||||||||||
| 108 | 47 | ▶ | if ($type eq 'BOOL') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | # Force-stringify if asked | ||||||||||||||||||||||||||||
| 110 | 12 | ▶ | if ($force_type eq 'S') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 2 | ▶ | return $marshalled_string->($val ? 1 : 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | # Force-numerify if asked | ||||||||||||||||||||||||||||
| 114 | 10 | ▶ | if ($force_type eq 'N') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 2 | ▶ | return $marshalled_num->($val ? 1 : 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | 8 | ▶ | return { BOOL => $val ? 1 : 0 }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | # Handle sets | ||||||||||||||||||||||||||||
| 121 | 35 | ▶ | if ($type =~ /^(NS|SS)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | # Blow up trying to force-type a set | ||||||||||||||||||||||||||||
| 123 | 11 | ▶ | die __PACKAGE__.'force_type not supported for sets yet' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | if $force_type; | ||||||||||||||||||||||||||||
| 125 | 9 | return { $type => [ $val->members ] }; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | # Handle lists | ||||||||||||||||||||||||||||
| 129 | 24 | ▶ | if ($type eq 'L') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 12 | my @items = map { _marshal_val($_, $force_type) } @$val; | |||||||||||||||||||||||||||
| 131 | # Strip out any values that failed force-typing | ||||||||||||||||||||||||||||
| 132 | 12 | @items = grep { defined } @items; | |||||||||||||||||||||||||||
| 133 | 12 | return { L => \@items }; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | # Handle maps | ||||||||||||||||||||||||||||
| 137 | 12 | ▶ | if ($type eq 'M') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 12 | my $force_types = {}; | |||||||||||||||||||||||||||
| 139 | 12 | ▶ | if ($force_type) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | # Recursively apply our force type to all values. | ||||||||||||||||||||||||||||
| 141 | 7 | $force_types = { map { $_ => $force_type } keys %$val }; | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | 12 | return { M => _marshal_hashref($val, $force_types) }; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | die "don't know how to marshal type of $type"; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 50 | ▶ | sub _unmarshal_attr_val { | ||||||||||||||||||||||||||
|
Subroutine
_unmarshal_attr_val: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||
| 150 | 50 | my ($attr_val) = @_; | |||||||||||||||||||||||||||
| 151 | 50 | my ($type, $val) = _get_canonical_attr_val($attr_val); | |||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 50 | ▶ | return undef if $type eq 'NULL'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | 48 | ▶ | return $val if $type =~ /^(S|N)$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | 21 | ▶ | return true if $type eq 'BOOL' && $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$type eq "BOOL" and $val
MC/DC100%2/2
$type eq "BOOL" and $val
$type eq "BOOL"
$val
Truth table100%3/3
A and B
A= $type eq "BOOL"B= $val
| |||||||||||||||||||||||||||||
| 156 | 18 | ▶ | return false if $type eq 'BOOL'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | 16 | ▶ | return Set::Object->new(@$val) if $type =~ /^(NS|SS)$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | 12 | ▶ | return [ map { _unmarshal_attr_val($_) } @$val ] if $type eq 'L'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 5 | ▶ | return _unmarshal_hashref($val) if $type eq 'M'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 0 | die "don't know how to unmarshal $type"; | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | # Sometimes Paws includes an empty L value in its AttributeValue object, see | ||||||||||||||||||||||||||||
| 165 | # https://github.com/pplu/aws-sdk-perl/issues/79 | ||||||||||||||||||||||||||||
| 166 | 50 | ▶ | sub _get_canonical_attr_val { | ||||||||||||||||||||||||||
|
Subroutine
_get_canonical_attr_val: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 167 | 50 | my ($attr_val) = @_; | |||||||||||||||||||||||||||
| 168 | 50 | my @types = keys %$attr_val; | |||||||||||||||||||||||||||
| 169 | 50 | my $canonical_type; | |||||||||||||||||||||||||||
| 170 | 50 | ▶ | if (@types == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | 47 | $canonical_type = $types[0]; | |||||||||||||||||||||||||||
| 172 | } else { | ||||||||||||||||||||||||||||
| 173 | 3 | ($canonical_type) = grep { $_ ne 'L' } @types; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 50 | return ($canonical_type, $attr_val->{$canonical_type}); | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 178 | ▶ | sub _val_type { | ||||||||||||||||||||||||||
|
Subroutine
_val_type: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||
| 180 | 178 | my ($val) = @_; | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 178 | ▶ | return 'NULL' if ! defined $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 168 | ▶ | return 'NULL' if $val eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | 164 | ▶ | return 'N' if _is_valid_number($val); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | 106 | ▶ | return 'S' if !ref $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 50 | ▶ | return 'BOOL' if isBoolean($val); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 38 | my $ref = ref $val; | |||||||||||||||||||||||||||
| 190 | 38 | ▶ | return 'L' if $ref eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | 26 | ▶ | return 'M' if $ref eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 13 | ▶ | if (blessed($val) and $val->isa('Set::Object')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($val) and $val->isa("Set::Object")
MC/DC50%1/2
builtin::blessed($val) and $val->isa("Set::Object")
builtin::blessed($val)
$val->isa("Set::Object")
Truth table66%2/3
A and B
A= builtin::blessed($val)B= $val->isa("Set::Object")
| |||||||||||||||||||||||||||||
| 194 | 12 | my @types = map { _val_type($_) } $val->members; | |||||||||||||||||||||||||||
| 195 | die "Sets can only contain strings and numbers, found $_" | ||||||||||||||||||||||||||||
| 196 | 12 | for grep { !/^(S|N)$/ } @types; | |||||||||||||||||||||||||||
| 197 | 11 | ▶ | if (grep { /^S$/ } @types) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 6 | return 'SS'; | |||||||||||||||||||||||||||
| 199 | } else { | ||||||||||||||||||||||||||||
| 200 | 5 | return 'NS'; | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 1 | die __PACKAGE__.": unable to marshal value: $val"; | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 164 | ▶ | sub _is_valid_number { | ||||||||||||||||||||||||||
|
Subroutine
_is_valid_number: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||
| 208 | 164 | my ($val) = @_; | |||||||||||||||||||||||||||
| 209 | 164 | ▶ | return 0 if ref $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | 114 | ▶ | return 0 unless StrictNum->check($val); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | # Some very high numbers are equal to 0, keep those as strings | ||||||||||||||||||||||||||||
| 213 | 65 | ▶ | return 1 if ("$val" eq '0'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 65 | ▶ | return 0 if ($val == 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 65 | ▶ | return 0 if ($val > 0 && $val <= 1e-130); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$val > 0 and $val <= "1e-130"
MC/DC100%2/2
$val > 0 and $val <= "1e-130"
$val > 0
$val <= "1e-130"
Truth table100%3/3
A and B
A= $val > 0B= $val <= "1e-130"
| |||||||||||||||||||||||||||||
| 217 | 64 | ▶ | return 0 if ($val < 0 && $val >= -1e-130); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$val < 0 and $val >= "-1e-130"
MC/DC100%2/2
$val < 0 and $val >= "-1e-130"
$val < 0
$val >= "-1e-130"
Truth table100%3/3
A and B
A= $val < 0B= $val >= "-1e-130"
| |||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 63 | ▶ | return 0 if ($val >= 1e126); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | 61 | ▶ | return 0 if ($val <= -1e126); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 60 | ▶ | return 0 if length($val) > 38; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 58 | return 1; | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 1 | 1; | |||||||||||||||||||||||||||
| 229 | __END__ | ||||||||||||||||||||||||||||