line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::Bool; |
2
|
164
|
|
|
164
|
|
1170
|
use strict; |
|
164
|
|
|
|
|
326
|
|
|
164
|
|
|
|
|
5240
|
|
3
|
164
|
|
|
164
|
|
823
|
use warnings; |
|
164
|
|
|
|
|
311
|
|
|
164
|
|
|
|
|
4893
|
|
4
|
|
|
|
|
|
|
|
5
|
164
|
|
|
164
|
|
888
|
use Carp qw/confess/; |
|
164
|
|
|
|
|
300
|
|
|
164
|
|
|
|
|
8167
|
|
6
|
|
|
|
|
|
|
|
7
|
164
|
|
|
164
|
|
950
|
use base 'Test2::Compare::Base'; |
|
164
|
|
|
|
|
304
|
|
|
164
|
|
|
|
|
20038
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.000156'; |
10
|
|
|
|
|
|
|
|
11
|
164
|
|
|
164
|
|
1271
|
use Test2::Util::HashBase qw/input/; |
|
164
|
|
|
|
|
397
|
|
|
164
|
|
|
|
|
1145
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Overloads '!' for us. |
14
|
164
|
|
|
164
|
|
89910
|
use Test2::Compare::Negatable; |
|
164
|
|
|
|
|
415
|
|
|
164
|
|
|
|
|
1065
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub name { |
17
|
84
|
|
|
84
|
1
|
145
|
my $self = shift; |
18
|
84
|
|
|
|
|
159
|
my $in = $self->{+INPUT}; |
19
|
84
|
|
|
|
|
183
|
return _render_bool($in); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub operator { |
23
|
84
|
|
|
84
|
1
|
162
|
my $self = shift; |
24
|
84
|
100
|
|
|
|
267
|
return '!=' if $self->{+NEGATE}; |
25
|
42
|
|
|
|
|
121
|
return '=='; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub verify { |
29
|
203
|
|
|
203
|
1
|
376
|
my $self = shift; |
30
|
203
|
|
|
|
|
536
|
my %params = @_; |
31
|
203
|
|
|
|
|
469
|
my ($got, $exists) = @params{qw/got exists/}; |
32
|
|
|
|
|
|
|
|
33
|
203
|
100
|
|
|
|
468
|
return 0 unless $exists; |
34
|
|
|
|
|
|
|
|
35
|
202
|
|
|
|
|
394
|
my $want = $self->{+INPUT}; |
36
|
|
|
|
|
|
|
|
37
|
202
|
100
|
100
|
|
|
868
|
my $match = ($want xor $got) ? 0 : 1; |
38
|
202
|
100
|
|
|
|
600
|
$match = $match ? 0 : 1 if $self->{+NEGATE}; |
|
|
100
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
202
|
|
|
|
|
626
|
return $match; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub run { |
44
|
203
|
|
|
203
|
1
|
399
|
my $self = shift; |
45
|
203
|
100
|
|
|
|
638
|
my $delta = $self->SUPER::run(@_) or return; |
46
|
|
|
|
|
|
|
|
47
|
82
|
|
100
|
|
|
579
|
my $dne = $delta->dne || ""; |
48
|
82
|
100
|
|
|
|
521
|
unless ($dne eq 'got') { |
49
|
81
|
|
|
|
|
199
|
my $got = $delta->got; |
50
|
81
|
|
|
|
|
356
|
$delta->set_got(_render_bool($got)); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
82
|
|
|
|
|
430
|
return $delta; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _render_bool { |
57
|
165
|
|
|
165
|
|
271
|
my $bool = shift; |
58
|
165
|
100
|
|
|
|
355
|
my $name = $bool ? 'TRUE' : 'FALSE'; |
59
|
165
|
100
|
|
|
|
368
|
my $val = defined $bool ? $bool : 'undef'; |
60
|
165
|
100
|
|
|
|
377
|
$val = "''" unless length($val); |
61
|
|
|
|
|
|
|
|
62
|
165
|
|
|
|
|
633
|
return "<$name ($val)>"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |