blib/lib/Event/timer.pm

filter: Statementstmt 94.7% 36 / 38 Branchbran 77.7% 14 / 18 Conditioncond 80.0% 4 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 85.7% 60 / 70 CC 13 SCAR 23.6
CC
13
Cov
89%
new
13.6
BEGIN
1.0
BEGIN
1.0
CRAP 10.6
↑ Summary blib/lib/Event/type.pm »
1 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Event::timer;
3 25 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 25 ▶use base 'Event::Watcher';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 25 ▶use vars qw(@ATTRIBUTE);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 25 @ATTRIBUTE = qw(at hard interval);
8  
9 25 'Event::Watcher'->register;
10  
11 46 ▶sub new {
Subroutine new: called CC=13 SCAR=26.1
Pod undocumented
12 # lock %Event::;
13 46 my $class = shift;
14 46 my %arg = @_;
15 46 ▶ my $o = allocate($class, delete $arg{attach_to} || {});
Condition100%2/2
delete $arg{'attach_to'} || {}
l!l
244
MC/DC100%1/1
delete $arg{'attach_to'} || {}
delete $arg{'attach_to'}
Truth table100%2/2
A
A= delete $arg{'attach_to'}
Aresult
11
00
16  
17 # deprecated
18 45 for (qw(at after interval repeat)) {
19 180 ▶ if (exists $arg{"e_$_"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $arg{"e_$_"}) 0 180 180
20 0 carp "'e_$_' is renamed to '$_'";
21 0 $arg{$_} = delete $arg{"e_$_"};
22 }
23 }
24  
25 45 my $has_at = exists $arg{at};
26 45 my $has_after = exists $arg{after};
27  
28 45 ▶ croak "'after' and 'at' are mutually exclusive"
Branch: 1 branch
BranchTrueFalseTotal
if $has_at and $has_after 0 45 45
Condition66%2/3
$has_at and $has_after
!ll&&!rl&&r
4410
MC/DC0%0/2
$has_at and $has_after
$has_at $has_after
Truth table66%2/3
A and B
A= $has_atB= $has_after
ABresult
0X0
100
111
29 if $has_at && $has_after;
30  
31 45 ▶ if ($has_after) {
Branch: 2 branches
BranchTrueFalseTotal
if ($has_after) { } 39 6 45
elsif ($has_at) { } 1 5 6
32 39 my $after = delete $arg{after};
33 39 $o->at(Event::time() + $after);
34 39 $has_at=1;
35 39 ▶ $o->interval($after) if !exists $arg{interval};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $arg{"interval"} 38 1 39
36 } elsif ($has_at) {
37 1 $o->at(delete $arg{at});
38 }
39 45 ▶ if (exists $arg{interval}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $arg{"interval"}) 3 42 45
40 3 my $i = delete $arg{interval};
41 3 ▶ $o->at(Event::time() + (ref $i? $$i : $i)) unless $has_at;
Branch: 2 branches
BranchTrueFalseTotal
unless $has_at 2 1 3
ref $i ? : 0 2 2
42 3 $o->interval($i);
43 3 ▶ $o->repeat(1) unless exists $arg{repeat};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $arg{"repeat"} 3 0 3
44 }
45  
46 45 $o->init(\%arg);
47 43 $o;
48 }
49  
50 25 1;
↑ Summary blib/lib/Event/type.pm »