File Coverage

blib/lib/Dallycot/Value/OpenRange.pm
Criterion Covered Total %
statement 15 46 32.6
branch 0 2 0.0
condition n/a
subroutine 5 21 23.8
pod 0 7 0.0
total 20 76 26.3


line stmt bran cond sub pod time code
1             package Dallycot::Value::OpenRange;
2             our $AUTHORITY = 'cpan:JSMITH';
3              
4             # ABSTRACT: An open range (semi-infinite) of integers
5              
6 23     23   13260 use strict;
  23         45  
  23         773  
7 23     23   105 use warnings;
  23         35  
  23         534  
8              
9             # No RDF equivalent - continuous list generation of items
10              
11 23     23   97 use utf8;
  23         29  
  23         122  
12 23     23   584 use parent 'Dallycot::Value::Collection';
  23         28  
  23         119  
13              
14 23     23   1420 use Promises qw(deferred);
  23         42  
  23         225  
15              
16 0     0     sub _type { return 'Range' }
17              
18             sub as_text {
19 0     0 0   my ($self) = @_;
20              
21 0           return $self->[0]->as_text . "..";
22             }
23              
24 0     0 0   sub is_empty {return}
25              
26             sub calculate_length {
27 0     0 0   my ( $self, $engine ) = @_;
28              
29 0           return Dallycot::Value::Numeric->new( Math::BigRat->binf() );
30             }
31              
32             sub head {
33 0     0 0   my ($self) = @_;
34              
35 0           my $d = deferred;
36              
37 0           $d->resolve( $self->[0] );
38              
39 0           return $d->promise;
40             }
41              
42             sub tail {
43 0     0 0   my ($self) = @_;
44              
45             return $self->[0]->successor->then(
46             sub {
47 0     0     my ($next) = @_;
48              
49 0           bless [$next] => __PACKAGE__;
50             }
51 0           );
52             }
53              
54             sub _walk_tail {
55 0     0     my ( $self, $engine, $d, $count ) = @_;
56              
57 0 0         if ( $count > 0 ) {
58             $self->tail($engine)->done(
59             sub {
60 0     0     my ($tail) = @_;
61 0           $tail->_walk_tail( $engine, $d, $count - 1 );
62             },
63             sub {
64 0     0     $d->reject(@_);
65             }
66 0           );
67             }
68             else {
69             $self->head($engine)->done(
70             sub {
71 0     0     $d -> resolve(@_);
72             },
73             sub {
74 0     0     $d -> reject(@_);
75             }
76 0           );
77             }
78             }
79              
80             sub apply_map {
81 0     0 0   my ( $self, $engine, $transform ) = @_;
82              
83             return $engine->make_map($transform)->then(
84             sub {
85 0     0     my ($map_t) = @_;
86              
87 0           return $map_t->apply( $engine, {}, $self );
88             }
89 0           );
90             }
91              
92             sub apply_filter {
93 0     0 0   my ( $self, $engine, $filter ) = @_;
94              
95             return $engine->make_filter($filter)->then(
96             sub {
97 0     0     my ($filter_t) = @_;
98              
99 0           $filter_t->apply( $engine, {}, $self );
100             }
101 0           );
102             }
103              
104             1;