lib/Schedule/Easing/Ease.pm

filter: Statementstmt 93.9% 62 / 66 Branchbran 90.9% 20 / 22 Conditioncond 77.7% 7 / 9 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 84.6% 11 / 13 Podpod 0.0% 0 / 6 totaltotal 84.3% 102 / 121 CC 17 SCAR 20.4
CC
17
Cov
92%
validate
14.1
new
3.0
includes
2.0
CRAP 7.7
« script/schedule-easing.pl ↑ Summary lib/Schedule/Easing/MD5.pm »
1 package Schedule::Easing::Ease;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use Carp qw/carp confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Scalar::Util qw/looks_like_number/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 ▶use Schedule::Easing::Function;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6 our $VERSION='0.1.5';
11  
12 70 ▶sub _default_keys { return qw/name match begin final tsA tsB shape shapeopt _warnExpired/ }
Subroutine _default_keys: called CC=1 SCAR=0.0
13 70 ▶sub _default {
Subroutine _default: called CC=1 SCAR=0.0
14 return (
15 70 name =>undef,
16 match=>qr/./,
17 begin=>0,
18 final=>1,
19 tsA =>0,
20 tsB =>1,
21 shape=>'linear',
22 shapeopt=>[],
23 _warnExpired=>0,
24 );
25 }
26  
27 19 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
28 19 my ($ref,%opt)=@_;
29 19 ▶ my $class=ref($ref)||$ref;
Condition66%2/3
ref $ref || $ref
l!l&&r!l&&!r
2170
MC/DC0%0/2
ref $ref || $ref
ref $ref $ref
Truth table66%2/3
A || B
A= ref $refB= $ref
ABresult
1X1
011
000
30 my %self=(
31 $class->_default(),
32 (ref($ref)?%$ref:()),
33 19 ▶ map {$_=>$opt{$_}} grep {defined($opt{$_})} $class->_default_keys()
Branch: 1 branch
BranchTrueFalseTotal
ref $ref ? : 2 17 19
34 );
35 19 return bless(\%self,$class)->validate()->init();
36 }
37  
38 70 ▶sub validate {
Subroutine validate: called CC=14 SCAR=26.5
Pod undocumented
39 70 my ($self)=@_;
40 70 foreach my $k (qw/tsA tsB begin final/) {
41 0 ▶ if(!defined($$self{$k})) { confess("Must be defined: $k") }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{$k}) 0 268 268
42 268 ▶ if(!looks_like_number($$self{$k})) { confess("Must be numeric: $k") }
Branch: 1 branch
BranchTrueFalseTotal
unless (&looks_like_number($self->{$k})) 8 260 268
43 }
44 62 ▶ if(ref($$self{match}) ne 'Regexp') { confess('Must be Regexp: match') }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"match"} ne "Regexp") 3 59 62
45 0 ▶ if(ref($$self{name})) { confess('Must be string: name') }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"name"}) 0 59 59
46 59 foreach my $k (qw/begin final/) {
47 118 ▶ if($$self{$k}<0) { $$self{$k}=0; carp("$k<0"); $$self{_err}=1 }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$k} < 0) 1 117 118
48 118 ▶ if($$self{$k}>1) { $$self{$k}=1; carp("$k>1"); $$self{_err}=1 }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$k} > 1) 1 117 118
49 }
50 59 ▶ if($$self{tsA}>=$$self{tsB}) { $$self{tsB}=1+$$self{tsA}; carp('tsA>=tsB'); $$self{_err}=1 }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tsA"} >= $self->{"tsB"}) 1 58 59
51 59 ▶ if($$self{_warnExpired}&&($$self{tsB}<time())&&(abs(0.5-$$self{final})>=0.5)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_warnExpired"} and $self->{"tsB"} < time and abs "0.5" - $self->{"final"} >= "0.5") 2 57 59
Condition83%5/6
$self->{"_warnExpired"} and $self->{"tsB"} < time and abs "0.5" - $self->{"final"} >= "0.5"
!ll&&!rl&&r
5612
$self->{"_warnExpired"} and $self->{"tsB"} < time
!ll&&!rl&&r
5603
MC/DC66%2/3
$self->{"_warnExpired"} and $self->{"tsB"} < time and abs "0.5" - $self->{"final"} >= "0.5"
$self->{"_warnExpired"} $self->{"tsB"} < time abs "0.5" - $self->{"final"} >= "0.5"
Truth table75%3/4
A and B and C
A= $self->{"_warnExpired"}B= $self->{"tsB"} < timeC= abs "0.5" - $self->{"final"} >= "0.5"
ABCresult
0XX0
10X0
1100
1111
52 2 ▶ if($$self{name}) { carp("Event has expired: $$self{name}"); $$self{_err}=1 }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'name'}) { } 1 1 2
53 1 else { carp("Event with tsB=$$self{tsB} has expired"); $$self{_err}=1 }
54 }
55 59 $$self{_shaper} =Schedule::Easing::Function::shape($$self{shape});
56 59 $$self{_unshaper}=Schedule::Easing::Function::inverse($$self{shape});
57 59 return $self;
58 }
59  
60 55 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
61 55 my ($self)=@_;
62 55 $$self{tsrange}=int($$self{tsB}-$$self{tsA});
63 55 return $self;
64 }
65  
66 0 ▶sub includes { die 'Abstract' }
Subroutine includes: not called CC=1 SCAR=6.9
Pod undocumented
67 0 ▶sub schedule { die 'Abstract' }
Subroutine schedule: not called CC=1 SCAR=6.9
Pod undocumented
68  
69 250087 ▶sub matches {
Subroutine matches: called CC=2 SCAR=6.9
Pod undocumented
70 250087 my ($self,$message)=@_;
71 250087 ▶ if($message=~$$self{match}) { return (matched=>1,%+) }
Branch: 1 branch
BranchTrueFalseTotal
if ($message =~ /$self->{"match"}/) 250026 61 250087
72 61 return;
73 }
74  
75 6 1;
« script/schedule-easing.pl ↑ Summary lib/Schedule/Easing/MD5.pm »