line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::Number; |
2
|
169
|
|
|
169
|
|
1172
|
use strict; |
|
169
|
|
|
|
|
398
|
|
|
169
|
|
|
|
|
5088
|
|
3
|
169
|
|
|
169
|
|
976
|
use warnings; |
|
169
|
|
|
|
|
388
|
|
|
169
|
|
|
|
|
4753
|
|
4
|
|
|
|
|
|
|
|
5
|
169
|
|
|
169
|
|
891
|
use Carp qw/confess/; |
|
169
|
|
|
|
|
371
|
|
|
169
|
|
|
|
|
7564
|
|
6
|
|
|
|
|
|
|
|
7
|
169
|
|
|
169
|
|
961
|
use base 'Test2::Compare::Base'; |
|
169
|
|
|
|
|
360
|
|
|
169
|
|
|
|
|
18099
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
10
|
|
|
|
|
|
|
|
11
|
169
|
|
|
169
|
|
1181
|
use Test2::Util::HashBase qw/input/; |
|
169
|
|
|
|
|
397
|
|
|
169
|
|
|
|
|
1102
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Overloads '!' for us. |
14
|
169
|
|
|
169
|
|
21272
|
use Test2::Compare::Negatable; |
|
169
|
|
|
|
|
390
|
|
|
169
|
|
|
|
|
1013
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
9
|
|
|
9
|
0
|
452
|
my $self = shift; |
18
|
9
|
|
|
|
|
99
|
my $input = $self->{+INPUT}; |
19
|
|
|
|
|
|
|
|
20
|
9
|
100
|
|
|
|
337
|
confess "input must be defined for 'Number' check" |
21
|
|
|
|
|
|
|
unless defined $input; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Check for '' |
24
|
8
|
100
|
100
|
|
|
395
|
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
|
294
|
my $self = shift; |
32
|
10
|
|
|
|
|
24
|
my $in = $self->{+INPUT}; |
33
|
10
|
|
|
|
|
33
|
return $in; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub operator { |
37
|
14
|
|
|
14
|
1
|
281
|
my $self = shift; |
38
|
14
|
100
|
|
|
|
48
|
return '' unless @_; |
39
|
12
|
|
|
|
|
1877
|
my ($got) = @_; |
40
|
|
|
|
|
|
|
|
41
|
12
|
100
|
|
|
|
38
|
return '' unless defined($got); |
42
|
10
|
50
|
33
|
|
|
83
|
return '' unless length($got) && $got =~ m/\S/; |
43
|
|
|
|
|
|
|
|
44
|
10
|
100
|
|
|
|
37
|
return '!=' if $self->{+NEGATE}; |
45
|
4
|
|
|
|
|
17
|
return '=='; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub verify { |
49
|
31
|
|
|
31
|
1
|
269
|
my $self = shift; |
50
|
31
|
|
|
|
|
87
|
my %params = @_; |
51
|
31
|
|
|
|
|
74
|
my ($got, $exists) = @params{qw/got exists/}; |
52
|
|
|
|
|
|
|
|
53
|
31
|
100
|
|
|
|
83
|
return 0 unless $exists; |
54
|
29
|
100
|
|
|
|
71
|
return 0 unless defined $got; |
55
|
27
|
100
|
|
|
|
63
|
return 0 if ref $got; |
56
|
25
|
100
|
100
|
|
|
185
|
return 0 unless length($got) && $got =~ m/\S/; |
57
|
|
|
|
|
|
|
|
58
|
23
|
|
|
|
|
55
|
my $input = $self->{+INPUT}; |
59
|
23
|
|
|
|
|
42
|
my $negate = $self->{+NEGATE}; |
60
|
|
|
|
|
|
|
|
61
|
23
|
|
|
|
|
35
|
my @warnings; |
62
|
|
|
|
|
|
|
my $out; |
63
|
|
|
|
|
|
|
{ |
64
|
23
|
|
|
5
|
|
37
|
local $SIG{__WARN__} = sub { push @warnings => @_ }; |
|
23
|
|
|
|
|
140
|
|
|
5
|
|
|
|
|
47
|
|
65
|
23
|
100
|
|
|
|
204
|
$out = $negate ? ($input != $got) : ($input == $got); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
23
|
|
|
|
|
66
|
for my $warn (@warnings) { |
69
|
5
|
50
|
|
|
|
27
|
if ($warn =~ m/numeric/) { |
70
|
5
|
|
|
|
|
10
|
$out = 0; |
71
|
5
|
|
|
|
|
10
|
next; # This warning won't help anyone. |
72
|
|
|
|
|
|
|
} |
73
|
0
|
|
|
|
|
0
|
warn $warn; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
23
|
|
|
|
|
109
|
return $out; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |