File Coverage

lib/Spreadsheet/Engine/Function/VALUE.pm
Criterion Covered Total %
statement 20 22 90.9
branch 4 6 66.6
condition 1 3 33.3
subroutine 6 6 100.0
pod 2 2 100.0
total 33 39 84.6


line stmt bran cond sub pod time code
1             package Spreadsheet::Engine::Function::VALUE;
2              
3 28     28   152 use strict;
  28         61  
  28         911  
4 28     28   217 use warnings;
  28         58  
  28         747  
5              
6 28     28   142 use base 'Spreadsheet::Engine::Fn::base';
  28         59  
  28         2787  
7              
8 28     28   173 use Spreadsheet::Engine::Sheet qw/determine_value_type/;
  28         243  
  28         6947  
9              
10 298     298 1 809 sub argument_count { 1 }
11              
12             sub result {
13 291     291 1 473 my $self = shift;
14 291         910 my $op = $self->next_operand;
15              
16 291 50 33     9544 if ($op->is_num || $op->is_blank) {
17 0         0 return Spreadsheet::Engine::Value->new(type => 'n', value => $op->value);
18             }
19              
20             # TODO: make this a Value
21 291 50       3392 if ($op->is_txt) {
22 291         9097 my $result = determine_value_type($op->value, \my $type);
23 291 100       1468 die Spreadsheet::Engine::Error->val if substr($type, 0, 1) ne 'n';
24 251         7269 return Spreadsheet::Engine::Value->new(type => 'n', value => $result);
25             }
26              
27 0           die Spreadsheet::Engine::Error->val;
28              
29             }
30              
31             1;
32              
33             __END__