line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Compare::Bool; |
2
|
164
|
|
|
164
|
|
1273
|
use strict; |
|
164
|
|
|
|
|
411
|
|
|
164
|
|
|
|
|
4938
|
|
3
|
164
|
|
|
164
|
|
854
|
use warnings; |
|
164
|
|
|
|
|
306
|
|
|
164
|
|
|
|
|
4854
|
|
4
|
|
|
|
|
|
|
|
5
|
164
|
|
|
164
|
|
862
|
use Carp qw/confess/; |
|
164
|
|
|
|
|
356
|
|
|
164
|
|
|
|
|
7432
|
|
6
|
|
|
|
|
|
|
|
7
|
164
|
|
|
164
|
|
881
|
use base 'Test2::Compare::Base'; |
|
164
|
|
|
|
|
396
|
|
|
164
|
|
|
|
|
17680
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
10
|
|
|
|
|
|
|
|
11
|
164
|
|
|
164
|
|
1212
|
use Test2::Util::HashBase qw/input/; |
|
164
|
|
|
|
|
332
|
|
|
164
|
|
|
|
|
1122
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Overloads '!' for us. |
14
|
164
|
|
|
164
|
|
88204
|
use Test2::Compare::Negatable; |
|
164
|
|
|
|
|
435
|
|
|
164
|
|
|
|
|
1141
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub name { |
17
|
84
|
|
|
84
|
1
|
153
|
my $self = shift; |
18
|
84
|
|
|
|
|
148
|
my $in = $self->{+INPUT}; |
19
|
84
|
|
|
|
|
148
|
return _render_bool($in); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub operator { |
23
|
84
|
|
|
84
|
1
|
131
|
my $self = shift; |
24
|
84
|
100
|
|
|
|
242
|
return '!=' if $self->{+NEGATE}; |
25
|
42
|
|
|
|
|
110
|
return '=='; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub verify { |
29
|
203
|
|
|
203
|
1
|
327
|
my $self = shift; |
30
|
203
|
|
|
|
|
546
|
my %params = @_; |
31
|
203
|
|
|
|
|
475
|
my ($got, $exists) = @params{qw/got exists/}; |
32
|
|
|
|
|
|
|
|
33
|
203
|
100
|
|
|
|
500
|
return 0 unless $exists; |
34
|
|
|
|
|
|
|
|
35
|
202
|
|
|
|
|
389
|
my $want = $self->{+INPUT}; |
36
|
|
|
|
|
|
|
|
37
|
202
|
100
|
100
|
|
|
810
|
my $match = ($want xor $got) ? 0 : 1; |
38
|
202
|
100
|
|
|
|
592
|
$match = $match ? 0 : 1 if $self->{+NEGATE}; |
|
|
100
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
202
|
|
|
|
|
580
|
return $match; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub run { |
44
|
203
|
|
|
203
|
1
|
336
|
my $self = shift; |
45
|
203
|
100
|
|
|
|
696
|
my $delta = $self->SUPER::run(@_) or return; |
46
|
|
|
|
|
|
|
|
47
|
82
|
|
100
|
|
|
551
|
my $dne = $delta->dne || ""; |
48
|
82
|
100
|
|
|
|
537
|
unless ($dne eq 'got') { |
49
|
81
|
|
|
|
|
190
|
my $got = $delta->got; |
50
|
81
|
|
|
|
|
340
|
$delta->set_got(_render_bool($got)); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
82
|
|
|
|
|
406
|
return $delta; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _render_bool { |
57
|
165
|
|
|
165
|
|
303
|
my $bool = shift; |
58
|
165
|
100
|
|
|
|
372
|
my $name = $bool ? 'TRUE' : 'FALSE'; |
59
|
165
|
100
|
|
|
|
343
|
my $val = defined $bool ? $bool : 'undef'; |
60
|
165
|
100
|
|
|
|
381
|
$val = "''" unless length($val); |
61
|
|
|
|
|
|
|
|
62
|
165
|
|
|
|
|
597
|
return "<$name ($val)>"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |