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