ES6/EventLoopBase.pm

filter: Statementstmt 27.0% 10 / 37 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 21.4% 3 / 14 Podpod 0.0% 0 / 3 totaltotal 23.2% 13 / 56 CC 2 SCAR 8.5
CC
2
Cov
26%
__ANON__
6.0
new
2.0
_create_postpone_cb
2.0
CRAP 2.3
« ES6/Future.pm ↑ Summary ES6.pm »
1 package Promise::ES6::EventLoopBase;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use parent qw(Promise::ES6);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
9 0 my ($class, $cr) = @_;
10  
11 0 ▶ return $class->SUPER::new( sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
12 0 my ($res, $rej) = @_;
13  
14 0 local $@;
15  
16 0 my $rej_pp = $class->_create_postpone_cb($rej);
17  
18 0 my $ok = eval {
19 0 $cr->(
20 $class->_create_postpone_cb($res),
21 $rej_pp,
22 );
23  
24 0 1;
25 };
26  
27 0 ▶ if (!$ok) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ok) 0 0 0
28 0 $rej_pp->( my $err = $@ );
29 }
30 0 } );
31 }
32  
33 0 ▶sub _create_postpone_cb {
Subroutine _create_postpone_cb: not called CC=1 SCAR=6.9
34 0 my ($class, $cr) = @_;
35  
36 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
37 0 my ($arg) = @_;
38 0 ▶ $class->_postpone( sub { $cr->($arg) } );
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 },
40 0 }
41  
42 0 ▶sub then {
Subroutine then: not called CC=1 SCAR=6.9
Pod undocumented
43 0 my ($self, $on_res, $on_rej) = @_;
44  
45 0 my $class = ref $self;
46  
47 0 ▶ return $class->new( sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
48 0 my ($y, $n) = @_;
49  
50 0 ▶ $class->_postpone( sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
51 0 $self->SUPER::then($on_res, $on_rej)->SUPER::then($y, $n);
52 0 } );
53 0 } );
54 }
55  
56 0 ▶sub finally {
Subroutine finally: not called CC=1 SCAR=6.9
Pod undocumented
57 0 my ($self, $on_finish) = @_;
58  
59 0 my $class = ref $self;
60  
61 0 ▶ return $class->new( sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
62 0 my ($y, $n) = @_;
63  
64 0 ▶ $class->_postpone( sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
65 0 $self->SUPER::finally($on_finish)->SUPER::then($y, $n);
66 0 } );
67 0 } );
68 }
69  
70 1 1;
« ES6/Future.pm ↑ Summary ES6.pm »