File Coverage

lib/Spreadsheet/Engine/Fn/counter.pm
Criterion Covered Total %
statement 18 18 100.0
branch 3 4 75.0
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 28 29 96.5


line stmt bran cond sub pod time code
1             package Spreadsheet::Engine::Fn::counter;
2              
3 28     28   173 use strict;
  28         61  
  28         961  
4 28     28   150 use warnings;
  28         60  
  28         728  
5              
6 28     28   345 use base 'Spreadsheet::Engine::Fn::base';
  28         129  
  28         6160  
7              
8 169     169 1 378 sub argument_count { -1 }
9              
10             sub result {
11 162     162 1 251 my $self = shift;
12              
13 162 50       436 return unless defined(my $foperand = $self->foperand);
14              
15 162         654 my $match = $self->calculate;
16 162         254 my $count = 0;
17              
18 162         201 while (@{$foperand}) {
  826         9344  
19 664 100       1890 $count++ if $match->($self->next_operand);
20             }
21              
22 162         3643 return Spreadsheet::Engine::Value->new(type => 'n', value => $count);
23             }
24              
25             1;
26              
27             __END__