blib/lib/Dallycot/AST/Compose.pm

filter: Statementstmt 83.8% 26 / 31 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 2 totaltotal 76.0% 35 / 46 CC 3 SCAR 6.1
CC
3
Cov
80%
__ANON__
3.4
to_rdf
2.0
__ANON__
2.0
CRAP 1.8
« blib/lib/Dallycot/AST/Index.pm ↑ Summary blib/lib/Dallycot/Resolver.pm »
1 package Dallycot::AST::Compose;
2 29 our $AUTHORITY = 'cpan:JSMITH';
3  
4 # ABSTRACT: Compose lambdas into a new lambda
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';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 29 ▶use Promises qw(deferred);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub to_rdf {
15 0 ▶ my($self, $model) = @_;
Subroutine to_rdf: not called CC=1 SCAR=6.9
Pod undocumented
16  
17 0 return $model -> apply(
18 $model -> meta_uri('loc:compose'),
19 [ @$self ],
20 {}
21 );
22 # my $bnode = $model -> bnode;
23 # $model -> add_type($bnode, 'loc:Composition');
24 # $model -> add_list($bnode, 'loc:expressions',
25 # map { $_ -> to_rdf($model) } @{$self}
26 # );
27 #
28 # return $bnode;
29 }
30  
31 sub execute {
32 18 ▶ my ( $self, $engine ) = @_;
Subroutine execute: called CC=1 SCAR=0.3
Pod undocumented
33  
34 18 my $d = deferred;
35  
36 $engine->collect(@$self)->done(
37 sub {
38 18 ▶ my (@functions) = @_;
Subroutine __ANON__: called CC=3 SCAR=12.3
39 18 ▶ if ( grep { !$_->isa('Dallycot::Value::Lambda') } @functions ) {
Branch: 2 branches
BranchTrueFalseTotal
if (grep {not $_->isa('Dallycot::Value::Lambda');} @functions) { } 0 18 18
elsif (grep {1 != $_->min_arity;} @functions) { } 0 18 18
40 0 $d->reject("All terms in a function composition must be lambdas");
41 }
42 37 elsif ( grep { 1 != $_->min_arity } @functions ) {
43 0 $d->reject("All lambdas in a function composition must have arity 1");
44 }
45 else {
46 18 $d->resolve( $engine->compose_lambdas(@functions) );
47 }
48 },
49 sub {
50 0 ▶ $d->reject(@_);
Subroutine __ANON__: not called CC=1 SCAR=6.9
51 }
52 18 );
53  
54 18 return $d->promise;
55 }
56  
57 29 1;
« blib/lib/Dallycot/AST/Index.pm ↑ Summary blib/lib/Dallycot/Resolver.pm »