« blib/lib/Valiemon/Attributes/Dependencies.pm
↑ Summary
blib/lib/Valiemon/Attributes/Properties.pm »
| 1 | package Valiemon::Primitives; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 25 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 25 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 25 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 25 | ▶ | use Scalar::Util qw(looks_like_number); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 25 | ▶ | use Types::Serialiser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 25 | ▶ | use Test::Deep qw(eq_deeply); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 217 | ▶ | my ($class, $options) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 217 | ▶ | return bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options || {}
MC/DC100%1/1
$options || {}
$options
Truth table100%2/2
A
A= $options
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | options => $options || +{}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | sub is_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 93 | ▶ | my ($self, $obj) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_object: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 93 | ▶ | (defined $obj && ref $obj eq 'HASH') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $obj and ref $obj eq "HASH"
MC/DC100%2/2
defined $obj and ref $obj eq "HASH"
defined $obj
ref $obj eq "HASH"
Truth table100%3/3
A and B
A= defined $objB= ref $obj eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | sub is_array { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 53 | ▶ | my ($self, $obj) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_array: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 53 | ▶ | (defined $obj && ref $obj eq 'ARRAY') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $obj and ref $obj eq "ARRAY"
MC/DC100%2/2
defined $obj and ref $obj eq "ARRAY"
defined $obj
ref $obj eq "ARRAY"
Truth table100%3/3
A and B
A= defined $objB= ref $obj eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | sub is_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 524 | ▶ | my ($self, $obj) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_string: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 524 | ▶ | (defined $obj && ref $obj eq '') ? 1 : 0; # really? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $obj and ref $obj eq ""
MC/DC100%2/2
defined $obj and ref $obj eq ""
defined $obj
ref $obj eq ""
Truth table100%3/3
A and B
A= defined $objB= ref $obj eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | sub is_number { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 535 | ▶ | my ($self, $obj) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_number: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # avoid from JSON::Boolean treated as number. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 535 | ▶ | (defined $obj && ref $obj eq '' && looks_like_number($obj)) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $obj and ref $obj eq "" and &looks_like_number($obj)
defined $obj and ref $obj eq ""
MC/DC100%3/3
defined $obj and ref $obj eq "" and &looks_like_number($obj)
defined $obj
ref $obj eq ""
&looks_like_number($obj)
Truth table100%4/4
A and B and C
A= defined $objB= ref $obj eq ""C= &looks_like_number($obj)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | sub is_integer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 260 | ▶ | my ($self, $obj) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_integer: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 260 | ▶ | $self->is_number($obj) && $obj =~ qr/^-?\d+$/ ? 1 : 0; # TODO find more better way | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->is_number($obj) and $obj =~ qr/^-?\d+$/
MC/DC100%2/2
$self->is_number($obj) and $obj =~ qr/^-?\d+$/
$self->is_number($obj)
$obj =~ qr/^-?\d+$/
Truth table100%3/3
A and B
A= $self->is_number($obj)B= $obj =~ qr/^-?\d+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | sub is_boolean { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 270 | ▶ | my ($self, $obj) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_boolean: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | return $self->{options}->{use_json_boolean} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 270 | ▶ | ? $self->is_boolean_json($obj) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | : $self->is_boolean_perl($obj) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | sub is_boolean_perl { # 1 or 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 140 | ▶ | my ($self, $obj) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_boolean_perl: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 140 | ▶ | (defined $obj && looks_like_number($obj) && ($obj == 1 || $obj == 0)) ? 1 : 0; # TODO invalidate 0.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
defined $obj and &looks_like_number($obj) and $obj == 1 || $obj == 0
defined $obj and &looks_like_number($obj)
$obj == 1 or $obj == 0
MC/DC100%4/4
defined $obj and &looks_like_number($obj) and $obj == 1 || $obj == 0
defined $obj
&looks_like_number($obj)
$obj == 1
$obj == 0
Truth table100%5/5
A and B and C or D
A= defined $objB= &looks_like_number($obj)C= $obj == 1D= $obj == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | sub is_boolean_json { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 162 | ▶ | my ($self, $obj) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_boolean_json: called CC=7 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 162 | ▶ | return 1 if defined $obj && Types::Serialiser::is_bool($obj); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $obj and &Types::Serialiser::is_bool($obj)
MC/DC100%2/2
defined $obj and &Types::Serialiser::is_bool($obj)
defined $obj
&Types::Serialiser::is_bool($obj)
Truth table100%3/3
A and B
A= defined $objB= &Types::Serialiser::is_bool($obj)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 140 | ▶ | return 1 if ref $obj eq 'SCALAR' && looks_like_number($$obj) && ($$obj == 1 || $$obj == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
ref $obj eq "SCALAR" and &looks_like_number($$obj) and $$obj == 1 || $$obj == 0
ref $obj eq "SCALAR" and &looks_like_number($$obj)
$$obj == 1 or $$obj == 0
MC/DC25%1/4
ref $obj eq "SCALAR" and &looks_like_number($$obj) and $$obj == 1 || $$obj == 0
ref $obj eq "SCALAR"
&looks_like_number($$obj)
$$obj == 1
$$obj == 0
Truth table40%2/5
A and B and C or D
A= ref $obj eq "SCALAR"B= &looks_like_number($$obj)C= $$obj == 1D= $$obj == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 136 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | sub is_null { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 23 | ▶ | my ($self, $obj) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_null: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 23 | ▶ | !defined($obj) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # json schema core: 3.6 JSON value equality | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | sub is_equal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 213 | ▶ | my ($self, $a, $b) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_equal: called CC=13 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 213 | ▶ | return 1 if !defined($a) && !defined($b); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $a or defined $b
MC/DC100%2/2
defined $a or defined $b
defined $a
defined $b
Truth table100%3/3
A or B
A= defined $aB= defined $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 212 | ▶ | return 1 if $self->is_boolean($a) && $self->is_boolean($b) && $a == $b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$self->is_boolean($a) and $self->is_boolean($b) and $a == $b
$self->is_boolean($a) and $self->is_boolean($b)
MC/DC100%3/3
$self->is_boolean($a) and $self->is_boolean($b) and $a == $b
$self->is_boolean($a)
$self->is_boolean($b)
$a == $b
Truth table100%4/4
A and B and C
A= $self->is_boolean($a)B= $self->is_boolean($b)C= $a == $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 206 | ▶ | return 1 if $self->is_string($a) && $self->is_string($b) && "$a" eq "$b"; # ah | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$self->is_string($a) and $self->is_string($b) and "$a" eq "$b"
$self->is_string($a) and $self->is_string($b)
MC/DC100%3/3
$self->is_string($a) and $self->is_string($b) and "$a" eq "$b"
$self->is_string($a)
$self->is_string($b)
"$a" eq "$b"
Truth table100%4/4
A and B and C
A= $self->is_string($a)B= $self->is_string($b)C= "$a" eq "$b"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 182 | ▶ | return 1 if $self->is_number($a) && $self->is_number($b) && $a == $b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->is_number($a) and $self->is_number($b) and $a == $b
$self->is_number($a) and $self->is_number($b)
MC/DC0%0/3
$self->is_number($a) and $self->is_number($b) and $a == $b
$self->is_number($a)
$self->is_number($b)
$a == $b
Truth table75%3/4
A and B and C
A= $self->is_number($a)B= $self->is_number($b)C= $a == $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 182 | ▶ | return 1 if eq_deeply($a, $b); # array & object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 166 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 25 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||