| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test2::Compare::Condition; |
|
2
|
2
|
|
|
2
|
|
13
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
57
|
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
49
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
17
|
use base 'Test2::Compare::Base'; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
558
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
16598
|
use Carp qw/croak/; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
90
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
22
|
use Test2::Util::HashBase qw/code/; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Overloads '!' for us. |
|
12
|
2
|
|
|
2
|
|
727
|
use Test2::Compare::Negatable; |
|
|
2
|
|
|
|
|
338
|
|
|
|
2
|
|
|
|
|
21
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub init { |
|
15
|
11
|
|
|
11
|
0
|
144
|
my $self = shift; |
|
16
|
|
|
|
|
|
|
|
|
17
|
11
|
50
|
|
|
|
70
|
croak "'code' must be a code reference" unless ref $self->{+CODE} eq 'CODE'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
11
|
|
|
|
|
36
|
$self->SUPER::init(); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub operator { |
|
23
|
2
|
|
|
2
|
1
|
347
|
my $self = shift; |
|
24
|
2
|
100
|
|
|
|
9
|
return '!=' if $self->{+NEGATE}; |
|
25
|
1
|
|
|
|
|
13
|
return '=='; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
1
|
51
|
sub name { '' } |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub verify { |
|
31
|
13
|
|
|
13
|
1
|
447
|
my $self = shift; |
|
32
|
13
|
|
|
|
|
34
|
my %params = @_; |
|
33
|
13
|
|
|
|
|
33
|
my ($got, $exists) = @params{qw/got exists/}; |
|
34
|
|
|
|
|
|
|
|
|
35
|
13
|
50
|
|
|
|
31
|
return 0 unless $params{exists}; |
|
36
|
|
|
|
|
|
|
|
|
37
|
13
|
|
|
|
|
23
|
local $_ = $got; |
|
38
|
13
|
|
|
|
|
34
|
my $cond = $self->{+CODE}->(); |
|
39
|
13
|
100
|
|
|
|
66
|
$cond = $cond ? 0 : 1 if $self->{+NEGATE}; |
|
|
|
100
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
13
|
|
|
|
|
40
|
return $cond; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub run { |
|
45
|
13
|
|
|
13
|
1
|
8534
|
my $self = shift; |
|
46
|
13
|
100
|
|
|
|
51
|
my $delta = $self->SUPER::run(@_) or return; |
|
47
|
|
|
|
|
|
|
|
|
48
|
4
|
|
50
|
|
|
189
|
my $dne = $delta->dne || ""; |
|
49
|
4
|
50
|
|
|
|
32
|
unless ($dne eq 'got') { |
|
50
|
4
|
|
|
|
|
13
|
my $got = $delta->got; |
|
51
|
4
|
|
|
|
|
20
|
$delta->set_got(_render_bool($got)); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
4
|
|
|
|
|
32
|
return $delta; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _render_bool { |
|
58
|
4
|
|
|
4
|
|
7
|
my $bool = shift; |
|
59
|
4
|
100
|
|
|
|
13
|
my $name = $bool ? 'TRUE' : 'FALSE'; |
|
60
|
4
|
50
|
|
|
|
10
|
my $val = defined $bool ? $bool : 'undef'; |
|
61
|
4
|
50
|
|
|
|
11
|
$val = "''" unless length($val); |
|
62
|
|
|
|
|
|
|
|
|
63
|
4
|
|
|
|
|
18
|
return "<$name ($val)>"; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |