blib/lib/Dallycot/AST/Condition.pm

filter: Statementstmt 91.4% 43 / 47 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 78.5% 11 / 14 Podpod 0.0% 0 / 3 totaltotal 84.7% 61 / 72 CC 5 SCAR 5.5
CC
5
Cov
91%
process_loop
3.1
__ANON__
2.0
_case_to_rdf
2.0
CRAP 1.7
« blib/lib/Dallycot/Resolver.pm ↑ Summary blib/lib/Dallycot/TextResolver.pm »
1 package Dallycot::AST::Condition;
2 29 our $AUTHORITY = 'cpan:JSMITH';
3  
4 # ABSTRACT: Select an expression based on guards
5  
6 29 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 29 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 29 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 29 ▶use parent 'Dallycot::AST::LoopBase';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub to_rdf {
13 1 ▶ my($self, $model) = @_;
Subroutine to_rdf: called CC=1 SCAR=0.0
Pod undocumented
14  
15 1 my $bnode = $model -> bnode;
16 1 $model -> add_type($bnode, 'loc:GuardedSequence');
17 $model -> add_list($bnode, 'loc:expressions',
18 map {
19 1 $self->_case_to_rdf($model, $_)
20 } @$self
21 );
22  
23 1 return $bnode;
24 }
25  
26 sub _case_to_rdf {
27 2 ▶ my($self, $model, $cond) = @_;
Subroutine _case_to_rdf: called CC=2 SCAR=6.9
28  
29 2 my $expr = $cond->[1]->to_rdf($model);
30 2 ▶ if(defined $cond->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cond->[0]) 1 1 2
31 1 $expr = $model -> add_connection(
32 $expr,
33 'loc:guard',
34 $cond->[0]->to_rdf($model)
35 );
36 }
37 2 return $expr;
38 }
39  
40 sub child_nodes {
41 121 ▶ my ($self) = @_;
Subroutine child_nodes: called CC=1 SCAR=0.0
Pod undocumented
42  
43 121 return grep {defined} map { @{$_} } @{$self};
44 }
45  
46 sub process_loop {
47 478 ▶ my ( $self, $engine, $d, $condition, @expressions ) = @_;
Subroutine process_loop: called CC=3 SCAR=11.3
Pod undocumented
48  
49 478 ▶ if ($condition) {
Branch: 1 branch
BranchTrueFalseTotal
if ($condition) { } 478 0 478
50 478 ▶ if ( defined $condition->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $condition->[0]) { } 429 49 478
51 $engine->execute( $condition->[0], ['Boolean'] )->done(
52 sub {
53 425 ▶ my ($flag) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
54 425 ▶ if ( $flag->value ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($flag->value) { } 362 63 425
55 $engine->execute( $condition->[1] )->done(
56 sub {
57 359 ▶ $d->resolve(@_);
Subroutine __ANON__: called CC=1 SCAR=0.0
58 },
59 sub {
60 0 ▶ $d->reject(@_);
Subroutine __ANON__: not called CC=1 SCAR=6.9
61 }
62 362 );
63 }
64 else {
65 63 $self->process_loop( $engine, $d, @expressions );
66 }
67 },
68 sub {
69 0 ▶ $d->reject(@_);
Subroutine __ANON__: not called CC=1 SCAR=6.9
70 }
71 429 );
72 }
73 else {
74 $engine->execute( $condition->[1] )->done(
75 sub {
76 48 ▶ $d->resolve(@_);
Subroutine __ANON__: called CC=1 SCAR=0.0
77 },
78 sub {
79 0 ▶ $d->reject(@_);
Subroutine __ANON__: not called CC=1 SCAR=6.9
80 }
81 49 );
82 }
83 }
84 else {
85 0 $d->resolve( $engine->UNDEFINED );
86 }
87  
88 478 return;
89 }
90  
91 29 1;
« blib/lib/Dallycot/Resolver.pm ↑ Summary blib/lib/Dallycot/TextResolver.pm »