File Coverage

lib/Spreadsheet/Engine/Function/EVEN.pm
Criterion Covered Total %
statement 17 17 100.0
branch 6 6 100.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 28 28 100.0


line stmt bran cond sub pod time code
1             package Spreadsheet::Engine::Function::EVEN;
2              
3 28     28   156 use strict;
  28         60  
  28         1000  
4 28     28   148 use warnings;
  28         66  
  28         747  
5              
6 28     28   151 use base 'Spreadsheet::Engine::Fn::math';
  28         59  
  28         5652  
7              
8             sub calculate {
9 405     405 1 13731 my ($self, $value) = @_;
10 405 100       1286 my $result = $value < 0 ? -$value : $value;
11 405         906 my $extra = $result - int($result);
12 405 100       1044 if ($extra) {
13 132         524 $result = int($result + 1) + (($result + 1) % 2);
14             } else { # integer
15 273         764 $result = $result + ($result % 2);
16             }
17 405 100       1385 $result = -$result if $value < 0;
18 405         8421 return $result;
19             }
20              
21             1;
22              
23             __END__