File Coverage

blib/lib/Dallycot/AST/ForwardWalk.pm
Criterion Covered Total %
statement 15 25 60.0
branch 0 4 0.0
condition n/a
subroutine 5 7 71.4
pod 0 1 0.0
total 20 37 54.0


line stmt bran cond sub pod time code
1             package Dallycot::AST::ForwardWalk;
2             our $AUTHORITY = 'cpan:JSMITH';
3              
4             # ABSTRACT: Find the value associated with a property of a subject
5              
6 23     23   11926 use strict;
  23         38  
  23         702  
7 23     23   89 use warnings;
  23         31  
  23         521  
8              
9 23     23   81 use utf8;
  23         31  
  23         93  
10 23     23   428 use parent 'Dallycot::AST';
  23         31  
  23         98  
11              
12 23     23   1138 use Promises qw(deferred);
  23         32  
  23         103  
13              
14             sub step {
15 0     0 0   my ( $self, $engine, $root ) = @_;
16              
17             return $engine->execute( $self->[0] )->then(
18             sub {
19 0     0     my ($prop_name) = @_;
20 0           my $prop = $prop_name->value;
21              
22 0 0         return $root->type if $prop eq '@type';
23              
24             return $root->fetch_property( $engine, $prop )->then(
25             sub {
26 0           my (@results) = @_;
27              
28 0 0         if ( @results != 1 ) {
29 0           return Dallycot::Value::Set->new(@results);
30             }
31             else {
32 0           return @results;
33             }
34             }
35 0           );
36             }
37 0           );
38             }
39              
40             1;