blib/lib/Dallycot/Value/OpenRange.pm

filter: Statementstmt 62.5% 30 / 48 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 52.3% 11 / 21 Podpod 0.0% 0 / 7 totaltotal 52.5% 41 / 78 CC 2 SCAR 6.2
CC
2
Cov
60%
_walk_tail
6.0
_type
2.0
as_text
2.0
CRAP 1.9
« blib/lib/Dallycot/AST/Invert.pm ↑ Summary blib/lib/Dallycot/AST/Index.pm »
1 package Dallycot::Value::OpenRange;
2 30 our $AUTHORITY = 'cpan:JSMITH';
3  
4 # ABSTRACT: An open range (semi-infinite) of integers
5  
6 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 30 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # No RDF equivalent - continuous list generation of items
10  
11 30 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 30 ▶use parent 'Dallycot::Value::Collection';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 30 ▶use Promises qw(deferred);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 0 ▶sub _type { return 'Range' }
Subroutine _type: not called CC=1 SCAR=6.9
17  
18 sub as_text {
19 0 ▶ my ($self) = @_;
Subroutine as_text: not called CC=1 SCAR=6.9
Pod undocumented
20  
21 0 return $self->[0]->as_text . "..";
22 }
23  
24 57 ▶sub is_empty {return}
Subroutine is_empty: called CC=1 SCAR=0.0
Pod undocumented
25  
26 sub calculate_length {
27 0 ▶ my ( $self, $engine ) = @_;
Subroutine calculate_length: not called CC=1 SCAR=6.9
Pod undocumented
28  
29 0 return Dallycot::Value::Numeric->new( Math::BigRat->binf() );
30 }
31  
32 sub head {
33 61 ▶ my ($self) = @_;
Subroutine head: called CC=1 SCAR=0.0
Pod undocumented
34  
35 61 my $d = deferred;
36  
37 61 $d->resolve( $self->[0] );
38  
39 61 return $d->promise;
40 }
41  
42 sub tail {
43 35 ▶ my ($self) = @_;
Subroutine tail: called CC=1 SCAR=0.0
Pod undocumented
44  
45 return $self->[0]->successor->then(
46 sub {
47 35 ▶ my ($next) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
48  
49 35 bless [$next] => __PACKAGE__;
50 }
51 35 );
52 }
53  
54 sub _walk_tail {
55 0 ▶ my ( $self, $engine, $d, $count ) = @_;
Subroutine _walk_tail: not called CC=2 SCAR=17.9
56  
57 0 ▶ if ( $count > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count > 0) { } 0 0 0
58 $self->tail($engine)->done(
59 sub {
60 0 ▶ my ($tail) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
61 0 $tail->_walk_tail( $engine, $d, $count - 1 );
62 },
63 sub {
64 0 ▶ $d->reject(@_);
Subroutine __ANON__: not called CC=1 SCAR=6.9
65 }
66 0 );
67 }
68 else {
69 $self->head($engine)->done(
70 sub {
71 0 ▶ $d -> resolve(@_);
Subroutine __ANON__: not called CC=1 SCAR=6.9
72 },
73 sub {
74 0 ▶ $d -> reject(@_);
Subroutine __ANON__: not called CC=1 SCAR=6.9
75 }
76 0 );
77 }
78 }
79  
80 sub apply_map {
81 28 ▶ my ( $self, $engine, $transform ) = @_;
Subroutine apply_map: called CC=1 SCAR=0.0
Pod undocumented
82  
83 return $engine->make_map($transform)->then(
84 sub {
85 26 ▶ my ($map_t) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
86  
87 26 return $map_t->apply( $engine, {}, $self );
88 }
89 28 );
90 }
91  
92 sub apply_filter {
93 0 ▶ my ( $self, $engine, $filter ) = @_;
Subroutine apply_filter: not called CC=1 SCAR=6.9
Pod undocumented
94  
95 return $engine->make_filter($filter)->then(
96 sub {
97 0 ▶ my ($filter_t) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
98  
99 0 $filter_t->apply( $engine, {}, $self );
100 }
101 0 );
102 }
103  
104 30 1;
« blib/lib/Dallycot/AST/Invert.pm ↑ Summary blib/lib/Dallycot/AST/Index.pm »