line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::Number; |
2
|
168
|
|
|
168
|
|
1117
|
use strict; |
|
168
|
|
|
|
|
387
|
|
|
168
|
|
|
|
|
4775
|
|
3
|
168
|
|
|
168
|
|
828
|
use warnings; |
|
168
|
|
|
|
|
330
|
|
|
168
|
|
|
|
|
4441
|
|
4
|
|
|
|
|
|
|
|
5
|
168
|
|
|
168
|
|
831
|
use Carp qw/confess/; |
|
168
|
|
|
|
|
361
|
|
|
168
|
|
|
|
|
7511
|
|
6
|
|
|
|
|
|
|
|
7
|
168
|
|
|
168
|
|
938
|
use base 'Test2::Compare::Base'; |
|
168
|
|
|
|
|
315
|
|
|
168
|
|
|
|
|
17172
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.000153'; |
10
|
|
|
|
|
|
|
|
11
|
168
|
|
|
168
|
|
1101
|
use Test2::Util::HashBase qw/input/; |
|
168
|
|
|
|
|
366
|
|
|
168
|
|
|
|
|
1144
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Overloads '!' for us. |
14
|
168
|
|
|
168
|
|
20074
|
use Test2::Compare::Negatable; |
|
168
|
|
|
|
|
364
|
|
|
168
|
|
|
|
|
913
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
9
|
|
|
9
|
0
|
468
|
my $self = shift; |
18
|
9
|
|
|
|
|
97
|
my $input = $self->{+INPUT}; |
19
|
|
|
|
|
|
|
|
20
|
9
|
100
|
|
|
|
310
|
confess "input must be defined for 'Number' check" |
21
|
|
|
|
|
|
|
unless defined $input; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Check for '' |
24
|
8
|
100
|
100
|
|
|
354
|
confess "input must be a number for 'Number' check" |
25
|
|
|
|
|
|
|
unless length($input) && $input =~ m/\S/; |
26
|
|
|
|
|
|
|
|
27
|
6
|
|
|
|
|
31
|
$self->SUPER::init(@_); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub name { |
31
|
10
|
|
|
10
|
1
|
1863
|
my $self = shift; |
32
|
10
|
|
|
|
|
26
|
my $in = $self->{+INPUT}; |
33
|
10
|
|
|
|
|
27
|
return $in; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub operator { |
37
|
14
|
|
|
14
|
1
|
223
|
my $self = shift; |
38
|
14
|
100
|
|
|
|
44
|
return '' unless @_; |
39
|
12
|
|
|
|
|
28
|
my ($got) = @_; |
40
|
|
|
|
|
|
|
|
41
|
12
|
100
|
|
|
|
37
|
return '' unless defined($got); |
42
|
10
|
50
|
33
|
|
|
57
|
return '' unless length($got) && $got =~ m/\S/; |
43
|
|
|
|
|
|
|
|
44
|
10
|
100
|
|
|
|
35
|
return '!=' if $self->{+NEGATE}; |
45
|
4
|
|
|
|
|
14
|
return '=='; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub verify { |
49
|
31
|
|
|
31
|
1
|
261
|
my $self = shift; |
50
|
31
|
|
|
|
|
87
|
my %params = @_; |
51
|
31
|
|
|
|
|
71
|
my ($got, $exists) = @params{qw/got exists/}; |
52
|
|
|
|
|
|
|
|
53
|
31
|
100
|
|
|
|
75
|
return 0 unless $exists; |
54
|
29
|
100
|
|
|
|
73
|
return 0 unless defined $got; |
55
|
27
|
100
|
|
|
|
63
|
return 0 if ref $got; |
56
|
25
|
100
|
100
|
|
|
174
|
return 0 unless length($got) && $got =~ m/\S/; |
57
|
|
|
|
|
|
|
|
58
|
23
|
|
|
|
|
45
|
my $input = $self->{+INPUT}; |
59
|
23
|
|
|
|
|
44
|
my $negate = $self->{+NEGATE}; |
60
|
|
|
|
|
|
|
|
61
|
23
|
|
|
|
|
30
|
my @warnings; |
62
|
|
|
|
|
|
|
my $out; |
63
|
|
|
|
|
|
|
{ |
64
|
23
|
|
|
5
|
|
33
|
local $SIG{__WARN__} = sub { push @warnings => @_ }; |
|
23
|
|
|
|
|
131
|
|
|
5
|
|
|
|
|
52
|
|
65
|
23
|
100
|
|
|
|
184
|
$out = $negate ? ($input != $got) : ($input == $got); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
23
|
|
|
|
|
59
|
for my $warn (@warnings) { |
69
|
5
|
50
|
|
|
|
24
|
if ($warn =~ m/numeric/) { |
70
|
5
|
|
|
|
|
13
|
$out = 0; |
71
|
5
|
|
|
|
|
10
|
next; # This warning won't help anyone. |
72
|
|
|
|
|
|
|
} |
73
|
0
|
|
|
|
|
0
|
warn $warn; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
23
|
|
|
|
|
105
|
return $out; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |