blib/lib/Dallycot/AST/Lambda.pm

filter: Statementstmt 93.2% 55 / 59 Branchbran 50.0% 3 / 6 Conditioncond 44.4% 4 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 4 totaltotal 77.6% 73 / 94 CC 9 SCAR 10.6
CC
9
Cov
84%
new
5.9
child_nodes
3.3
_binding_rdf
2.0
CRAP 2.9
« blib/lib/Dallycot/Value/Boolean.pm ↑ Summary blib/lib/Dallycot/Value/URI.pm »
1 package Dallycot::AST::Lambda;
2 29 our $AUTHORITY = 'cpan:JSMITH';
3  
4 # ABSTRACT: Create a lambda value with a closure environment
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 29 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 29 Readonly my $EXPRESSION => 0;
17 29 Readonly my $BINDINGS => 1;
18 29 Readonly my $BINDINGS_WITH_DEFAULTS => 2;
19 29 Readonly my $OPTIONS => 3;
20  
21 sub new {
22 1 ▶ my ( $self, $expr, $bindings, $bindings_with_defaults, $options ) = @_;
Subroutine new: called CC=5 SCAR=17.8
Pod undocumented
23  
24 1 ▶ my $class = ref $self || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
25 1 ▶ $bindings ||= [];
Condition50%1/2
$bindings ||= []
l!l
01
MC/DC0%0/1
$bindings ||= []
$bindings
Truth table50%1/2
A
A= $bindings
Aresult
11
00
26 1 ▶ $bindings_with_defaults ||= [];
Condition50%1/2
$bindings_with_defaults ||= []
l!l
01
MC/DC0%0/1
$bindings_with_defaults ||= []
$bindings_with_defaults
Truth table50%1/2
A
A= $bindings_with_defaults
Aresult
11
00
27 1 ▶ $options ||= {};
Condition50%1/2
$options ||= {}
l!l
01
MC/DC0%0/1
$options ||= {}
$options
Truth table50%1/2
A
A= $options
Aresult
11
00
28  
29 1 return bless [ $expr, $bindings, $bindings_with_defaults, $options ] => $class;
30 }
31  
32 sub to_rdf {
33 2 ▶ my($self, $model) = @_;
Subroutine to_rdf: called CC=2 SCAR=7.0
Pod undocumented
34  
35 2 my $bnode = $model -> bnode;
36 2 $model -> add_type($bnode, 'loc:Algorithm');
37 2 $model -> add_expression($bnode, $self -> [$EXPRESSION]);
38 $model -> add_list(
39 $bnode, 'loc:bindings',
40 3 (map { $self -> _binding_rdf($model, $_) } @{$self->[$BINDINGS]}),
41 2 (map { $self -> _binding_rdf($model, @$_) } @{$self->[$BINDINGS_WITH_DEFAULTS]})
42 );
43 2 foreach my $opt(keys %{$self->[$OPTIONS]}) {
44 $model -> add_option(
45 $bnode,
46 $opt,
47 0 $self->[$OPTIONS]->{$opt}->to_rdf($model)
48 );
49 }
50 2 return $bnode;
51 }
52  
53 sub _binding_rdf {
54 3 ▶ my($self, $model, $label, $expr) = @_;
Subroutine _binding_rdf: called CC=2 SCAR=7.1
55  
56 3 my $bnode = $model -> bnode;
57 3 $model -> add_type($bnode, 'loc:Binding');
58 3 $model -> add_label($bnode, $label);
59 3 ▶ if(defined $expr) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $expr) 0 3 3
60 0 $model -> add_expression($bnode, $expr);
61 }
62 3 return $bnode;
63 }
64  
65 sub child_nodes {
66 81 ▶ my ($self) = @_;
Subroutine child_nodes: called CC=3 SCAR=12.0
Pod undocumented
67 return $self->[$EXPRESSION],
68 0 ▶ ( map { $_->[1] } @{ $self->[$BINDINGS_WITH_DEFAULTS] || [] } ),
Branch: 1 branch
BranchTrueFalseTotal
$self->[$BINDINGS_WITH_DEFAULTS] or [] 0 81 81
69 81 ▶ ( values %{ $self->[$OPTIONS] || {} } );
Branch: 1 branch
BranchTrueFalseTotal
$self->[$OPTIONS] or {} 0 81 81
70 }
71  
72 sub execute {
73 364 ▶ my ( $self, $engine ) = @_;
Subroutine execute: called CC=1 SCAR=0.0
Pod undocumented
74  
75 364 my $d = deferred;
76  
77 364 $d->resolve( $engine->make_lambda(@$self) );
78  
79 364 return $d->promise;
80 }
81  
82 29 1;
« blib/lib/Dallycot/Value/Boolean.pm ↑ Summary blib/lib/Dallycot/Value/URI.pm »