line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::Bool; |
2
|
163
|
|
|
163
|
|
1089
|
use strict; |
|
163
|
|
|
|
|
310
|
|
|
163
|
|
|
|
|
4665
|
|
3
|
163
|
|
|
163
|
|
759
|
use warnings; |
|
163
|
|
|
|
|
312
|
|
|
163
|
|
|
|
|
4157
|
|
4
|
|
|
|
|
|
|
|
5
|
163
|
|
|
163
|
|
1100
|
use Carp qw/confess/; |
|
163
|
|
|
|
|
316
|
|
|
163
|
|
|
|
|
6676
|
|
6
|
|
|
|
|
|
|
|
7
|
163
|
|
|
163
|
|
876
|
use base 'Test2::Compare::Base'; |
|
163
|
|
|
|
|
305
|
|
|
163
|
|
|
|
|
16611
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.000153'; |
10
|
|
|
|
|
|
|
|
11
|
163
|
|
|
163
|
|
1104
|
use Test2::Util::HashBase qw/input/; |
|
163
|
|
|
|
|
288
|
|
|
163
|
|
|
|
|
1014
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Overloads '!' for us. |
14
|
163
|
|
|
163
|
|
80950
|
use Test2::Compare::Negatable; |
|
163
|
|
|
|
|
378
|
|
|
163
|
|
|
|
|
1029
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub name { |
17
|
84
|
|
|
84
|
1
|
131
|
my $self = shift; |
18
|
84
|
|
|
|
|
154
|
my $in = $self->{+INPUT}; |
19
|
84
|
|
|
|
|
156
|
return _render_bool($in); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub operator { |
23
|
84
|
|
|
84
|
1
|
138
|
my $self = shift; |
24
|
84
|
100
|
|
|
|
234
|
return '!=' if $self->{+NEGATE}; |
25
|
42
|
|
|
|
|
110
|
return '=='; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub verify { |
29
|
203
|
|
|
203
|
1
|
311
|
my $self = shift; |
30
|
203
|
|
|
|
|
474
|
my %params = @_; |
31
|
203
|
|
|
|
|
403
|
my ($got, $exists) = @params{qw/got exists/}; |
32
|
|
|
|
|
|
|
|
33
|
203
|
100
|
|
|
|
409
|
return 0 unless $exists; |
34
|
|
|
|
|
|
|
|
35
|
202
|
|
|
|
|
330
|
my $want = $self->{+INPUT}; |
36
|
|
|
|
|
|
|
|
37
|
202
|
100
|
100
|
|
|
695
|
my $match = ($want xor $got) ? 0 : 1; |
38
|
202
|
100
|
|
|
|
527
|
$match = $match ? 0 : 1 if $self->{+NEGATE}; |
|
|
100
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
202
|
|
|
|
|
474
|
return $match; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub run { |
44
|
203
|
|
|
203
|
1
|
332
|
my $self = shift; |
45
|
203
|
100
|
|
|
|
533
|
my $delta = $self->SUPER::run(@_) or return; |
46
|
|
|
|
|
|
|
|
47
|
82
|
|
100
|
|
|
553
|
my $dne = $delta->dne || ""; |
48
|
82
|
100
|
|
|
|
490
|
unless ($dne eq 'got') { |
49
|
81
|
|
|
|
|
214
|
my $got = $delta->got; |
50
|
81
|
|
|
|
|
336
|
$delta->set_got(_render_bool($got)); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
82
|
|
|
|
|
357
|
return $delta; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _render_bool { |
57
|
165
|
|
|
165
|
|
227
|
my $bool = shift; |
58
|
165
|
100
|
|
|
|
324
|
my $name = $bool ? 'TRUE' : 'FALSE'; |
59
|
165
|
100
|
|
|
|
330
|
my $val = defined $bool ? $bool : 'undef'; |
60
|
165
|
100
|
|
|
|
310
|
$val = "''" unless length($val); |
61
|
|
|
|
|
|
|
|
62
|
165
|
|
|
|
|
566
|
return "<$name ($val)>"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |