File Coverage

blib/lib/Data/Sah/Filter/perl/Float/check_has_fraction.pm
Criterion Covered Total %
statement 8 14 57.1
branch n/a
condition n/a
subroutine 3 5 60.0
pod 0 2 0.0
total 11 21 52.3


line stmt bran cond sub pod time code
1             package Data::Sah::Filter::perl::Float::check_has_fraction;
2              
3 1     1   357950 use 5.010001;
  1         6  
4 1     1   7 use strict;
  1         2  
  1         35  
5 1     1   10 use warnings;
  1         2  
  1         298  
6              
7             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
8             our $DATE = '2024-07-17'; # DATE
9             our $DIST = 'Data-Sah-Filter'; # DIST
10             our $VERSION = '0.025'; # VERSION
11              
12             sub meta {
13             +{
14 0     0 0   v => 1,
15             summary => 'Check that a floating point number has non-zero fraction',
16             description => <<'_',
17              
18             This is the opposite of the `Float::check_int` filter.
19              
20             _
21             might_fail => 1,
22             args => {
23             },
24             examples => [
25             {value=>1, valid=>0},
26             {value=>-1.1, valid=>1},
27             ],
28             };
29             }
30              
31             sub filter {
32 0     0 0   my %fargs = @_;
33              
34 0           my $dt = $fargs{data_term};
35 0           my $res = {};
36 0           $res->{expr_filter} = join(
37             "",
38             "do { my \$tmp=$dt; \$tmp!=int(\$tmp) ? [undef, \$tmp] : ['Number must have fraction', \$tmp] }",
39             );
40              
41 0           $res;
42             }
43              
44             1;
45             # ABSTRACT: Check that a floating point number has non-zero fraction
46              
47             __END__