line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Kantan::Expect; |
2
|
4
|
|
|
4
|
|
16477
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
136
|
|
3
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
2
|
|
|
4
|
|
|
|
|
93
|
|
4
|
4
|
|
|
4
|
|
15
|
use utf8; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
18
|
|
5
|
4
|
|
|
4
|
|
135
|
use 5.010_001; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
137
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
748
|
use Moo; |
|
4
|
|
|
|
|
15425
|
|
|
4
|
|
|
|
|
14
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has builder => ( is => 'rw', required => 1 ); |
10
|
|
|
|
|
|
|
has stuff => ( is => 'rw', required => 1 ); |
11
|
|
|
|
|
|
|
has inverted => ( is => 'rw', default => sub { 0 } ); |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
1926
|
no Moo; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
14
|
|
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
1123
|
use Try::Tiny; |
|
4
|
|
|
|
|
1053
|
|
|
4
|
|
|
|
|
213
|
|
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
4
|
|
334
|
use Test::Kantan::Caller; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
106
|
|
18
|
4
|
|
|
4
|
|
1727
|
use Test::Deep::NoTest (); |
|
4
|
|
|
|
|
36009
|
|
|
4
|
|
|
|
|
3632
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _ok { |
21
|
60
|
|
|
60
|
|
168
|
my ($self, %args) = @_; |
22
|
60
|
50
|
|
|
|
144
|
exists($args{value}) or die "Missing value"; |
23
|
60
|
|
|
|
|
94
|
my $value = delete $args{value}; |
24
|
|
|
|
|
|
|
|
25
|
60
|
100
|
|
|
|
120
|
my $caller_level = exists($args{caller_level}) ? |
26
|
|
|
|
|
|
|
delete $args{caller_level} : 1; |
27
|
|
|
|
|
|
|
|
28
|
60
|
100
|
|
|
|
239
|
$self->builder->ok( |
29
|
|
|
|
|
|
|
caller => Test::Kantan::Caller->new($caller_level), |
30
|
|
|
|
|
|
|
value => $self->inverted ? !$value : $value, |
31
|
|
|
|
|
|
|
%args, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub not { |
36
|
8
|
|
|
8
|
0
|
49
|
my $self = shift; |
37
|
8
|
|
|
|
|
134
|
Test::Kantan::Expect->new( |
38
|
|
|
|
|
|
|
builder => $self->builder, |
39
|
|
|
|
|
|
|
stuff => $self->stuff, |
40
|
|
|
|
|
|
|
inverted => !$self->inverted, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub to_be_defined { |
45
|
4
|
|
|
4
|
1
|
47
|
my $self = shift; |
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
|
|
22
|
$self->_ok( |
48
|
|
|
|
|
|
|
value => defined($self->stuff), |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub to_be_truthy { |
53
|
6
|
|
|
6
|
1
|
67
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
|
55
|
6
|
|
|
|
|
16
|
$self->_ok( |
56
|
|
|
|
|
|
|
value => $self->stuff, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |
59
|
0
|
|
|
0
|
1
|
0
|
sub to_be_true { goto \&to_be_truthy } |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub to_be_falsy { |
62
|
6
|
|
|
6
|
1
|
79
|
my ($self) = @_; |
63
|
|
|
|
|
|
|
|
64
|
6
|
|
|
|
|
18
|
$self->_ok( |
65
|
|
|
|
|
|
|
value => !$self->stuff, |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
} |
68
|
0
|
|
|
0
|
1
|
0
|
sub to_be_false { goto \&to_be_falsy } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _to_equal_by_test_deep { |
71
|
37
|
|
|
37
|
|
8678
|
my ($self, $expected, %args) = @_; |
72
|
|
|
|
|
|
|
|
73
|
37
|
|
|
|
|
126
|
my ($ok, $stack) = Test::Deep::cmp_details($self->stuff, $expected); |
74
|
37
|
100
|
|
|
|
20878
|
my $diag = $ok ? '-' : Test::Deep::deep_diag($stack); |
75
|
37
|
|
|
|
|
918
|
$self->_ok( |
76
|
|
|
|
|
|
|
value => $ok, |
77
|
|
|
|
|
|
|
description => $diag, |
78
|
|
|
|
|
|
|
%args, |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub to_equal { |
83
|
4
|
|
|
4
|
1
|
20
|
my ($self, $expected) = @_; |
84
|
|
|
|
|
|
|
|
85
|
4
|
|
|
|
|
14
|
$self->_to_equal_by_test_deep( |
86
|
|
|
|
|
|
|
$expected, |
87
|
|
|
|
|
|
|
caller_level => 2, |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
2
|
|
|
2
|
1
|
29
|
sub to_be { goto \&to_equal } |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub to_throw { |
94
|
2
|
|
|
2
|
1
|
20
|
my ($self) = @_; |
95
|
|
|
|
|
|
|
|
96
|
2
|
|
|
|
|
3
|
my $thrown; |
97
|
2
|
|
|
2
|
|
20
|
try { $self->stuff->() } catch { $thrown++ }; |
|
2
|
|
|
|
|
74
|
|
|
1
|
|
|
|
|
23
|
|
98
|
2
|
|
|
|
|
29
|
$self->_ok( |
99
|
|
|
|
|
|
|
value => $thrown, |
100
|
|
|
|
|
|
|
); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub to_match { |
104
|
2
|
|
|
2
|
1
|
18
|
my ($self, $re) = @_; |
105
|
|
|
|
|
|
|
|
106
|
2
|
|
|
|
|
13
|
$self->_ok( |
107
|
|
|
|
|
|
|
value => scalar($self->stuff =~ $re), |
108
|
|
|
|
|
|
|
); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub to_be_a { |
112
|
3
|
|
|
3
|
1
|
14
|
my ($self, $v) = @_; |
113
|
|
|
|
|
|
|
|
114
|
3
|
|
|
|
|
16
|
$self->_ok( |
115
|
|
|
|
|
|
|
value => scalar(UNIVERSAL::isa($self->stuff, $v)), |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
1
|
|
|
1
|
1
|
11
|
sub to_be_an { goto \&to_be_a } |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub to_equal_as_a_bag_of { |
122
|
5
|
|
|
5
|
1
|
44
|
my ($self, $expected) = @_; |
123
|
|
|
|
|
|
|
|
124
|
5
|
|
|
|
|
16
|
$self->_to_equal_by_test_deep( |
125
|
5
|
|
|
|
|
7
|
Test::Deep::bag(@{$expected}), |
126
|
|
|
|
|
|
|
caller_level => 2, |
127
|
|
|
|
|
|
|
); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
0
|
1
|
0
|
sub to_be_a_bag_of { goto \&to_equal_as_a_bag_of } |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub to_equal_as_a_set_of { |
133
|
5
|
|
|
5
|
1
|
34
|
my ($self, $expected) = @_; |
134
|
|
|
|
|
|
|
|
135
|
5
|
|
|
|
|
14
|
$self->_to_equal_by_test_deep( |
136
|
5
|
|
|
|
|
5
|
Test::Deep::set(@{$expected}), |
137
|
|
|
|
|
|
|
caller_level => 2, |
138
|
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
0
|
1
|
0
|
sub to_be_a_set_of { goto \&to_equal_as_a_set_of } |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub to_be_a_sub_bag_of { |
144
|
5
|
|
|
5
|
1
|
34
|
my ($self, $expected) = @_; |
145
|
|
|
|
|
|
|
|
146
|
5
|
|
|
|
|
14
|
$self->_to_equal_by_test_deep( |
147
|
5
|
|
|
|
|
5
|
Test::Deep::subbagof(@{$expected}), |
148
|
|
|
|
|
|
|
caller_level => 2, |
149
|
|
|
|
|
|
|
); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub to_be_a_sub_set_of { |
153
|
4
|
|
|
4
|
1
|
27
|
my ($self, $expected) = @_; |
154
|
|
|
|
|
|
|
|
155
|
4
|
|
|
|
|
10
|
$self->_to_equal_by_test_deep( |
156
|
4
|
|
|
|
|
4
|
Test::Deep::subsetof(@{$expected}), |
157
|
|
|
|
|
|
|
caller_level => 2, |
158
|
|
|
|
|
|
|
); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub to_be_a_super_bag_of { |
162
|
7
|
|
|
7
|
1
|
48
|
my ($self, $expected) = @_; |
163
|
|
|
|
|
|
|
|
164
|
7
|
|
|
|
|
19
|
$self->_to_equal_by_test_deep( |
165
|
7
|
|
|
|
|
7
|
Test::Deep::superbagof(@{$expected}), |
166
|
|
|
|
|
|
|
caller_level => 2, |
167
|
|
|
|
|
|
|
); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub to_be_a_super_set_of { |
171
|
1
|
|
|
1
|
1
|
8
|
my ($self, $expected) = @_; |
172
|
|
|
|
|
|
|
|
173
|
1
|
|
|
|
|
4
|
$self->_to_equal_by_test_deep( |
174
|
1
|
|
|
|
|
3
|
Test::Deep::supersetof(@{$expected}), |
175
|
|
|
|
|
|
|
caller_level => 2, |
176
|
|
|
|
|
|
|
); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub to_be_a_sub_hash_of { |
180
|
3
|
|
|
3
|
1
|
26
|
my ($self, $expected) = @_; |
181
|
|
|
|
|
|
|
|
182
|
3
|
|
|
|
|
9
|
$self->_to_equal_by_test_deep( |
183
|
|
|
|
|
|
|
Test::Deep::subhashof($expected), |
184
|
|
|
|
|
|
|
caller_level => 2, |
185
|
|
|
|
|
|
|
); |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub to_be_a_super_hash_of { |
189
|
3
|
|
|
3
|
1
|
23
|
my ($self, $expected) = @_; |
190
|
|
|
|
|
|
|
|
191
|
3
|
|
|
|
|
8
|
$self->_to_equal_by_test_deep( |
192
|
|
|
|
|
|
|
Test::Deep::superhashof($expected), |
193
|
|
|
|
|
|
|
caller_level => 2, |
194
|
|
|
|
|
|
|
); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
1; |
198
|
|
|
|
|
|
|
__END__ |