File Coverage

lib/UR/BoolExpr/Template/PropertyComparison/Between.pm
Criterion Covered Total %
statement 21 22 95.4
branch 6 8 75.0
condition 4 9 44.4
subroutine 5 5 100.0
pod n/a
total 36 44 81.8


line stmt bran cond sub pod time code
1             package UR::BoolExpr::Template::PropertyComparison::Between;
2              
3 6     6   311 use strict;
  6         9  
  6         174  
4 6     6   22 use warnings;
  6         6  
  6         156  
5 6     6   18 use UR;
  6         9  
  6         36  
6             our $VERSION = "0.46"; # UR $VERSION;
7              
8             UR::Object::Type->define(
9             class_name => __PACKAGE__,
10             is => ['UR::BoolExpr::Template::PropertyComparison'],
11             );
12              
13             sub _compare {
14 16     16   21 my ($self, $value, @property_value) = @_;
15 16         21 my $lower_bound = $value->[0];
16 16         20 my $upper_bound = $value->[1];
17              
18 16 100       57 my $cv_is_number = Scalar::Util::looks_like_number($lower_bound)
19             and
20             Scalar::Util::looks_like_number($upper_bound);
21              
22 6     6   35 no warnings 'uninitialized';
  6         13  
  6         716  
23 16         21 foreach my $property_value ( @property_value ) {
24 16         26 my $pv_is_number = Scalar::Util::looks_like_number($property_value);
25              
26 16 100 66     49 if ($cv_is_number and $pv_is_number) {
27 10 50 33     84 return 1 if ( $property_value >= $lower_bound and $property_value <= $upper_bound);
28             } else {
29 6 50 33     51 return 1 if ( $property_value ge $lower_bound and $property_value le $upper_bound);
30             }
31             }
32 0           return '';
33             }
34              
35              
36             1;
37              
38             =pod
39              
40             =head1 NAME
41              
42             UR::BoolExpr::Template::PropertyComparison::Between - perform a 'between' test
43              
44             =head1 DESCRIPTION
45              
46             Evaluates to true of the property's value is between the lower and upper bounds, inclusive.
47             If the property returns multiple values, this comparison returns true if any of the values are
48             within the bounds.
49              
50             =cut