line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Compare::Number; |
2
|
100
|
|
|
100
|
|
694
|
use strict; |
|
100
|
|
|
|
|
113
|
|
|
100
|
|
|
|
|
2312
|
|
3
|
100
|
|
|
100
|
|
316
|
use warnings; |
|
100
|
|
|
|
|
107
|
|
|
100
|
|
|
|
|
2085
|
|
4
|
|
|
|
|
|
|
|
5
|
100
|
|
|
100
|
|
302
|
use Carp qw/confess/; |
|
100
|
|
|
|
|
119
|
|
|
100
|
|
|
|
|
3753
|
|
6
|
|
|
|
|
|
|
|
7
|
100
|
|
|
100
|
|
334
|
use base 'Test::Stream::Compare'; |
|
100
|
|
|
|
|
111
|
|
|
100
|
|
|
|
|
5996
|
|
8
|
100
|
|
|
100
|
|
379
|
use Test::Stream::HashBase accessors => [qw/input negate/]; |
|
100
|
|
|
|
|
124
|
|
|
100
|
|
|
|
|
580
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub init { |
11
|
7
|
|
|
7
|
0
|
5
|
my $self = shift; |
12
|
7
|
|
|
|
|
15
|
my $input = $self->{+INPUT}; |
13
|
|
|
|
|
|
|
|
14
|
7
|
100
|
|
|
|
162
|
confess "input must be defined for 'Number' check" |
15
|
|
|
|
|
|
|
unless defined $input; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Check for '' |
18
|
6
|
100
|
100
|
|
|
192
|
confess "input must be a number for 'Number' check" |
19
|
|
|
|
|
|
|
unless length($input) && $input =~ m/\S/; |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
20
|
$self->SUPER::init(@_); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub name { |
25
|
7
|
|
|
7
|
1
|
11
|
my $self = shift; |
26
|
7
|
|
|
|
|
7
|
my $in = $self->{+INPUT}; |
27
|
7
|
|
|
|
|
15
|
return $in; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub operator { |
31
|
11
|
|
|
11
|
1
|
16
|
my $self = shift; |
32
|
11
|
100
|
|
|
|
24
|
return '' unless @_; |
33
|
9
|
|
|
|
|
10
|
my ($got) = @_; |
34
|
|
|
|
|
|
|
|
35
|
9
|
100
|
|
|
|
19
|
return '' unless defined($got); |
36
|
7
|
50
|
33
|
|
|
40
|
return '' unless length($got) && $got =~ m/\S/; |
37
|
|
|
|
|
|
|
|
38
|
7
|
100
|
|
|
|
17
|
return '!=' if $self->{+NEGATE}; |
39
|
4
|
|
|
|
|
10
|
return '=='; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub verify { |
43
|
25
|
|
|
25
|
1
|
28
|
my $self = shift; |
44
|
25
|
|
|
|
|
40
|
my %params = @_; |
45
|
25
|
|
|
|
|
31
|
my ($got, $exists) = @params{qw/got exists/}; |
46
|
|
|
|
|
|
|
|
47
|
25
|
100
|
|
|
|
40
|
return 0 unless $exists; |
48
|
23
|
100
|
|
|
|
41
|
return 0 unless defined $got; |
49
|
21
|
100
|
|
|
|
34
|
return 0 if ref $got; |
50
|
19
|
100
|
100
|
|
|
95
|
return 0 unless length($got) && $got =~ m/\S/; |
51
|
|
|
|
|
|
|
|
52
|
17
|
|
|
|
|
22
|
my $input = $self->{+INPUT}; |
53
|
17
|
|
|
|
|
15
|
my $negate = $self->{+NEGATE}; |
54
|
|
|
|
|
|
|
|
55
|
17
|
|
|
|
|
16
|
my @warnings; |
56
|
|
|
|
|
|
|
my $out; |
57
|
|
|
|
|
|
|
{ |
58
|
17
|
|
|
4
|
|
9
|
local $SIG{__WARN__} = sub { push @warnings => @_ }; |
|
17
|
|
|
|
|
80
|
|
|
4
|
|
|
|
|
23
|
|
59
|
17
|
100
|
|
|
|
99
|
$out = $negate ? ($input != $got) : ($input == $got); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
17
|
|
|
|
|
30
|
for my $warn (@warnings) { |
63
|
4
|
50
|
|
|
|
16
|
if ($warn =~ m/numeric/) { |
64
|
4
|
|
|
|
|
5
|
$out = 0; |
65
|
4
|
|
|
|
|
6
|
next; # This warning won't help anyone. |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
0
|
warn $warn; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
17
|
|
|
|
|
49
|
return $out; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |