line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::Compare; |
2
|
163
|
|
|
163
|
|
6871
|
use strict; |
|
163
|
|
|
|
|
332
|
|
|
163
|
|
|
|
|
4421
|
|
3
|
163
|
|
|
163
|
|
770
|
use warnings; |
|
163
|
|
|
|
|
3654
|
|
|
163
|
|
|
|
|
7254
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000153'; |
6
|
|
|
|
|
|
|
|
7
|
163
|
|
|
163
|
|
1091
|
use Carp qw/croak/; |
|
163
|
|
|
|
|
352
|
|
|
163
|
|
|
|
|
14201
|
|
8
|
163
|
|
|
163
|
|
1020
|
use Scalar::Util qw/reftype/; |
|
163
|
|
|
|
|
325
|
|
|
163
|
|
|
|
|
8015
|
|
9
|
|
|
|
|
|
|
|
10
|
163
|
|
|
163
|
|
1558
|
use Test2::API qw/context/; |
|
163
|
|
|
|
|
72658
|
|
|
163
|
|
|
|
|
7590
|
|
11
|
163
|
|
|
163
|
|
60284
|
use Test2::Util::Ref qw/rtype/; |
|
163
|
|
|
|
|
422
|
|
|
163
|
|
|
|
|
8519
|
|
12
|
163
|
|
|
163
|
|
1023
|
use Test2::Util qw/pkg_to_file/; |
|
163
|
|
|
|
|
310
|
|
|
163
|
|
|
|
|
6662
|
|
13
|
|
|
|
|
|
|
|
14
|
163
|
|
|
|
|
11744
|
use Test2::Compare qw{ |
15
|
|
|
|
|
|
|
compare |
16
|
|
|
|
|
|
|
get_build push_build pop_build build |
17
|
|
|
|
|
|
|
strict_convert relaxed_convert |
18
|
163
|
|
|
163
|
|
64351
|
}; |
|
163
|
|
|
|
|
426
|
|
19
|
|
|
|
|
|
|
|
20
|
163
|
|
|
163
|
|
65561
|
use Test2::Compare::Array(); |
|
163
|
|
|
|
|
650
|
|
|
163
|
|
|
|
|
4298
|
|
21
|
163
|
|
|
163
|
|
68691
|
use Test2::Compare::Bag(); |
|
163
|
|
|
|
|
426
|
|
|
163
|
|
|
|
|
3419
|
|
22
|
163
|
|
|
163
|
|
60235
|
use Test2::Compare::Bool(); |
|
163
|
|
|
|
|
469
|
|
|
163
|
|
|
|
|
3195
|
|
23
|
163
|
|
|
163
|
|
60547
|
use Test2::Compare::Custom(); |
|
163
|
|
|
|
|
386
|
|
|
163
|
|
|
|
|
3216
|
|
24
|
163
|
|
|
163
|
|
58758
|
use Test2::Compare::Event(); |
|
163
|
|
|
|
|
429
|
|
|
163
|
|
|
|
|
3234
|
|
25
|
163
|
|
|
163
|
|
60507
|
use Test2::Compare::Float(); |
|
163
|
|
|
|
|
433
|
|
|
163
|
|
|
|
|
3340
|
|
26
|
163
|
|
|
163
|
|
62497
|
use Test2::Compare::Hash(); |
|
163
|
|
|
|
|
436
|
|
|
163
|
|
|
|
|
4015
|
|
27
|
163
|
|
|
163
|
|
996
|
use Test2::Compare::Isa(); |
|
163
|
|
|
|
|
362
|
|
|
163
|
|
|
|
|
2228
|
|
28
|
163
|
|
|
163
|
|
731
|
use Test2::Compare::Meta(); |
|
163
|
|
|
|
|
375
|
|
|
163
|
|
|
|
|
2097
|
|
29
|
163
|
|
|
163
|
|
62131
|
use Test2::Compare::Number(); |
|
163
|
|
|
|
|
429
|
|
|
163
|
|
|
|
|
3269
|
|
30
|
163
|
|
|
163
|
|
941
|
use Test2::Compare::Object(); |
|
163
|
|
|
|
|
363
|
|
|
163
|
|
|
|
|
2346
|
|
31
|
163
|
|
|
163
|
|
62807
|
use Test2::Compare::OrderedSubset(); |
|
163
|
|
|
|
|
431
|
|
|
163
|
|
|
|
|
3187
|
|
32
|
163
|
|
|
163
|
|
59837
|
use Test2::Compare::Pattern(); |
|
163
|
|
|
|
|
498
|
|
|
163
|
|
|
|
|
3158
|
|
33
|
163
|
|
|
163
|
|
58724
|
use Test2::Compare::Ref(); |
|
163
|
|
|
|
|
416
|
|
|
163
|
|
|
|
|
3135
|
|
34
|
163
|
|
|
163
|
|
58447
|
use Test2::Compare::DeepRef(); |
|
163
|
|
|
|
|
460
|
|
|
163
|
|
|
|
|
3063
|
|
35
|
163
|
|
|
163
|
|
57164
|
use Test2::Compare::Regex(); |
|
163
|
|
|
|
|
416
|
|
|
163
|
|
|
|
|
3204
|
|
36
|
163
|
|
|
163
|
|
58446
|
use Test2::Compare::Scalar(); |
|
163
|
|
|
|
|
401
|
|
|
163
|
|
|
|
|
3479
|
|
37
|
163
|
|
|
163
|
|
60119
|
use Test2::Compare::Set(); |
|
163
|
|
|
|
|
417
|
|
|
163
|
|
|
|
|
3289
|
|
38
|
163
|
|
|
163
|
|
58683
|
use Test2::Compare::String(); |
|
163
|
|
|
|
|
421
|
|
|
163
|
|
|
|
|
3232
|
|
39
|
163
|
|
|
163
|
|
57605
|
use Test2::Compare::Undef(); |
|
163
|
|
|
|
|
410
|
|
|
163
|
|
|
|
|
3091
|
|
40
|
163
|
|
|
163
|
|
57887
|
use Test2::Compare::Wildcard(); |
|
163
|
|
|
|
|
410
|
|
|
163
|
|
|
|
|
19340
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
%Carp::Internal = ( |
43
|
|
|
|
|
|
|
%Carp::Internal, |
44
|
|
|
|
|
|
|
'Test2::Tools::Compare' => 1, |
45
|
|
|
|
|
|
|
'Test2::Compare::Array' => 1, |
46
|
|
|
|
|
|
|
'Test2::Compare::Bag' => 1, |
47
|
|
|
|
|
|
|
'Test2::Compare::Bool' => 1, |
48
|
|
|
|
|
|
|
'Test2::Compare::Custom' => 1, |
49
|
|
|
|
|
|
|
'Test2::Compare::Event' => 1, |
50
|
|
|
|
|
|
|
'Test2::Compare::Float' => 1, |
51
|
|
|
|
|
|
|
'Test2::Compare::Hash' => 1, |
52
|
|
|
|
|
|
|
'Test2::Compare::Isa' => 1, |
53
|
|
|
|
|
|
|
'Test2::Compare::Meta' => 1, |
54
|
|
|
|
|
|
|
'Test2::Compare::Number' => 1, |
55
|
|
|
|
|
|
|
'Test2::Compare::Object' => 1, |
56
|
|
|
|
|
|
|
'Test2::Compare::Pattern' => 1, |
57
|
|
|
|
|
|
|
'Test2::Compare::Ref' => 1, |
58
|
|
|
|
|
|
|
'Test2::Compare::Regex' => 1, |
59
|
|
|
|
|
|
|
'Test2::Compare::Scalar' => 1, |
60
|
|
|
|
|
|
|
'Test2::Compare::Set' => 1, |
61
|
|
|
|
|
|
|
'Test2::Compare::String' => 1, |
62
|
|
|
|
|
|
|
'Test2::Compare::Undef' => 1, |
63
|
|
|
|
|
|
|
'Test2::Compare::Wildcard' => 1, |
64
|
|
|
|
|
|
|
'Test2::Compare::OrderedSubset' => 1, |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
our @EXPORT = qw/is like/; |
68
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ |
69
|
|
|
|
|
|
|
is like isnt unlike |
70
|
|
|
|
|
|
|
match mismatch validator |
71
|
|
|
|
|
|
|
hash array bag object meta meta_check number float rounded within string subset bool check_isa |
72
|
|
|
|
|
|
|
in_set not_in_set check_set |
73
|
|
|
|
|
|
|
item field call call_list call_hash prop check all_items all_keys all_vals all_values |
74
|
|
|
|
|
|
|
etc end filter_items |
75
|
|
|
|
|
|
|
T F D DF E DNE FDNE U L |
76
|
|
|
|
|
|
|
event fail_events |
77
|
|
|
|
|
|
|
exact_ref |
78
|
|
|
|
|
|
|
}; |
79
|
163
|
|
|
163
|
|
1084
|
use base 'Exporter'; |
|
163
|
|
|
|
|
326
|
|
|
163
|
|
|
|
|
648670
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $_autodump = sub { |
82
|
|
|
|
|
|
|
my ($ctx, $got) = @_; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $module = $ENV{'T2_AUTO_DUMP'} or return; |
85
|
|
|
|
|
|
|
$module = 'Data::Dumper' if $module eq '1'; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $file = pkg_to_file($module); |
88
|
|
|
|
|
|
|
eval { require $file }; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
if (not $module->can('Dump')) { |
91
|
|
|
|
|
|
|
require Data::Dumper; |
92
|
|
|
|
|
|
|
$module = 'Data::Dumper'; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $deparse = $Data::Dumper::Deparse; |
96
|
|
|
|
|
|
|
$deparse = !!$ENV{'T2_AUTO_DEPARSE'} if exists $ENV{'T2_AUTO_DEPARSE'}; |
97
|
|
|
|
|
|
|
local $Data::Dumper::Deparse = $deparse; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$ctx->diag($module->Dump([$got], ['GOT'])); |
100
|
|
|
|
|
|
|
}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub is($$;$@) { |
103
|
1374
|
|
|
1374
|
1
|
58798
|
my ($got, $exp, $name, @diag) = @_; |
104
|
1374
|
|
|
|
|
4136
|
my $ctx = context(); |
105
|
|
|
|
|
|
|
|
106
|
1374
|
|
|
|
|
149696
|
my $delta = compare($got, $exp, \&strict_convert); |
107
|
|
|
|
|
|
|
|
108
|
1374
|
100
|
|
|
|
4448
|
if ($delta) { |
109
|
|
|
|
|
|
|
# Temporary thing. |
110
|
208
|
|
|
|
|
309
|
my $count = 0; |
111
|
208
|
|
|
|
|
253
|
my $implicit = 0; |
112
|
208
|
|
|
|
|
343
|
my @deltas = ($delta); |
113
|
208
|
|
|
|
|
478
|
while (my $d = shift @deltas) { |
114
|
309
|
|
|
|
|
971
|
my $add = $d->children; |
115
|
309
|
100
|
100
|
|
|
1320
|
push @deltas => @$add if $add && @$add; |
116
|
309
|
100
|
|
|
|
571
|
next if $d->verified; |
117
|
250
|
|
|
|
|
853
|
$count++; |
118
|
250
|
100
|
66
|
|
|
458
|
$implicit++ if $d->note && $d->note eq 'implicit end'; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
208
|
50
|
|
|
|
1008
|
if ($implicit == $count) { |
122
|
0
|
|
|
|
|
0
|
$ctx->ok(1, $name); |
123
|
0
|
0
|
|
|
|
0
|
my $meth = $ENV{AUTHOR_TESTING} ? 'throw' : 'alert'; |
124
|
0
|
|
|
|
|
0
|
my $type = $delta->render_check; |
125
|
0
|
|
|
|
|
0
|
$ctx->$meth( |
126
|
|
|
|
|
|
|
join "\n", |
127
|
|
|
|
|
|
|
"!!! NOTICE OF BEHAVIOR CHANGE !!!", |
128
|
|
|
|
|
|
|
"This test uses at least 1 $type check without using end() or etc().", |
129
|
|
|
|
|
|
|
"The old behavior was to default to etc() when inside is().", |
130
|
|
|
|
|
|
|
"The old behavior was a bug.", |
131
|
|
|
|
|
|
|
"The new behavior is to default to end().", |
132
|
|
|
|
|
|
|
"This test will soon start to fail with the following diagnostics:", |
133
|
|
|
|
|
|
|
$delta->diag->as_string, |
134
|
|
|
|
|
|
|
"", |
135
|
|
|
|
|
|
|
); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
else { |
138
|
208
|
|
|
|
|
451
|
$ctx->fail($name, $delta->diag, @diag); |
139
|
208
|
|
|
|
|
37405
|
$ctx->$_autodump($got); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
else { |
143
|
1166
|
|
|
|
|
4493
|
$ctx->ok(1, $name); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
1374
|
|
|
|
|
178052
|
$ctx->release; |
147
|
1374
|
|
|
|
|
36407
|
return !$delta; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub isnt($$;$@) { |
151
|
12
|
|
|
12
|
1
|
980
|
my ($got, $exp, $name, @diag) = @_; |
152
|
12
|
|
|
|
|
212
|
my $ctx = context(); |
153
|
|
|
|
|
|
|
|
154
|
12
|
|
|
|
|
3568
|
my $delta = compare($got, $exp, \&strict_convert); |
155
|
|
|
|
|
|
|
|
156
|
12
|
100
|
|
|
|
159
|
if ($delta) { |
157
|
8
|
|
|
|
|
177
|
$ctx->ok(1, $name); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
else { |
160
|
4
|
|
|
|
|
20
|
$ctx->ok(0, $name, ["Comparison matched (it should not).", @diag]); |
161
|
4
|
|
|
|
|
1871
|
$ctx->$_autodump($got); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
12
|
|
|
|
|
4458
|
$ctx->release; |
165
|
12
|
100
|
|
|
|
782
|
return $delta ? 1 : 0; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub like($$;$@) { |
169
|
334
|
|
|
334
|
1
|
46237
|
my ($got, $exp, $name, @diag) = @_; |
170
|
334
|
|
|
|
|
1004
|
my $ctx = context(); |
171
|
|
|
|
|
|
|
|
172
|
334
|
|
|
|
|
30217
|
my $delta = compare($got, $exp, \&relaxed_convert); |
173
|
|
|
|
|
|
|
|
174
|
334
|
100
|
|
|
|
1371
|
if ($delta) { |
175
|
3
|
|
|
|
|
9
|
$ctx->fail($name, $delta->diag, @diag); |
176
|
3
|
|
|
|
|
567
|
$ctx->$_autodump($got); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
else { |
179
|
331
|
|
|
|
|
1195
|
$ctx->ok(1, $name); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
334
|
|
|
|
|
67212
|
$ctx->release; |
183
|
334
|
|
|
|
|
9085
|
return !$delta; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub unlike($$;$@) { |
187
|
9
|
|
|
9
|
1
|
543
|
my ($got, $exp, $name, @diag) = @_; |
188
|
9
|
|
|
|
|
20
|
my $ctx = context(); |
189
|
|
|
|
|
|
|
|
190
|
9
|
|
|
|
|
677
|
my $delta = compare($got, $exp, \&relaxed_convert); |
191
|
|
|
|
|
|
|
|
192
|
9
|
100
|
|
|
|
36
|
if ($delta) { |
193
|
4
|
|
|
|
|
13
|
$ctx->ok(1, $name); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
else { |
196
|
5
|
|
|
|
|
36
|
$ctx->ok(0, $name, ["Comparison matched (it should not).", @diag]); |
197
|
5
|
|
|
|
|
2279
|
$ctx->$_autodump($got); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
9
|
|
|
|
|
468
|
$ctx->release; |
201
|
9
|
100
|
|
|
|
206
|
return $delta ? 1 : 0; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
7
|
|
|
7
|
1
|
262
|
sub meta(&) { build('Test2::Compare::Meta', @_) } |
205
|
0
|
|
|
0
|
1
|
0
|
sub meta_check(&) { build('Test2::Compare::Meta', @_) } |
206
|
513
|
|
|
513
|
1
|
3484
|
sub hash(&) { build('Test2::Compare::Hash', @_) } |
207
|
631
|
|
|
631
|
1
|
545211
|
sub array(&) { build('Test2::Compare::Array', @_) } |
208
|
401
|
|
|
401
|
1
|
2943
|
sub bag(&) { build('Test2::Compare::Bag', @_) } |
209
|
10
|
|
|
10
|
1
|
290
|
sub object(&) { build('Test2::Compare::Object', @_) } |
210
|
31
|
|
|
31
|
1
|
30225
|
sub subset(&) { build('Test2::Compare::OrderedSubset', @_) } |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub U() { |
213
|
2
|
|
|
2
|
1
|
280
|
my @caller = caller; |
214
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
215
|
2
|
100
|
|
2
|
|
15
|
code => sub { defined $_ ? 0 : 1 }, name => 'UNDEFINED', operator => '!DEFINED()', |
|
2
|
|
|
|
|
8
|
|
216
|
|
|
|
|
|
|
file => $caller[1], |
217
|
|
|
|
|
|
|
lines => [$caller[2]], |
218
|
|
|
|
|
|
|
); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub D() { |
222
|
6
|
|
|
6
|
1
|
340
|
my @caller = caller; |
223
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
224
|
6
|
100
|
|
6
|
|
33
|
code => sub { defined $_ ? 1 : 0 }, name => 'DEFINED', operator => 'DEFINED()', |
|
6
|
|
|
|
|
14
|
|
225
|
|
|
|
|
|
|
file => $caller[1], |
226
|
|
|
|
|
|
|
lines => [$caller[2]], |
227
|
|
|
|
|
|
|
); |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub DF() { |
231
|
6
|
|
|
6
|
1
|
314
|
my @caller = caller; |
232
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
233
|
6
|
100
|
100
|
6
|
|
34
|
code => sub { defined $_ && ( ! ref $_ && ! $_ ) ? 1 : 0 }, name => 'DEFINED BUT FALSE', operator => 'DEFINED() && FALSE()', |
|
6
|
|
|
|
|
70
|
|
234
|
|
|
|
|
|
|
file => $caller[1], |
235
|
|
|
|
|
|
|
lines => [$caller[2]], |
236
|
|
|
|
|
|
|
); |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub DNE() { |
240
|
26
|
|
|
26
|
1
|
693
|
my @caller = caller; |
241
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
242
|
26
|
100
|
|
30
|
|
218
|
code => sub { my %p = @_; $p{exists} ? 0 : 1 }, name => '', operator => '!exists', |
|
30
|
|
|
|
|
137
|
|
|
30
|
|
|
|
|
115
|
|
243
|
|
|
|
|
|
|
file => $caller[1], |
244
|
|
|
|
|
|
|
lines => [$caller[2]], |
245
|
|
|
|
|
|
|
); |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub E() { |
249
|
2
|
|
|
2
|
1
|
298
|
my @caller = caller; |
250
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
251
|
2
|
100
|
|
2
|
|
15
|
code => sub { my %p = @_; $p{exists} ? 1 : 0 }, name => '', operator => '!exists', |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
45
|
|
252
|
|
|
|
|
|
|
file => $caller[1], |
253
|
|
|
|
|
|
|
lines => [$caller[2]], |
254
|
|
|
|
|
|
|
); |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub F() { |
258
|
29
|
|
|
29
|
1
|
466
|
my @caller = caller; |
259
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
260
|
29
|
100
|
|
28
|
|
167
|
code => sub { my %p = @_; $p{got} ? 0 : $p{exists} }, name => 'FALSE', operator => 'FALSE()', |
|
28
|
|
|
|
|
99
|
|
|
28
|
|
|
|
|
101
|
|
261
|
|
|
|
|
|
|
file => $caller[1], |
262
|
|
|
|
|
|
|
lines => [$caller[2]], |
263
|
|
|
|
|
|
|
); |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
sub FDNE() { |
267
|
6
|
|
|
6
|
1
|
351
|
my @caller = caller; |
268
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
269
|
6
|
100
|
66
|
6
|
|
35
|
code => sub { defined $_ && ( ref $_ || $_ ) ? 0 : 1 }, name => 'FALSE', operator => 'FALSE() || !exists', |
|
6
|
|
|
|
|
23
|
|
270
|
|
|
|
|
|
|
file => $caller[1], |
271
|
|
|
|
|
|
|
lines => [$caller[2]], |
272
|
|
|
|
|
|
|
); |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
sub T() { |
276
|
161
|
|
|
161
|
1
|
2315
|
my @caller = caller; |
277
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
278
|
161
|
100
|
100
|
161
|
|
2306
|
code => sub { defined $_ && ( ref $_ || $_ ) ? 1 : 0 }, name => 'TRUE', operator => 'TRUE()', |
|
161
|
|
|
|
|
1049
|
|
279
|
|
|
|
|
|
|
file => $caller[1], |
280
|
|
|
|
|
|
|
lines => [$caller[2]], |
281
|
|
|
|
|
|
|
); |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
sub L() { |
285
|
5
|
|
|
5
|
1
|
299
|
my @caller = caller; |
286
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
287
|
5
|
100
|
100
|
5
|
|
28
|
code => sub { defined $_ && length $_ ? 1 : 0 }, name => 'LENGTH', operator => 'DEFINED() && LENGTH()', |
|
5
|
|
|
|
|
33
|
|
288
|
|
|
|
|
|
|
file => $caller[1], |
289
|
|
|
|
|
|
|
lines => [$caller[2]], |
290
|
|
|
|
|
|
|
); |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
sub exact_ref($) { |
294
|
30
|
|
|
30
|
1
|
580
|
my @caller = caller; |
295
|
30
|
|
|
|
|
152
|
return Test2::Compare::Ref->new( |
296
|
|
|
|
|
|
|
file => $caller[1], |
297
|
|
|
|
|
|
|
lines => [$caller[2]], |
298
|
|
|
|
|
|
|
input => $_[0], |
299
|
|
|
|
|
|
|
); |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
sub match($) { |
303
|
548
|
|
|
548
|
1
|
9511
|
my @caller = caller; |
304
|
548
|
|
|
|
|
2226
|
return Test2::Compare::Pattern->new( |
305
|
|
|
|
|
|
|
file => $caller[1], |
306
|
|
|
|
|
|
|
lines => [$caller[2]], |
307
|
|
|
|
|
|
|
pattern => $_[0], |
308
|
|
|
|
|
|
|
); |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
sub mismatch($) { |
312
|
4
|
|
|
4
|
1
|
621
|
my @caller = caller; |
313
|
4
|
|
|
|
|
33
|
return Test2::Compare::Pattern->new( |
314
|
|
|
|
|
|
|
file => $caller[1], |
315
|
|
|
|
|
|
|
lines => [$caller[2]], |
316
|
|
|
|
|
|
|
negate => 1, |
317
|
|
|
|
|
|
|
pattern => $_[0], |
318
|
|
|
|
|
|
|
); |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
sub validator { |
322
|
6
|
|
|
6
|
1
|
27255
|
my $code = pop; |
323
|
6
|
|
|
|
|
12
|
my $cname = pop; |
324
|
6
|
|
|
|
|
11
|
my $op = pop; |
325
|
|
|
|
|
|
|
|
326
|
6
|
|
|
|
|
23
|
my @caller = caller; |
327
|
6
|
|
|
|
|
35
|
return Test2::Compare::Custom->new( |
328
|
|
|
|
|
|
|
file => $caller[1], |
329
|
|
|
|
|
|
|
lines => [$caller[2]], |
330
|
|
|
|
|
|
|
code => $code, |
331
|
|
|
|
|
|
|
name => $cname, |
332
|
|
|
|
|
|
|
operator => $op, |
333
|
|
|
|
|
|
|
); |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
sub number($;@) { |
337
|
3
|
|
|
3
|
1
|
208
|
my ($num, @args) = @_; |
338
|
3
|
|
|
|
|
8
|
my @caller = caller; |
339
|
3
|
|
|
|
|
22
|
return Test2::Compare::Number->new( |
340
|
|
|
|
|
|
|
file => $caller[1], |
341
|
|
|
|
|
|
|
lines => [$caller[2]], |
342
|
|
|
|
|
|
|
input => $num, |
343
|
|
|
|
|
|
|
@args, |
344
|
|
|
|
|
|
|
); |
345
|
|
|
|
|
|
|
} |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
sub float($;@) { |
348
|
6
|
|
|
6
|
1
|
393
|
my ($num, @args) = @_; |
349
|
6
|
|
|
|
|
15
|
my @caller = caller; |
350
|
6
|
|
|
|
|
36
|
return Test2::Compare::Float->new( |
351
|
|
|
|
|
|
|
file => $caller[1], |
352
|
|
|
|
|
|
|
lines => [$caller[2]], |
353
|
|
|
|
|
|
|
input => $num, |
354
|
|
|
|
|
|
|
@args, |
355
|
|
|
|
|
|
|
); |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
sub rounded($$) { |
359
|
1
|
|
|
1
|
1
|
11
|
my ($num, $precision) = @_; |
360
|
1
|
|
|
|
|
4
|
my @caller = caller; |
361
|
1
|
|
|
|
|
5
|
return Test2::Compare::Float->new( |
362
|
|
|
|
|
|
|
file => $caller[1], |
363
|
|
|
|
|
|
|
lines => [$caller[2]], |
364
|
|
|
|
|
|
|
input => $num, |
365
|
|
|
|
|
|
|
precision => $precision, |
366
|
|
|
|
|
|
|
); |
367
|
|
|
|
|
|
|
} |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
sub within($;$) { |
370
|
2
|
|
|
2
|
1
|
164
|
my ($num, $tolerance) = @_; |
371
|
2
|
|
|
|
|
6
|
my @caller = caller; |
372
|
2
|
100
|
|
|
|
10
|
return Test2::Compare::Float->new( |
373
|
|
|
|
|
|
|
file => $caller[1], |
374
|
|
|
|
|
|
|
lines => [$caller[2]], |
375
|
|
|
|
|
|
|
input => $num, |
376
|
|
|
|
|
|
|
defined $tolerance ? ( tolerance => $tolerance ) : (), |
377
|
|
|
|
|
|
|
); |
378
|
|
|
|
|
|
|
} |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
sub bool($;@) { |
381
|
203
|
|
|
203
|
1
|
28161
|
my ($bool, @args) = @_; |
382
|
203
|
|
|
|
|
626
|
my @caller = caller; |
383
|
203
|
|
|
|
|
806
|
return Test2::Compare::Bool->new( |
384
|
|
|
|
|
|
|
file => $caller[1], |
385
|
|
|
|
|
|
|
lines => [$caller[2]], |
386
|
|
|
|
|
|
|
input => $bool, |
387
|
|
|
|
|
|
|
@args, |
388
|
|
|
|
|
|
|
); |
389
|
|
|
|
|
|
|
} |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
sub string($;@) { |
392
|
4
|
|
|
4
|
1
|
193
|
my ($str, @args) = @_; |
393
|
4
|
|
|
|
|
15
|
my @caller = caller; |
394
|
4
|
|
|
|
|
22
|
return Test2::Compare::String->new( |
395
|
|
|
|
|
|
|
file => $caller[1], |
396
|
|
|
|
|
|
|
lines => [$caller[2]], |
397
|
|
|
|
|
|
|
input => $str, |
398
|
|
|
|
|
|
|
@args, |
399
|
|
|
|
|
|
|
); |
400
|
|
|
|
|
|
|
} |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
sub check_isa($;@) { |
403
|
3
|
|
|
3
|
1
|
248
|
my ($class_name, @args) = @_; |
404
|
3
|
|
|
|
|
11
|
my @caller = caller; |
405
|
3
|
|
|
|
|
23
|
return Test2::Compare::Isa->new( |
406
|
|
|
|
|
|
|
file => $caller[1], |
407
|
|
|
|
|
|
|
lines => [$caller[2]], |
408
|
|
|
|
|
|
|
input => $class_name, |
409
|
|
|
|
|
|
|
@args, |
410
|
|
|
|
|
|
|
); |
411
|
|
|
|
|
|
|
} |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
sub filter_items(&) { |
414
|
18
|
100
|
|
18
|
1
|
150
|
defined( my $build = get_build() ) or croak "No current build!"; |
415
|
|
|
|
|
|
|
|
416
|
17
|
100
|
|
|
|
179
|
croak "'$build' does not support filters" |
417
|
|
|
|
|
|
|
unless $build->can('add_filter'); |
418
|
|
|
|
|
|
|
|
419
|
16
|
100
|
|
|
|
127
|
croak "'filter_items' should only ever be called in void context" |
420
|
|
|
|
|
|
|
if defined wantarray; |
421
|
|
|
|
|
|
|
|
422
|
15
|
|
|
|
|
57
|
$build->add_filter(@_); |
423
|
|
|
|
|
|
|
} |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
sub all_items { |
426
|
5
|
50
|
|
5
|
1
|
26
|
defined( my $build = get_build() ) or croak "No current build!"; |
427
|
|
|
|
|
|
|
|
428
|
5
|
50
|
|
|
|
24
|
croak "'$build' does not support all-items" |
429
|
|
|
|
|
|
|
unless $build->can('add_for_each'); |
430
|
|
|
|
|
|
|
|
431
|
5
|
50
|
|
|
|
15
|
croak "'all_items' should only ever be called in void context" |
432
|
|
|
|
|
|
|
if defined wantarray; |
433
|
|
|
|
|
|
|
|
434
|
5
|
|
|
|
|
15
|
$build->add_for_each(@_); |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
sub all_keys { |
438
|
2
|
50
|
|
2
|
1
|
10
|
defined( my $build = get_build() ) or croak "No current build!"; |
439
|
|
|
|
|
|
|
|
440
|
2
|
50
|
|
|
|
8
|
croak "'$build' does not support all-keys" |
441
|
|
|
|
|
|
|
unless $build->can('add_for_each_key'); |
442
|
|
|
|
|
|
|
|
443
|
2
|
50
|
|
|
|
6
|
croak "'all_keys' should only ever be called in void context" |
444
|
|
|
|
|
|
|
if defined wantarray; |
445
|
|
|
|
|
|
|
|
446
|
2
|
|
|
|
|
7
|
$build->add_for_each_key(@_); |
447
|
|
|
|
|
|
|
} |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
*all_vals = *all_values; |
450
|
|
|
|
|
|
|
sub all_values { |
451
|
2
|
50
|
|
2
|
1
|
12
|
defined( my $build = get_build() ) or croak "No current build!"; |
452
|
|
|
|
|
|
|
|
453
|
2
|
50
|
|
|
|
10
|
croak "'$build' does not support all-values" |
454
|
|
|
|
|
|
|
unless $build->can('add_for_each_val'); |
455
|
|
|
|
|
|
|
|
456
|
2
|
50
|
|
|
|
5
|
croak "'all_values' should only ever be called in void context" |
457
|
|
|
|
|
|
|
if defined wantarray; |
458
|
|
|
|
|
|
|
|
459
|
2
|
|
|
|
|
7
|
$build->add_for_each_val(@_); |
460
|
|
|
|
|
|
|
} |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
sub end() { |
464
|
318
|
100
|
|
318
|
1
|
1747
|
defined( my $build = get_build() ) or croak "No current build!"; |
465
|
|
|
|
|
|
|
|
466
|
317
|
100
|
|
|
|
1338
|
croak "'$build' does not support 'ending'" |
467
|
|
|
|
|
|
|
unless $build->can('ending'); |
468
|
|
|
|
|
|
|
|
469
|
316
|
100
|
|
|
|
1061
|
croak "'end' should only ever be called in void context" |
470
|
|
|
|
|
|
|
if defined wantarray; |
471
|
|
|
|
|
|
|
|
472
|
315
|
|
|
|
|
913
|
$build->set_ending(1); |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
sub etc() { |
476
|
1036
|
50
|
|
1036
|
1
|
2490
|
defined( my $build = get_build() ) or croak "No current build!"; |
477
|
|
|
|
|
|
|
|
478
|
1036
|
50
|
|
|
|
2599
|
croak "'$build' does not support 'ending'" |
479
|
|
|
|
|
|
|
unless $build->can('ending'); |
480
|
|
|
|
|
|
|
|
481
|
1036
|
50
|
|
|
|
1680
|
croak "'etc' should only ever be called in void context" |
482
|
|
|
|
|
|
|
if defined wantarray; |
483
|
|
|
|
|
|
|
|
484
|
1036
|
|
|
|
|
2098
|
$build->set_ending(0); |
485
|
|
|
|
|
|
|
} |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
my $_call = sub { |
488
|
|
|
|
|
|
|
my ($name, $expect, $context, $func_name) = @_; |
489
|
|
|
|
|
|
|
defined( my $build = get_build() ) or croak "No current build!"; |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
croak "'$build' does not support method calls" |
492
|
|
|
|
|
|
|
unless $build->can('add_call'); |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
croak "'$func_name' should only ever be called in void context" |
495
|
|
|
|
|
|
|
if defined wantarray; |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
my @caller = caller; |
498
|
|
|
|
|
|
|
$build->add_call( |
499
|
|
|
|
|
|
|
$name, |
500
|
|
|
|
|
|
|
Test2::Compare::Wildcard->new( |
501
|
|
|
|
|
|
|
expect => $expect, |
502
|
|
|
|
|
|
|
file => $caller[1], |
503
|
|
|
|
|
|
|
lines => [$caller[2]], |
504
|
|
|
|
|
|
|
), |
505
|
|
|
|
|
|
|
undef, |
506
|
|
|
|
|
|
|
$context, |
507
|
|
|
|
|
|
|
); |
508
|
|
|
|
|
|
|
}; |
509
|
|
|
|
|
|
|
|
510
|
1830
|
|
|
1830
|
1
|
46875
|
sub call($$) { $_call->(@_,'scalar','call') } |
511
|
7
|
|
|
7
|
1
|
52
|
sub call_list($$) { $_call->(@_,'list','call_list') } |
512
|
7
|
|
|
7
|
1
|
42
|
sub call_hash($$) { $_call->(@_,'hash','call_hash') } |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
sub prop($$) { |
515
|
822
|
|
|
822
|
1
|
6644
|
my ($name, $expect) = @_; |
516
|
822
|
100
|
|
|
|
2072
|
defined( my $build = get_build() ) or croak "No current build!"; |
517
|
|
|
|
|
|
|
|
518
|
821
|
50
|
|
|
|
2610
|
croak "'$build' does not support meta-checks" |
519
|
|
|
|
|
|
|
unless $build->can('add_prop'); |
520
|
|
|
|
|
|
|
|
521
|
821
|
100
|
|
|
|
1895
|
croak "'prop' should only ever be called in void context" |
522
|
|
|
|
|
|
|
if defined wantarray; |
523
|
|
|
|
|
|
|
|
524
|
820
|
|
|
|
|
2110
|
my @caller = caller; |
525
|
820
|
|
|
|
|
3163
|
$build->add_prop( |
526
|
|
|
|
|
|
|
$name, |
527
|
|
|
|
|
|
|
Test2::Compare::Wildcard->new( |
528
|
|
|
|
|
|
|
expect => $expect, |
529
|
|
|
|
|
|
|
file => $caller[1], |
530
|
|
|
|
|
|
|
lines => [$caller[2]], |
531
|
|
|
|
|
|
|
), |
532
|
|
|
|
|
|
|
); |
533
|
|
|
|
|
|
|
} |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
sub item($;$) { |
536
|
1423
|
|
|
1423
|
1
|
3883
|
my @args = @_; |
537
|
1423
|
|
|
|
|
1755
|
my $expect = pop @args; |
538
|
|
|
|
|
|
|
|
539
|
1423
|
100
|
|
|
|
2304
|
defined( my $build = get_build() ) or croak "No current build!"; |
540
|
|
|
|
|
|
|
|
541
|
1422
|
100
|
|
|
|
3566
|
croak "'$build' does not support array item checks" |
542
|
|
|
|
|
|
|
unless $build->can('add_item'); |
543
|
|
|
|
|
|
|
|
544
|
1421
|
100
|
|
|
|
2550
|
croak "'item' should only ever be called in void context" |
545
|
|
|
|
|
|
|
if defined wantarray; |
546
|
|
|
|
|
|
|
|
547
|
1420
|
|
|
|
|
3264
|
my @caller = caller; |
548
|
1420
|
|
|
|
|
3626
|
push @args => Test2::Compare::Wildcard->new( |
549
|
|
|
|
|
|
|
expect => $expect, |
550
|
|
|
|
|
|
|
file => $caller[1], |
551
|
|
|
|
|
|
|
lines => [$caller[2]], |
552
|
|
|
|
|
|
|
); |
553
|
|
|
|
|
|
|
|
554
|
1420
|
|
|
|
|
4810
|
$build->add_item(@args); |
555
|
|
|
|
|
|
|
} |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
sub field($$) { |
558
|
965
|
|
|
965
|
1
|
2228
|
my ($name, $expect) = @_; |
559
|
|
|
|
|
|
|
|
560
|
965
|
100
|
|
|
|
1599
|
defined( my $build = get_build() ) or croak "No current build!"; |
561
|
|
|
|
|
|
|
|
562
|
964
|
100
|
|
|
|
2659
|
croak "'$build' does not support hash field checks" |
563
|
|
|
|
|
|
|
unless $build->can('add_field'); |
564
|
|
|
|
|
|
|
|
565
|
963
|
100
|
|
|
|
1710
|
croak "'field' should only ever be called in void context" |
566
|
|
|
|
|
|
|
if defined wantarray; |
567
|
|
|
|
|
|
|
|
568
|
962
|
|
|
|
|
2145
|
my @caller = caller; |
569
|
962
|
|
|
|
|
2629
|
$build->add_field( |
570
|
|
|
|
|
|
|
$name, |
571
|
|
|
|
|
|
|
Test2::Compare::Wildcard->new( |
572
|
|
|
|
|
|
|
expect => $expect, |
573
|
|
|
|
|
|
|
file => $caller[1], |
574
|
|
|
|
|
|
|
lines => [$caller[2]], |
575
|
|
|
|
|
|
|
), |
576
|
|
|
|
|
|
|
); |
577
|
|
|
|
|
|
|
} |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
sub check($) { |
580
|
18
|
|
|
18
|
1
|
65
|
my ($check) = @_; |
581
|
|
|
|
|
|
|
|
582
|
18
|
100
|
|
|
|
38
|
defined( my $build = get_build() ) or croak "No current build!"; |
583
|
|
|
|
|
|
|
|
584
|
17
|
100
|
|
|
|
136
|
croak "'$build' is not a check-set" |
585
|
|
|
|
|
|
|
unless $build->can('add_check'); |
586
|
|
|
|
|
|
|
|
587
|
16
|
100
|
|
|
|
113
|
croak "'check' should only ever be called in void context" |
588
|
|
|
|
|
|
|
if defined wantarray; |
589
|
|
|
|
|
|
|
|
590
|
15
|
|
|
|
|
37
|
my @caller = caller; |
591
|
15
|
|
|
|
|
43
|
my $wc = Test2::Compare::Wildcard->new( |
592
|
|
|
|
|
|
|
expect => $check, |
593
|
|
|
|
|
|
|
file => $caller[1], |
594
|
|
|
|
|
|
|
lines => [$caller[2]], |
595
|
|
|
|
|
|
|
); |
596
|
|
|
|
|
|
|
|
597
|
15
|
|
|
|
|
72
|
$build->add_check($wc); |
598
|
|
|
|
|
|
|
} |
599
|
|
|
|
|
|
|
|
600
|
9
|
|
|
9
|
1
|
737
|
sub check_set { return _build_set('all' => @_) } |
601
|
9
|
|
|
9
|
1
|
480
|
sub in_set { return _build_set('any' => @_) } |
602
|
5
|
|
|
5
|
1
|
450
|
sub not_in_set { return _build_set('none' => @_) } |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
sub _build_set { |
605
|
23
|
|
|
23
|
|
66
|
my $redux = shift; |
606
|
23
|
|
|
|
|
52
|
my ($builder) = @_; |
607
|
23
|
|
100
|
|
|
101
|
my $btype = reftype($builder) || ''; |
608
|
|
|
|
|
|
|
|
609
|
23
|
|
|
|
|
68
|
my $set; |
610
|
23
|
100
|
|
|
|
71
|
if ($btype eq 'CODE') { |
611
|
7
|
|
|
|
|
19
|
$set = build('Test2::Compare::Set', $builder); |
612
|
6
|
|
|
|
|
18
|
$set->set_builder($builder); |
613
|
|
|
|
|
|
|
} |
614
|
|
|
|
|
|
|
else { |
615
|
16
|
|
|
|
|
192
|
$set = Test2::Compare::Set->new(checks => [@_]); |
616
|
|
|
|
|
|
|
} |
617
|
|
|
|
|
|
|
|
618
|
22
|
|
|
|
|
128
|
$set->set_reduction($redux); |
619
|
22
|
|
|
|
|
111
|
return $set; |
620
|
|
|
|
|
|
|
} |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
sub fail_events($;$) { |
623
|
37
|
|
|
37
|
1
|
282
|
my $event = &event(@_); |
624
|
|
|
|
|
|
|
|
625
|
37
|
|
|
|
|
68
|
my $diag = event('Diag'); |
626
|
|
|
|
|
|
|
|
627
|
37
|
50
|
|
|
|
98
|
return ($event, $diag) if defined wantarray; |
628
|
|
|
|
|
|
|
|
629
|
37
|
50
|
|
|
|
78
|
defined( my $build = get_build() ) or croak "No current build!"; |
630
|
37
|
|
|
|
|
113
|
$build->add_item($event); |
631
|
37
|
|
|
|
|
85
|
$build->add_item($diag); |
632
|
|
|
|
|
|
|
} |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
sub event($;$) { |
635
|
2195
|
|
|
2195
|
1
|
441955
|
my ($intype, $spec) = @_; |
636
|
|
|
|
|
|
|
|
637
|
2195
|
|
|
|
|
6437
|
my @caller = caller; |
638
|
|
|
|
|
|
|
|
639
|
2195
|
100
|
|
|
|
5328
|
croak "type is required" unless $intype; |
640
|
|
|
|
|
|
|
|
641
|
2194
|
|
|
|
|
3166
|
my $type; |
642
|
2194
|
100
|
|
|
|
6158
|
if ($intype =~ m/^\+(.*)$/) { |
643
|
99
|
|
|
|
|
797
|
$type = $1; |
644
|
|
|
|
|
|
|
} |
645
|
|
|
|
|
|
|
else { |
646
|
2095
|
|
|
|
|
4504
|
$type = "Test2::Event::$intype"; |
647
|
|
|
|
|
|
|
} |
648
|
|
|
|
|
|
|
|
649
|
2194
|
|
|
|
|
3352
|
my $event; |
650
|
2194
|
100
|
|
|
|
9459
|
if (!$spec) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
651
|
134
|
|
|
|
|
659
|
$event = Test2::Compare::Event->new( |
652
|
|
|
|
|
|
|
etype => $intype, |
653
|
|
|
|
|
|
|
file => $caller[1], |
654
|
|
|
|
|
|
|
lines => [$caller[2]], |
655
|
|
|
|
|
|
|
ending => 0, |
656
|
|
|
|
|
|
|
); |
657
|
|
|
|
|
|
|
} |
658
|
|
|
|
|
|
|
elsif (!ref $spec) { |
659
|
1
|
|
|
|
|
90
|
croak "'$spec' is not a valid event specification"; |
660
|
|
|
|
|
|
|
} |
661
|
|
|
|
|
|
|
elsif (reftype($spec) eq 'CODE') { |
662
|
841
|
|
|
|
|
2569
|
$event = build('Test2::Compare::Event', $spec); |
663
|
841
|
|
|
|
|
2804
|
$event->set_etype($intype); |
664
|
841
|
|
|
|
|
4844
|
$event->set_builder($spec); |
665
|
841
|
100
|
|
|
|
3437
|
$event->set_ending(0) unless defined $event->ending; |
666
|
|
|
|
|
|
|
} |
667
|
|
|
|
|
|
|
else { |
668
|
1218
|
|
|
|
|
5411
|
my $refcheck = Test2::Compare::Hash->new( |
669
|
|
|
|
|
|
|
inref => $spec, |
670
|
|
|
|
|
|
|
file => $caller[1], |
671
|
|
|
|
|
|
|
lines => [$caller[2]], |
672
|
|
|
|
|
|
|
); |
673
|
1218
|
|
|
|
|
6792
|
$event = Test2::Compare::Event->new( |
674
|
|
|
|
|
|
|
refcheck => $refcheck, |
675
|
|
|
|
|
|
|
file => $caller[1], |
676
|
|
|
|
|
|
|
lines => [$caller[2]], |
677
|
|
|
|
|
|
|
etype => $intype, |
678
|
|
|
|
|
|
|
ending => 0, |
679
|
|
|
|
|
|
|
); |
680
|
|
|
|
|
|
|
} |
681
|
|
|
|
|
|
|
|
682
|
2193
|
|
|
|
|
13026
|
$event->add_prop('blessed' => $type); |
683
|
|
|
|
|
|
|
|
684
|
2193
|
100
|
|
|
|
4738
|
return $event if defined wantarray; |
685
|
|
|
|
|
|
|
|
686
|
2108
|
100
|
|
|
|
4740
|
defined( my $build = get_build() ) or croak "No current build!"; |
687
|
2107
|
|
|
|
|
7880
|
$build->add_item($event); |
688
|
|
|
|
|
|
|
} |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
1; |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
__END__ |