File Coverage

lib/Spreadsheet/Engine/Fn/series.pm
Criterion Covered Total %
statement 27 27 100.0
branch 4 4 100.0
condition 9 10 90.0
subroutine 7 7 100.0
pod 4 4 100.0
total 51 52 98.0


line stmt bran cond sub pod time code
1             package Spreadsheet::Engine::Fn::series;
2              
3 28     28   625 use strict;
  28         64  
  28         1080  
4 28     28   150 use warnings;
  28         61  
  28         708  
5              
6 28     28   149 use base 'Spreadsheet::Engine::Fn::base';
  28         59  
  28         9624  
7              
8 1406     1406 1 3429 sub argument_count { -1 }
9              
10             sub result {
11 1333     1333 1 2310 my $self = shift;
12 1333         2423 my $type = '';
13 1333         5678 my $calculator = $self->calculate;
14 1333         4198 my $accumulator = $self->accumulator;
15              
16 1333         3550 my $foperand = $self->foperand;
17 1333         2143 while (@{$foperand}) {
  5183         100456  
18 3850         10721 my $op = $self->next_operand;
19 3850 100 100     96245 if ($op->is_num) {
    100          
20 3103         28751 $accumulator = $calculator->($op, $accumulator);
21 3103   66     36596 $type = $self->optype(plus => $op, $type || $op)->type;
22             } elsif ($op->is_error && substr($type, 0, 1) ne 'e') {
23 52         1583 $type = $op->type;
24             }
25             }
26 1333   100     4703 my $result = $self->result_from($accumulator) || 0;
27              
28 1294   100     30263 return Spreadsheet::Engine::Value->new(
29             type => $type || 'n',
30             value => $result
31             );
32             }
33              
34 554     554 1 1041 sub accumulator { undef }
35              
36             sub result_from {
37 1098     1098 1 2026 my ($self, $accumulator) = @_;
38 1098         3701 return $accumulator;
39             }
40              
41             1;
42              
43             __END__