File Coverage

lib/Spreadsheet/Engine/Function/EXACT.pm
Criterion Covered Total %
statement 24 24 100.0
branch 15 20 75.0
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 46 51 90.2


line stmt bran cond sub pod time code
1             package Spreadsheet::Engine::Function::EXACT;
2              
3 28     28   159 use strict;
  28         66  
  28         919  
4 28     28   149 use warnings;
  28         58  
  28         837  
5              
6 28     28   189 use base 'Spreadsheet::Engine::Fn::logical';
  28         63  
  28         9303  
7              
8 552     552 1 1434 sub argument_count { 2 }
9              
10             sub calculate {
11 552     552 1 1091 my $self = shift;
12              
13             # Sort values by type so we only need to compare in one direction
14 552         24952 my ($X, $Y) =
15 552         1887 sort { $a->type cmp $b->type } ($self->next_operand, $self->next_operand);
16              
17 552 50       7768 die $X if $X->is_error;
18 552 50       5711 die $Y if $Y->is_error;
19              
20 552 100       5580 if ($X->is_blank) {
21 3 50       38 return 1 if $Y->is_blank;
22 3 100       38 return !length $Y->value if $Y->is_txt;
23             }
24              
25 550 100       5846 if ($X->is_num) {
26 420 100       4364 return $X->value == $Y->value if $Y->is_num;
27 234 50       2837 return $X->value . '' eq $Y->value if $Y->is_txt;
28             }
29              
30 130 100       1346 if ($X->is_txt) {
31 129 50       1163 return $X->value eq $Y->value if $Y->is_txt;
32             }
33              
34 1         16 return 0;
35             }
36              
37             1;
38              
39             __END__