File Coverage

blib/lib/Dallycot/AST/PropWalk.pm
Criterion Covered Total %
statement 15 40 37.5
branch 0 12 0.0
condition n/a
subroutine 5 11 45.4
pod 0 3 0.0
total 20 66 30.3


line stmt bran cond sub pod time code
1             package Dallycot::AST::PropWalk;
2             our $AUTHORITY = 'cpan:JSMITH';
3              
4             # ABSTRACT: Manages traversal of a graph
5              
6 23     23   16955 use strict;
  23         45  
  23         845  
7 23     23   99 use warnings;
  23         31  
  23         490  
8              
9 23     23   86 use utf8;
  23         30  
  23         107  
10 23     23   526 use parent 'Dallycot::AST::LoopBase';
  23         33  
  23         107  
11              
12 23     23   1226 use Promises qw(collect deferred);
  23         29  
  23         119  
13              
14 0     0 0   sub to_string {
15              
16             }
17              
18             sub execute {
19 0     0 0   my ( $self, $engine ) = @_;
20              
21 0           my ( $root_expr, @steps ) = @$self;
22              
23             return $engine->execute($root_expr)->then(
24             sub {
25 0     0     my ($root) = [@_];
26              
27 0 0         if (@steps) {
    0          
28 0           my $d = deferred;
29 0           $self->process_loop( $engine, $d, root => $root, steps => \@steps );
30 0           return $d;
31             }
32             elsif ( @$root > 1 ) {
33 0           return bless $root => "Dallycot::Value::Set";
34             }
35             else {
36 0           return @$root;
37             }
38             }
39 0           );
40             }
41              
42             sub process_loop {
43 0     0 0   my ( $self, $engine, $d, %state ) = @_;
44              
45 0 0         my ( $root, $step, @steps ) = ( $state{root}, @{ $state{steps} || [] } );
  0            
46              
47 0           collect( map { $step->step( $engine, $_ ) } @$root )->done(
48             sub {
49 0     0     my (@results) = map {@$_} @_;
  0            
50 0 0         if (@steps) {
    0          
    0          
51 0           $self->process_loop( $engine, $d, root => \@results, steps => \@steps );
52             }
53             elsif ( @results > 1 ) {
54 0           $d->resolve( bless \@results => "Dallycot::Value::Set" );
55             }
56             elsif ( @results == 1 ) {
57 0           $d->resolve(@results);
58             }
59             else {
60 0           $d->resolve( $engine->UNDEFINED );
61             }
62             },
63             sub {
64 0     0     $d->reject(@_);
65             }
66 0           );
67              
68 0           return;
69             }
70              
71             1;