| 1 | # Copyrights 2023 by [Mark Overmeer <markov@cpan.org>]. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.03. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 28 | ▶ | use warnings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 28 | ▶ | use strict; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 28 | ▶ | use v5.16; # fc | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | package Math::Formula::Type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 28 | ▶ | use vars '$VERSION'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 28 | $VERSION = '0.16'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 28 | ▶ | use base 'Math::Formula::Token'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | #!!! The declarations of all other packages in this file are indented to avoid | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | #!!! indexing by CPAN. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 28 | ▶ | use Log::Report 'math-formula', import => [ qw/warning error __x/ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # Object is an ARRAY. The first element is the token, as read from the formula | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # or constructed from a computed value. The second is a value, which can be | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # used in computation. More elements are type specific. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | sub cast($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 11 | ▶ | { my ($self, $to, $context) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cast: called CC=2 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 11 | ▶ | return MF::STRING->new(undef, $self->token) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | if $to eq 'MF::STRING'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # token() is implemented in de base-class ::Token, but documented here | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # Returns a value as result of a calculation. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # nothing to compute for most types: simply itself | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 511 | ▶ | sub compute { $_[0] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compute: called CC=1 SCAR=0.0
Pod
undocumented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 790 | ▶ | sub value { my $self = shift; $self->[1] //= $self->_value($self->[0], @_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=2 SCAR=6.9
Pod
documented
Condition100%3/3
$self->[1] //= $self->_value($self->[0], @_)
MC/DC100%2/2
$self->[1] //= $self->_value($self->[0], @_)
$self->[1]
$self->_value($self->[0], @_)
Truth table100%3/3
A //= B
A= $self->[1]B= $self->_value($self->[0], @_)
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub _value { $_[1] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value: not called CC=1 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | ▶ | sub collapsed($) { $_[0]->token =~ s/\s+/ /gr =~ s/^ //r =~ s/ $//r } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
collapsed: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | sub prefix() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | { my ($self, $op, $context) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefix: not called CC=1 SCAR=6.9
Pod
undocumented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | error __x"cannot find prefx operator '{op}' on a {child}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | op => $op, child => ref $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | sub attribute { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | warning __x"cannot find attribute '{attr}' for {class} '{token}'", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute: not called CC=1 SCAR=6.9
Pod
undocumented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | attr => $_[1], class => ref $_[0], token => $_[0]->token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | sub infix($@) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 34 | ▶ | { my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
infix: called CC=6 SCAR=19.1
Pod
undocumented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 34 | my ($op, $right, $context) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 34 | ▶ | if($op eq '.' && $right->isa('MF::NAME')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$op eq "." and $right->isa("MF::NAME")
MC/DC50%1/2
$op eq "." and $right->isa("MF::NAME")
$op eq "."
$right->isa("MF::NAME")
Truth table66%2/3
A and B
A= $op eq "."B= $right->isa("MF::NAME")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 33 | ▶ | { if(my $attr = $self->attribute($right->token)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 33 | ▶ | { return ref $attr eq 'CODE' ? $attr->($self, @_) : $attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # object used as string | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | ▶ | return $self->cast('MF::STRING', $context)->infix(@_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | if $op eq '~'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | error __x"cannot match infix operator '{op}' for ({left} -> {right})", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | op => $op, left => ref $self, right => ref $right; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | MF::BOOLEAN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 28 | ▶ | use base 'Math::Formula::Type'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # $class->new($token, $value, %options) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # When the value is derived from an expression, this should result in 1 or 0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | sub new($$@) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 165 | ▶ | { my ($class, $token, $value) = (shift, shift, shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 165 | ▶ | defined $token or $value = $value ? 1 : 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 165 | $class->SUPER::new($token, $value, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | sub prefix($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 6 | ▶ | { my ($self, $op, $context) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefix: called CC=2 SCAR=7.6
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 6 | ▶ | if($op eq 'not') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 6 | { return MF::BOOLEAN->new(undef, ! $self->value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $self->SUPER::prefix($op, $context); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | sub infix($$$) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 26 | ▶ | { my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
infix: called CC=12 SCAR=25.2
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 26 | my ($op, $right, $context) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 26 | ▶ | if(my $r = $right->isa('MF::BOOLEAN') ? $right : $right->cast('MF::BOOLEAN', $context)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | { # boolean values are 0 or 1, never undef | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 23 | ▶ | my $v = $op eq 'and' ? ($self->value and $r->value) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%10/10
$self->value and $r->value
$self->value or $r->value
$self->value xor $r->value
MC/DC100%2/2
$self->value and $r->value
$self->value
$r->value
MC/DC100%2/2
$self->value or $r->value
$self->value
$r->value
MC/DC100%2/2
$self->value xor $r->value
$self->value
$r->value
Truth table100%3/3
A and B
A= $self->valueB= $r->value
Truth table100%3/3
A or B
A= $self->valueB= $r->value
Truth table100%4/4
A xor B
A= $self->valueB= $r->value
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | : $op eq 'or' ? ($self->value or $r->value) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | : $op eq 'xor' ? ($self->value xor $r->value) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | : undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 23 | ▶ | return MF::BOOLEAN->new(undef, $v) if defined $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | elsif($op eq '->') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | ▶ | { $self->value or return undef; # case false | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | my $result = $right->compute($context); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | $context->setCaptures([]); # do not leak captures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 3 | return $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $self->SUPER::infix(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 98 | ▶ | sub _token($) { $_[1] ? 'true' : 'false' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_token: called CC=2 SCAR=6.9
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 38 | ▶ | sub _value($) { $_[1] eq 'true' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | MF::STRING; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 28 | ▶ | use base 'Math::Formula::Type'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 28 | ▶ | use Unicode::Collate (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 28 | my $collate = Unicode::Collate->new; #XXX which options do we need? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | sub new($$@) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 176 | ▶ | { my ($class, $token, $value) = (shift, shift, shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 176 | ▶ | ($token, $value) = (undef, $$token) if ref $token eq 'SCALAR'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 176 | $class->SUPER::new($token, $value, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 18 | ▶ | sub _token($) { '"' . ($_[1] =~ s/[\"]/\\$1/gr) . '"' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_token: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | sub _value($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 106 | ▶ | { my $token = $_[1] // ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value: called CC=4 SCAR=14.5
Condition50%1/2
$_[1] // ""
MC/DC0%0/1
$_[1] // ""
$_[1]
Truth table50%1/2
A
A= $_[1]
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 106 | ▶ | substr($token, 0, 1) eq '"' ? $token =~ s/^"//r =~ s/"$//r =~ s/\\([\\"])/$1/gr | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | : substr($token, 0, 1) eq "'" ? $token =~ s/^'//r =~ s/'$//r =~ s/\\([\\'])/$1/gr | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | : $token; # from code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | sub cast($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 28 | ▶ | { my ($self, $to) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cast: called CC=5 SCAR=16.3
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 28 | ▶ | ref $self eq __PACKAGE__ && $to eq 'MF::REGEXP' ? MF::REGEXP->_from_string($self) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
ref $self eq __PACKAGE__ and $to eq "MF::REGEXP"
ref $self eq __PACKAGE__ and $to eq "MF::PATTERN"
MC/DC50%1/2
ref $self eq __PACKAGE__ and $to eq "MF::REGEXP"
ref $self eq __PACKAGE__
$to eq "MF::REGEXP"
MC/DC50%1/2
ref $self eq __PACKAGE__ and $to eq "MF::PATTERN"
ref $self eq __PACKAGE__
$to eq "MF::PATTERN"
Truth table66%2/3
A and B
A= ref $self eq __PACKAGE__B= $to eq "MF::REGEXP"
Truth table66%2/3
A and B
A= ref $self eq __PACKAGE__B= $to eq "MF::PATTERN"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | : ref $self eq __PACKAGE__ && $to eq 'MF::PATTERN' ? MF::PATTERN->_from_string($self) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | : $self->SUPER::cast($to); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | sub infix($$$) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 60 | ▶ | { my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
infix: called CC=20 SCAR=30.7
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 60 | my ($op, $right, $context) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 60 | ▶ | if($op eq '~') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 6 | ▶ | { my $r = $right->isa('MF::STRING') ? $right : $right->cast('MF::STRING', $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 6 | ▶ | return MF::STRING->new(undef, $self->value . $r->value) if $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | elsif($op eq '=~') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 9 | ▶ | { if(my $r = $right->isa('MF::REGEXP') ? $right : $right->cast('MF::REGEXP', $context)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 9 | ▶ | { if(my @captures = $self->value =~ $r->regexp) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 7 | { $context->setCaptures(\@captures); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 7 | return MF::BOOLEAN->new(undef, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | return MF::BOOLEAN->new(undef, 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | elsif($op eq '!~') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 4 | ▶ | { my $r = $right->isa('MF::REGEXP') ? $right : $right->cast('MF::REGEXP', $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 4 | ▶ | return MF::BOOLEAN->new(undef, $self->value !~ $r->regexp) if $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ▶ | elsif($op eq 'like' || $op eq 'unlike') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$op eq "like" or $op eq "unlike"
MC/DC100%2/2
$op eq "like" or $op eq "unlike"
$op eq "like"
$op eq "unlike"
Truth table100%3/3
A or B
A= $op eq "like"B= $op eq "unlike"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | { # When expr is CODE, it may produce a qr// instead of a pattern. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 12 | ▶ | my $r = $right->isa('MF::PATTERN') || $right->isa('MF::REGEXP') ? $right : $right->cast('MF::PATTERN', $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$right->isa("MF::PATTERN") or $right->isa("MF::REGEXP")
MC/DC50%1/2
$right->isa("MF::PATTERN") or $right->isa("MF::REGEXP")
$right->isa("MF::PATTERN")
$right->isa("MF::REGEXP")
Truth table66%2/3
A or B
A= $right->isa("MF::PATTERN")B= $right->isa("MF::REGEXP")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 12 | ▶ | my $v = ! $r ? undef | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | : $op eq 'like' ? $self->value =~ $r->regexp : $self->value !~ $r->regexp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 12 | ▶ | return MF::BOOLEAN->new(undef, $v) if $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | elsif($op eq 'cmp') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 21 | ▶ | { my $r = $right->isa('MF::STRING') ? $right : $right->cast('MF::STRING', $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 21 | return MF::INTEGER->new(undef, $collate->cmp($self->value, $right->value)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 8 | $self->SUPER::infix(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | my %string_attrs = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 3 | ▶ | length => sub { MF::INTEGER->new(undef, length($_[0]->value)) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | ▶ | is_empty => sub { MF::BOOLEAN->new(undef, $_[0]->value !~ m/\P{Whitespace}/) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | ▶ | lower => sub { MF::STRING->new(undef, fc($_[0]->value)) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 8 | ▶ | sub attribute($) { $string_attrs{$_[1]} || $_[0]->SUPER::attribute($_[1]) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute: called CC=2 SCAR=7.6
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | MF::INTEGER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 28 | ▶ | use base 'Math::Formula::Type'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 28 | ▶ | use Log::Report 'math-formula', import => [ qw/error __x/ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | sub cast($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 16 | ▶ | { my ($self, $to) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cast: called CC=4 SCAR=13.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 16 | ▶ | $to eq 'MF::BOOLEAN' ? MF::BOOLEAN->new(undef, $_[0]->value == 0 ? 0 : 1) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | : $to eq 'MF::FLOAT' ? MF::FLOAT->new(undef, $_[0]->value) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | : $self->SUPER::cast($to); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | sub prefix($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 9 | ▶ | { my ($self, $op, $context) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefix: called CC=3 SCAR=11.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 9 | ▶ | $op eq '+' ? $self | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | : $op eq '-' ? MF::INTEGER->new(undef, - $self->value) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | : $self->SUPER::prefix($op, $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | sub infix($$$) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 58 | ▶ | { my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
infix: called CC=16 SCAR=27.7
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 58 | my ($op, $right, $context) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 58 | ▶ | return $self->cast('MF::BOOLEAN', $context)->infix(@_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$op eq "and" or $op eq "or" or $op eq "xor"
$op eq "and" or $op eq "or"
MC/DC100%3/3
$op eq "and" or $op eq "or" or $op eq "xor"
$op eq "and"
$op eq "or"
$op eq "xor"
Truth table100%4/4
A or B or C
A= $op eq "and"B= $op eq "or"C= $op eq "xor"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | if $op eq 'and' || $op eq 'or' || $op eq 'xor'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 52 | ▶ | $right->cast('MF::INTEGER') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | if $right->isa('MF::TIMEZONE'); # mis-parse | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 52 | ▶ | if($right->isa('MF::INTEGER') || $right->isa('MF::FLOAT')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$right->isa("MF::INTEGER") or $right->isa("MF::FLOAT")
MC/DC100%2/2
$right->isa("MF::INTEGER") or $right->isa("MF::FLOAT")
$right->isa("MF::INTEGER")
$right->isa("MF::FLOAT")
Truth table100%3/3
A or B
A= $right->isa("MF::INTEGER")B= $right->isa("MF::FLOAT")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 47 | ▶ | { my $v = $op eq '+' ? $self->value + $right->value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | : $op eq '-' ? $self->value - $right->value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | : $op eq '*' ? $self->value * $right->value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | : $op eq '%' ? $self->value % $right->value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | : undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 47 | ▶ | return ref($right)->new(undef, $v) if defined $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 25 | ▶ | return MF::INTEGER->new(undef, $self->value <=> $right->value) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | if $op eq '<=>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | ▶ | return MF::FLOAT->new(undef, $self->value / $right->value) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | if $op eq '/'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 5 | ▶ | return $right->infix($op, $self, @_[2..$#_]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$op eq "*" and $right->isa("MF::DURATION")
MC/DC50%1/2
$op eq "*" and $right->isa("MF::DURATION")
$op eq "*"
$right->isa("MF::DURATION")
Truth table66%2/3
A and B
A= $op eq "*"B= $right->isa("MF::DURATION")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | if $op eq '*' && $right->isa('MF::DURATION'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 3 | $self->SUPER::infix(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 28 | my $gibi = 1024 * 1024 * 1024; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 28 | my $multipliers = '[kMGTEZ](?:ibi)?\b'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 28 | ▶ | sub _match { "[0-9][0-9_]* (?:$multipliers)?" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 28 | my %multipliers = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | k => 1000, M => 1000_000, G => 1000_000_000, T => 1000_000_000_000, E => 1e15, Z => 1e18, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | kibi => 1024, Mibi => 1024*1024, Gibi => $gibi, Tibi => 1024*$gibi, Eibi => 1024*1024*$gibi, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | Zibi => $gibi*$gibi, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | sub _value($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 123 | ▶ | { my ($v, $m) = $_[1] =~ m/^ ( [0-9]+ (?: _[0-9][0-9][0-9] )* ) ($multipliers)? $/x | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value: called CC=3 SCAR=11.1
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | or error __x"illegal number format for '{string}'", string => $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 123 | ▶ | ($1 =~ s/_//gr) * ($2 ? $multipliers{$2} : 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | my %int_attrs = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 2 | ▶ | abs => sub { $_[0]->value < 0 ? MF::INTEGER->new(undef, - $_[0]->value) : $_[0] }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | ▶ | sub attribute($) { $int_attrs{$_[1]} || $_[0]->SUPER::attribute($_[1]) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute: called CC=2 SCAR=7.6
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | MF::FLOAT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 28 | ▶ | use base 'Math::Formula::Type'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 28 | ▶ | use POSIX qw/floor/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 29 | ▶ | sub _match { '[0-9]+ (?: \.[0-9]+ (?: e [+-][0-9]+ )? | e [+-][0-9]+ )' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 37 | ▶ | sub _value($) { $_[1] + 0.0 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 24 | ▶ | sub _token($) { my $t = sprintf '%g', $_[1]; $t =~ /[e.]/ ? $t : "$t.0" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_token: called CC=2 SCAR=6.9
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | sub cast($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | ▶ | { my ($self, $to) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cast: called CC=2 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 2 | ▶ | $to eq 'MF::INTEGER' ? MF::INTEGER->new(undef, floor($_[0]->value)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | : $self->SUPER::cast($to); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | sub prefix($$) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 9 | ▶ | { my ($self, $op, $context) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefix: called CC=3 SCAR=11.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 9 | ▶ | $op eq '+' ? $self | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | : $op eq '-' ? MF::FLOAT->new(undef, - $self->value) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | : $self->SUPER::prefix($op, $context) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | sub infix($$$) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 17 | ▶ | { my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
infix: called CC=14 SCAR=28.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 17 | my ($op, $right, $context) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 17 | ▶ | return $self->cast('MF::BOOLEAN', $context)->infix(@_) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$op eq "and" or $op eq "or" or $op eq "xor"
$op eq "and" or $op eq "or"
MC/DC0%0/3
$op eq "and" or $op eq "or" or $op eq "xor"
$op eq "and"
$op eq "or"
$op eq "xor"
Truth table25%1/4
A or B or C
A= $op eq "and"B= $op eq "or"C= $op eq "xor"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | if $op eq 'and' || $op eq 'or' || $op eq 'xor'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 17 | ▶ | $right->cast('MF::INTEGER') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | if $right->isa('MF::TIMEZONE'); # mis-parse | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 17 | ▶ | if($right->isa('MF::FLOAT') || $right->isa('MF::INTEGER')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$right->isa("MF::FLOAT") or $right->isa("MF::INTEGER")
MC/DC0%0/2
$right->isa("MF::FLOAT") or $right->isa("MF::INTEGER")
$right->isa("MF::FLOAT")
$right->isa("MF::INTEGER")
Truth table66%2/3
A or B
A= $right->isa("MF::FLOAT")B= $right->isa("MF::INTEGER")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | { # Perl will upgrade the integers | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 17 | ▶ | my $v = $op eq '+' ? $self->value + $right->value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | : $op eq '-' ? $self->value - $right->value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | : $op eq '*' ? $self->value * $right->value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | : $op eq '%' ? $self->value % $right->value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | : $op eq '/' ? $self->value / $right->value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | : undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 17 | ▶ | return MF::FLOAT->new(undef, $v) if defined $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 6 | ▶ | return MF::INTEGER->new(undef, $self->value <=> $right->value) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | if $op eq '<=>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $self->SUPER::infix(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # I really do not want a math library in here! Use formulas with CODE expr | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # my %float_attrs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | #sub attribute($) { $float_attrs{$_[1]} || $_[0]->SUPER::attribute($_[1]) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | MF::DATETIME; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 28 | ▶ | use base 'Math::Formula::Type'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 28 | ▶ | use DateTime (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | sub _match { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 56 | ▶ | '[12][0-9]{3} \- (?:0[1-9]|1[012]) \- (?:0[1-9]|[12][0-9]|3[01]) T ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | . '(?:[01][0-9]|2[0-3]) \: [0-5][0-9] \: (?:[0-5][0-9]) (?:\.[0-9]+)?' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | . '(?:[+-][0-9]{4})?'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 4 | ▶ | sub _token($) { $_[1]->datetime . ($_[1]->time_zone->name =~ s/UTC$/+0000/r) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_token: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | sub _value($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 37 | ▶ | { my ($self, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value: called CC=4 SCAR=13.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 37 | ▶ | $token =~ m/^ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ([12][0-9]{3}) \- (0[1-9]|1[012]) \- (0[1-9]|[12][0-9]|3[01]) T | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | ([01][0-9]|2[0-3]) \: ([0-5][0-9]) \: ([0-5][0-9]|6[01]) (?:(\.[0-9]+))? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | ([+-] [0-9]{4})? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | $ /x or return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 37 | ▶ | my $tz_offset = $8 // '+0000'; # careful with named matches :-( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$8 // "+0000"
MC/DC100%1/1
$8 // "+0000"
$8
Truth table100%2/2
A
A= $8
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 37 | ▶ | my @args = ( year => $1, month => $2, day => $3, hour => $4, minute => $5, second => $6, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$7 // 0
MC/DC100%1/1
$7 // 0
$7
Truth table100%2/2
A
A= $7
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | nanosecond => ($7 // 0) * 1_000_000_000 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 37 | my $tz = DateTime::TimeZone::OffsetOnly->new(offset => $tz_offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 37 | DateTime->new(@args, time_zone => $tz); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | sub _to_time($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 2 | ▶ | { +{ hour => $_[0]->hour, minute => $_[0]->minute, second => $_[0]->second, ns => $_[0]->nanosecond }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_to_time: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | sub cast($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 2 | ▶ | { my ($self, $to) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cast: called CC=3 SCAR=11.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 2 | ▶ | $to eq 'MF::TIME' ? MF::TIME->new(undef, _to_time($_[0]->value)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | : $to eq 'MF::DATE' ? MF::DATE->new(undef, $_[0]->value->clone) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | : $self->SUPER::cast($to); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | sub infix($$$@) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 21 | ▶ | { my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
infix: called CC=14 SCAR=26.6
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 21 | my ($op, $right, $context) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 21 | ▶ | if($op eq '+' || $op eq '-') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op eq "+" or $op eq "-"
MC/DC100%2/2
$op eq "+" or $op eq "-"
$op eq "+"
$op eq "-"
Truth table100%3/3
A or B
A= $op eq "+"B= $op eq "-"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 3 | { my $dt = $self->value->clone; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 3 | ▶ | if($right->isa('MF::DURATION')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 2 | ▶ | { my $v = $op eq '+' ? $dt->add_duration($right->value) : $dt->subtract_duration($right->value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 2 | return MF::DATETIME->new(undef, $v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 1 | ▶ | if($op eq '-') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | ▶ | { my $r = $right->isa('MF::DATETIME') ? $right : $right->cast('MF::DATETIME', $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 1 | return MF::DURATION->new(undef, $dt->subtract_datetime($right->value)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 18 | ▶ | if($op eq '<=>') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 8 | ▶ | { return MF::INTEGER->new(undef, DateTime->compare($self->value, $right->value)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | if $right->isa('MF::DATETIME'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 3 | ▶ | if($right->isa('MF::DATE')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | { # Many timezone problems solved by DateTime | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 3 | my $date = $right->token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 3 | ▶ | my $begin = $self->_value($date =~ /\+/ ? $date =~ s/\+/T00:00:00+/r : $date.'T00:00:00'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 3 | ▶ | return MF::INTEGER->new(undef, -1) if DateTime->compare($begin, $self->value) > 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 2 | ▶ | my $end = $self->_value($date =~ /\+/ ? $date =~ s/\+/T23:59:59+/r : $date.'T23:59:59'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 2 | ▶ | return MF::INTEGER->new(undef, DateTime->compare($self->value, $end) > 0 ? 1 : 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 10 | $self->SUPER::infix(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | my %dt_attrs = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 1 | ▶ | 'time' => sub { MF::TIME->new(undef, _to_time($_[0]->value)) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 1 | ▶ | date => sub { MF::DATE->new(undef, $_[0]->value) }, # dt's are immutable | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 1 | ▶ | hour => sub { MF::INTEGER->new(undef, $_[0]->value->hour) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 1 | ▶ | minute => sub { MF::INTEGER->new(undef, $_[0]->value->minute) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 1 | ▶ | second => sub { MF::INTEGER->new(undef, $_[0]->value->second) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 1 | ▶ | fracsec => sub { MF::FLOAT ->new(undef, $_[0]->value->fractional_second) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | sub attribute($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 10 | ▶ | { $dt_attrs{$_[1]} || $MF::DATE::date_attrs{$_[1]} || $_[0]->SUPER::attribute($_[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute: called CC=3 SCAR=12.0
Branch: 1 branch
Condition66%2/3
$dt_attrs{$_[1]} or $MF::DATE::date_attrs{$_[1]}
MC/DC0%0/2
$dt_attrs{$_[1]} or $MF::DATE::date_attrs{$_[1]}
$dt_attrs{$_[1]}
$MF::DATE::date_attrs{$_[1]}
Truth table66%2/3
A or B
A= $dt_attrs{$_[1]}B= $MF::DATE::date_attrs{$_[1]}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | MF::DATE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 28 | ▶ | use base 'Math::Formula::Type'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 28 | ▶ | use Log::Report 'math-formula', import => [ qw/error warning __x/ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 28 | ▶ | use DateTime::TimeZone (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 28 | ▶ | use DateTime::TimeZone::OffsetOnly (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 56 | ▶ | sub _match { '[12][0-9]{3} \- (?:0[1-9]|1[012]) \- (?:0[1-9]|[12][0-9]|3[01]) (?:[+-][0-9]{4})?' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 5 | ▶ | sub _token($) { $_[1]->ymd . ($_[1]->time_zone->name =~ s/UTC$/+0000/r) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_token: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | sub _value($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 11 | ▶ | { my ($self, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value: called CC=3 SCAR=11.2
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 11 | ▶ | $token =~ m/^ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | ([12][0-9]{3}) \- (0[1-9]|1[012]) \- (0[1-9]|[12][0-9]|3[01]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | ([+-] [0-9]{4})? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | $ /x or return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 11 | ▶ | my $tz_offset = $4 // '+0000'; # careful with named matches :-( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$4 // "+0000"
MC/DC0%0/1
$4 // "+0000"
$4
Truth table50%1/2
A
A= $4
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 11 | my @args = ( year => $1, month => $2, day => $3); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 11 | my $tz = DateTime::TimeZone::OffsetOnly->new(offset => $tz_offset); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 11 | DateTime->new(@args, time_zone => $tz); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | sub cast($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 3 | ▶ | { my ($self, $to) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cast: called CC=4 SCAR=14.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 3 | ▶ | if($to eq 'MF::INTEGER') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | { # In really exceptional cases, an integer expression can be mis-detected as DATE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 2 | bless $self, 'MF::INTEGER'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 2 | $self->[0] = $self->[1] = eval "$self->[0]"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 2 | return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 1 | ▶ | if($to eq 'MF::DATETIME') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 1 | { my $t = $self->token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 1 | ▶ | my $dt = $t =~ /\+/ ? $t =~ s/\+/T00:00:00+/r : $t . 'T00:00:00'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 1 | return MF::DATETIME->new($dt); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | $self->SUPER::cast($to); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | sub infix($$@) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 12 | ▶ | { my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
infix: called CC=17 SCAR=28.6
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 12 | my ($op, $right, $context) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 12 | ▶ | if($op eq '+' && $right->isa('MF::TIME')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op eq "+" and $right->isa("MF::TIME")
MC/DC100%2/2
$op eq "+" and $right->isa("MF::TIME")
$op eq "+"
$right->isa("MF::TIME")
Truth table100%3/3
A and B
A= $op eq "+"B= $right->isa("MF::TIME")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 1 | { my $l = $self->value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 1 | my $r = $right->value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | my $v = DateTime->new(year => $l->year, month => $l->month, day => $l->day, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | hour => $r->{hour}, minute => $r->{minute}, second => $r->{second}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 1 | nanosecond => $r->{ns}, time_zone => $l->time_zone); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 1 | return MF::DATETIME->new(undef, $v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 11 | ▶ | if($op eq '-' && $right->isa('MF::DATE')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op eq "-" and $right->isa("MF::DATE")
MC/DC100%2/2
$op eq "-" and $right->isa("MF::DATE")
$op eq "-"
$right->isa("MF::DATE")
Truth table100%3/3
A and B
A= $op eq "-"B= $right->isa("MF::DATE")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 1 | { return MF::DURATION->new(undef, $self->value->clone->subtract_datetime($right->value)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 10 | ▶ | if($op eq '+' || $op eq '-') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op eq "+" or $op eq "-"
MC/DC100%2/2
$op eq "+" or $op eq "-"
$op eq "+"
$op eq "-"
Truth table100%3/3
A or B
A= $op eq "+"B= $op eq "-"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 2 | ▶ | { my $r = $right->isa('MF::DURATION') ? $right : $right->cast('MF::DURATION', $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 2 | ▶ | ! $r || $r->token !~ m/T.*[1-9]/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$r and $r->token =~ /T.*[1-9]/u
MC/DC0%0/2
$r and $r->token =~ /T.*[1-9]/u
$r
$r->token =~ /T.*[1-9]/u
Truth table33%1/3
A and B
A= $rB= $r->token =~ /T.*[1-9]/u
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | or error __x"only duration with full days with DATE, found '{value}'", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | value => $r->token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 2 | my $dt = $self->value->clone; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 2 | ▶ | my $v = $op eq '+' ? $dt->add_duration($right->value) : $dt->subtract_duration($right->value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 2 | return MF::DATE->new(undef, $v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 8 | ▶ | if($op eq '<=>') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 4 | ▶ | { my $r = $right->isa('MF::DATE') ? $right : $right->cast('MF::DATE', $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 4 | my ($ld, $ltz) = $self->token =~ m/(.{10})(.*)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 4 | my ($rd, $rtz) = $r->token =~ m/(.{10})(.*)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | # It is probably a configuration issue when you configure this. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 4 | ▶ | $ld ne $rd || ($ltz //'') eq ($rtz //'') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition71%5/7
$ld ne $rd or ($ltz // "") eq ($rtz // "")
$ltz // ""
$rtz // ""
MC/DC0%0/2
$ld ne $rd or ($ltz // "") eq ($rtz // "")
$ld ne $rd
$ltz
MC/DC0%0/1
$rtz // ""
$rtz
Truth table66%2/3
A or B
A= $ld ne $rdB= $ltz
Truth table50%1/2
A
A= $rtz
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | or warning __x"dates '{first}' and '{second}' do not match on timezone", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | first => $self->token, second => $r->token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 4 | return MF::INTEGER->new(undef, $ld cmp $rd); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 4 | $self->SUPER::infix(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | our %date_attrs = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 2 | ▶ | year => sub { MF::INTEGER->new(undef, $_[0]->value->year) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 2 | ▶ | month => sub { MF::INTEGER->new(undef, $_[0]->value->month) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 2 | ▶ | day => sub { MF::INTEGER->new(undef, $_[0]->value->day) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 2 | ▶ | timezone => sub { MF::TIMEZONE->new($_[0]->value->time_zone->name) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 4 | ▶ | sub attribute($) { $date_attrs{$_[1]} || $_[0]->SUPER::attribute($_[1]) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute: called CC=2 SCAR=7.6
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | MF::TIME; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 28 | ▶ | use base 'Math::Formula::Type'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 28 | ▶ | use constant GIGA => 1_000_000_000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 56 | ▶ | sub _match { '(?:[01][0-9]|2[0-3]) \: [0-5][0-9] \: (?:[0-5][0-9]) (?:\.[0-9]+)?' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | sub _token($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 7 | ▶ | { my $time = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_token: called CC=2 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 7 | my $ns = $time->{ns}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 7 | ▶ | my $frac = $ns ? sprintf(".%09d", $ns) =~ s/0+$//r : ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 7 | sprintf "%02d:%02d:%02d%s", $time->{hour}, $time->{minute}, $time->{second}, $frac; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | sub _value($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 23 | ▶ | { my ($self, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value: called CC=3 SCAR=11.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 23 | ▶ | $token =~ m/^ ([01][0-9]|2[0-3]) \: ([0-5][0-9]) \: ([0-5][0-9]) (?:(\.[0-9]+))? $/x | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | or return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 23 | ▶ | +{ hour => $1+0, minute => $2+0, second => $3+0, ns => ($4 //0) * GIGA }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$4 // 0
MC/DC100%1/1
$4 // 0
$4
Truth table100%2/2
A
A= $4
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | our %time_attrs = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 4 | ▶ | hour => sub { MF::INTEGER->new(undef, $_[0]->value->{hour}) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 2 | ▶ | minute => sub { MF::INTEGER->new(undef, $_[0]->value->{minute}) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 2 | ▶ | second => sub { MF::INTEGER->new(undef, $_[0]->value->{second}) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 2 | ▶ | fracsec => sub { my $t = $_[0]->value; MF::FLOAT->new(undef, $t->{second} + $t->{ns}/GIGA) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 10 | ▶ | sub attribute($) { $time_attrs{$_[1]} || $_[0]->SUPER::attribute($_[1]) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute: called CC=2 SCAR=7.6
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | sub _sec_diff($$) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 8 | ▶ | { my ($self, $diff, $ns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sec_diff: called CC=3 SCAR=11.2
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 8 | ▶ | if($ns < 0) { $ns += GIGA; $diff -= 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | elsif($ns > GIGA) { $ns -= GIGA; $diff += 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 8 | my $sec = $diff % 60; $diff /= 60; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 8 | my $min = $diff % 60; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 8 | my $hrs = ($diff / 60) % 24; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 8 | +{ hour => $hrs, minute => $min, second => $sec, nanosecond => $ns}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | sub infix($$@) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 13 | ▶ | { my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
infix: called CC=10 SCAR=23.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 13 | my ($op, $right, $context) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 13 | ▶ | if($op eq '+' || $op eq '-') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op eq "+" or $op eq "-"
MC/DC100%2/2
$op eq "+" or $op eq "-"
$op eq "+"
$op eq "-"
Truth table100%3/3
A or B
A= $op eq "+"B= $op eq "-"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | { # normalization is a pain, so bluntly convert to seconds | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 8 | my $time = $self->value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 8 | my $was = $time->{hour} * 3600 + $time->{minute} * 60 + $time->{second}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 8 | ▶ | if(my $r = $right->isa('MF::TIME') ? $right : $right->cast('MF::TIME', $context)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 5 | { my $v = $r->value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 5 | my $min = $v->{hour} * 3600 + $v->{minute} * 60 + $v->{second}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 5 | my $diff = $self->_sec_diff($was - $min, $time->{ns} - $v->{ns}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 5 | ▶ | my $frac = $diff->{nanosecond} ? sprintf(".%09d", $diff->{nanosecond}) =~ s/0+$//r : ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | return MF::DURATION->new(sprintf "PT%dH%dM%d%sS", $diff->{hour}, $diff->{minute}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 5 | $diff->{second}, $frac); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 3 | ▶ | if(my $r = $right->isa('MF::DURATION') ? $right : $right->cast('MF::DURATION', $context)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 3 | { my (undef, $hours, $mins, $secs, $ns) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | $r->value->in_units(qw/days hours minutes seconds nanoseconds/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 3 | my $dur = $hours * 3600 + $mins * 60 + $secs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 3 | ▶ | my $diff = $op eq '+' ? $was + $dur : $was - $dur; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 3 | ▶ | my $nns = $op eq '+' ? $time->{ns} + $ns : $time->{ns} - $ns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 3 | return MF::TIME->new(undef, $self->_sec_diff($diff, $ns)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 5 | $self->SUPER::infix(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | MF::TIMEZONE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 28 | ▶ | use base 'Math::Formula::Type'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 28 | ▶ | use POSIX 'floor'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 28 | ▶ | sub _match { '[+-] (?: 0[0-9]|1[012] ) [0-5][0-9]' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | sub _token($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 4 | ▶ | { my $count = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_token: called CC=2 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 4 | my $sign = '+'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 4 | ▶ | ($sign, $count) = ('-', -$count) if $count < 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 4 | my $hours = floor($count / 60 + 0.0001); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 4 | my $mins = $count % 60; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 4 | sprintf "%s%02d%02d", $sign, $hours, $mins; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | # The value is stored in minutes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | sub _value($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 12 | ▶ | { my ($self, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value: called CC=3 SCAR=11.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 12 | ▶ | $token =~ m/^ ([+-]) (0[0-9]|1[012]) ([0-5][0-9]) $/x | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | or return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 12 | ▶ | ($1 eq '-' ? -1 : 1) * ( $2 * 60 + $3 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | sub cast($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 6 | ▶ | { my ($self, $to) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cast: called CC=3 SCAR=11.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 6 | ▶ | if($to->isa('MF::INTEGER') || $to->isa('MF::FLOAT')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$to->isa("MF::INTEGER") or $to->isa("MF::FLOAT")
MC/DC50%1/2
$to->isa("MF::INTEGER") or $to->isa("MF::FLOAT")
$to->isa("MF::INTEGER")
$to->isa("MF::FLOAT")
Truth table66%2/3
A or B
A= $to->isa("MF::INTEGER")B= $to->isa("MF::FLOAT")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | { # Oops, we mis-parsed and integer when 1[0-2][0-5][0-9] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 5 | $self->[1] = $self->[0] + 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 5 | $self->[0] = undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 5 | return bless $self, $to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 1 | $self->SUPER::cast($to); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | our %tz_attrs = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 1 | ▶ | in_seconds => sub { MF::INTEGER->new(undef, $_[0]->value * 60) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 1 | ▶ | in_minutes => sub { MF::INTEGER->new(undef, $_[0]->value) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 2 | ▶ | sub attribute($) { $tz_attrs{$_[1]} || $_[0]->SUPER::attribute($_[1]) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute: called CC=2 SCAR=7.6
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | sub prefix($$) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 2 | ▶ | { my ($self, $op, $context) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefix: called CC=3 SCAR=11.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 2 | ▶ | $op eq '+' ? $self | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | : $op eq '-' ? MF::TIMEZONE->new(undef, - $self->value) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | : $self->SUPER::prefix($op, $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | sub infix($$@) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 5 | ▶ | { my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
infix: called CC=6 SCAR=18.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 5 | my ($op, $right, $context) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 5 | ▶ | if($op eq '+' || $op eq '-') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op eq "+" or $op eq "-"
MC/DC100%2/2
$op eq "+" or $op eq "-"
$op eq "+"
$op eq "-"
Truth table100%3/3
A or B
A= $op eq "+"B= $op eq "-"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 3 | ▶ | { if(my $d = $right->isa('MF::DURATION') ? $right : $right->cast('MF::DURATION')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 3 | ▶ | { return MF::TIMEZONE->new(undef, $self->value + | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | ($op eq '-' ? -1 : 1) * floor($d->inSeconds / 60 + 0.000001)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 2 | $self->SUPER::infix(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | MF::DURATION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 28 | ▶ | use base 'Math::Formula::Type'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 28 | ▶ | use DateTime::Duration (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 28 | ▶ | use POSIX qw/floor/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 56 | ▶ | sub _match { '[+-]? P (?:[0-9]+Y)? (?:[0-9]+M)? (?:[0-9]+D)? ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | . ' (?:T (?:[0-9]+H)? (?:[0-9]+M)? (?:[0-9]+(?:\.[0-9]+)?S)? )? \b'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 28 | ▶ | use DateTime::Format::Duration::ISO8601 (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 28 | my $dur_format = DateTime::Format::Duration::ISO8601->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | # Implementation dus not like negatives, but DateTime::Duration does. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 13 | ▶ | sub _token($) { ($_[1]->is_negative ? '-' : '') . $dur_format->format_duration($_[1]) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_token: called CC=2 SCAR=6.9
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | sub _value($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 40 | ▶ | { my $value = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value: called CC=2 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 40 | my $negative = $value =~ s/^-//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 40 | my $duration = $dur_format->parse_duration($value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 40 | ▶ | $negative ? $duration->multiply(-1) : $duration; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | sub prefix($$) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 2 | ▶ | { my ($self, $op, $context) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefix: called CC=3 SCAR=11.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 2 | ▶ | $op eq '+' ? $self | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | : $op eq '-' ? MF::DURATION->new('-' . $self->token) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | : $self->SUPER::prefix($op, $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | sub infix($$@) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 16 | ▶ | { my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
infix: called CC=13 SCAR=26.5
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 16 | my ($op, $right, $context) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 16 | ▶ | if($op eq '+' || $op eq '-') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$op eq "+" or $op eq "-"
MC/DC100%2/2
$op eq "+" or $op eq "-"
$op eq "+"
$op eq "-"
Truth table100%3/3
A or B
A= $op eq "+"B= $op eq "-"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 4 | ▶ | { my $r = $right->isa('MF::DURATION') ? $right : $right->cast('MF::DURATION', $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 4 | my $v = $self->value->clone; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 4 | ▶ | my $dt = ! $r ? undef : $op eq '+' ? $v->add_duration($r->value) : $v->subtract_duration($r->value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 4 | ▶ | return MF::DURATION->new(undef, $dt) if $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | elsif($op eq '*') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 4 | ▶ | { my $r = $right->isa('MF::INTEGER') ? $right : $right->cast('MF::INTEGER', $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 4 | ▶ | return MF::DURATION->new(undef, $self->value->clone->multiply($r->value)) if $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | elsif($op eq '<=>') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 6 | ▶ | { my $r = $right->isa('MF::DURATION') ? $right : $right->cast('MF::DURATION', $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 6 | ▶ | return MF::INTEGER->new(undef, DateTime::Duration->compare($self->value, $r->value)) if $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 2 | $self->SUPER::infix(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | sub inSeconds() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 5 | ▶ | { my $d = $_[0]->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inSeconds: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 5 | ($d->years + $d->months/12) * 365.256 + $d->days * 86400 + $d->hours * 3600 + $d->minutes * 60 + $d->seconds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | my %dur_attrs = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 1 | ▶ | in_days => sub { MF::INTEGER->new(undef, floor($_[0]->inSeconds / 86400 +0.00001)) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 1 | ▶ | in_seconds => sub { MF::INTEGER->new(undef, $_[0]->inSeconds) }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 2 | ▶ | sub attribute($) { $dur_attrs{$_[1]} || $_[0]->SUPER::attribute($_[1]) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribute: called CC=2 SCAR=7.6
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | MF::NAME; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 28 | ▶ | use base 'Math::Formula::Type'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 28 | ▶ | use Log::Report 'math-formula', import => [ qw/error __x/ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 28 | my $pattern = '[_\p{Alpha}][_\p{AlNum}]*'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 28 | ▶ | sub _match() { $pattern } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | sub value($) { error __x"name '{name}' cannot be used as value.", name => $_[0]->token } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: not called CC=1 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | sub validated($$) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | { my ($class, $name, $where) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validated: not called CC=2 SCAR=17.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | $name =~ qr/^$pattern$/o | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | or error __x"Illegal name '{name}' in '{where}'", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | name => $name =~ s/[^_\p{AlNum}]/ϴ/gr, where => $where; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | $class->new($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | sub cast(@) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 2 | ▶ | { my ($self, $type, $context) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cast: called CC=4 SCAR=20.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 2 | ▶ | if($type->isa('MF::FRAGMENT')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | { my $frag = $self->token eq '' ? $context : $context->fragment($self->token); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | return MF::FRAGMENT->new($frag->name, $frag) if $frag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 2 | $context->evaluate($self->token, expect => $type); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | sub prefix($$) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 4 | ▶ | { my ($self, $op, $context) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefix: called CC=2 SCAR=8.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 4 | ▶ | return MF::BOOLEAN->new(undef, defined $context->formula($self->token)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | if $op eq 'exists'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | $self->SUPER::prefix($op, $context); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | sub infix(@) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 21 | ▶ | { my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
infix: called CC=10 SCAR=23.2
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 21 | my ($op, $right, $context) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 21 | my $name = $self->token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 21 | ▶ | if($op eq '.') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 4 | ▶ | { my $left = $name eq '' ? MF::FRAGMENT->new($context->name, $context) : $context->evaluate($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 4 | ▶ | return $left->infix(@_) if $left; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 17 | ▶ | if($op eq '#') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 7 | ▶ | { my $left = $name eq '' ? MF::FRAGMENT->new($context->name, $context) : $context->fragment($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 7 | ▶ | return $left->infix(@_) if $left; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 10 | ▶ | if($op eq '//') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 5 | ▶ | { return defined $context->formula($name) ? $context->evaluate($name) : $right->compute($context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 5 | my $left = $context->evaluate($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 5 | ▶ | $left ? $left->infix($op, $right, $context): undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | MF::PATTERN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 28 | ▶ | use base 'MF::STRING'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 28 | ▶ | use Log::Report 'math-formula', import => [ qw/warning __x/ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | sub _token($) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | ▶ | warning __x"cannot convert qr back to pattern, do {regexp}", regexp => $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_token: not called CC=1 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | "pattern meaning $_[1]"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | sub _from_string($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 11 | ▶ | { my ($class, $string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_from_string: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 11 | $string->token; # be sure the pattern is kept as token: cannot be recovered | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 11 | bless $string, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | sub _to_regexp($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 24 | ▶ | { my @chars = $_[0] =~ m/( \\. | . )/gxu; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_to_regexp: called CC=20 SCAR=30.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 24 | my (@regexp, $in_alts, $in_range); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 24 | foreach my $char (@chars) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 106 | ▶ | { if(length $char==2) { push @regexp, $char; next } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 104 | ▶ | if($char !~ /^[\[\]*?{},!]$/) { push @regexp, $in_range ? $char : quotemeta $char } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 10 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 12 | elsif($char eq '*') { push @regexp, '.*' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 1 | elsif($char eq '?') { push @regexp, '.' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 3 | elsif($char eq '[') { push @regexp, '['; $in_range++ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 3 | elsif($char eq ']') { push @regexp, ']'; $in_range=0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 2 | ▶ | elsif($char eq '!') { push @regexp, $in_range && $regexp[-1] eq '[' ? '^' : '\!' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$in_range and $regexp[-1] eq "["
MC/DC50%1/2
$in_range and $regexp[-1] eq "["
$in_range
$regexp[-1] eq "["
Truth table66%2/3
A and B
A= $in_rangeB= $regexp[-1] eq "["
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 5 | ▶ | elsif($char eq '{') { push @regexp, $in_range ? '{' : '(?:'; $in_range or $in_alts++ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 5 | ▶ | elsif($char eq '}') { push @regexp, $in_range ? '}' : ')'; $in_range or $in_alts=0 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 10 | ▶ | elsif($char eq ',') { push @regexp, $in_alts ? '|' : '\,' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | else {die} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 24 | my $regexp = join '', @regexp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 24 | qr/^${regexp}$/u; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 12 | ▶ | sub regexp() { $_[0][2] //= _to_regexp($_[0]->value) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
regexp: called CC=2 SCAR=7.2
Condition66%2/3
$_[0][2] //= &_to_regexp(scalar $_[0]->value)
MC/DC0%0/2
$_[0][2] //= &_to_regexp(scalar $_[0]->value)
$_[0][2]
&_to_regexp(scalar $_[0]->value)
Truth table66%2/3
A //= B
A= $_[0][2]B= &_to_regexp(scalar $_[0]->value)
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | MF::REGEXP; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 28 | ▶ | use base 'MF::STRING'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | sub _from_string($) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 14 | ▶ | { my ($class, $string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_from_string: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 14 | bless $string, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | sub regexp | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 17 | ▶ | { my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
regexp: called CC=2 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 17 | ▶ | return $self->[2] if defined $self->[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 15 | my $value = $self->value =~ s!/!\\/!gr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 15 | $self->[2] = qr/$value/xu; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | #----------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | MF::FRAGMENT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 28 | ▶ | use base 'Math::Formula::Type'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 28 | ▶ | use Log::Report 'math-formula', import => [ qw/panic error __x/ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | ▶ | sub name { $_[0][0] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 15 | ▶ | sub context { $_[0][1] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
context: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | sub infix($$@) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 15 | ▶ | { my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
infix: called CC=7 SCAR=21.1
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 15 | my ($op, $right, $context) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 15 | my $name = $right->token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 15 | ▶ | if($op eq '#' && $right->isa('MF::NAME')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$op eq "#" and $right->isa("MF::NAME")
MC/DC50%1/2
$op eq "#" and $right->isa("MF::NAME")
$op eq "#"
$right->isa("MF::NAME")
Truth table66%2/3
A and B
A= $op eq "#"B= $right->isa("MF::NAME")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 7 | ▶ | { my $fragment = $self->context->fragment($name) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | or error __x"cannot find fragment '{name}' in '{context}'", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | name => $name, context => $context->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 7 | return $fragment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 8 | ▶ | if($op eq '.' && $right->isa('MF::NAME')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$op eq "." and $right->isa("MF::NAME")
MC/DC0%0/2
$op eq "." and $right->isa("MF::NAME")
$op eq "."
$right->isa("MF::NAME")
Truth table33%1/3
A and B
A= $op eq "."B= $right->isa("MF::NAME")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 8 | { my $result = $self->context->evaluate($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 8 | ▶ | return $result if $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | $self->SUPER::infix(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 28 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||