line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::Compare; |
2
|
164
|
|
|
164
|
|
7286
|
use strict; |
|
164
|
|
|
|
|
385
|
|
|
164
|
|
|
|
|
4673
|
|
3
|
164
|
|
|
164
|
|
894
|
use warnings; |
|
164
|
|
|
|
|
4285
|
|
|
164
|
|
|
|
|
7629
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
6
|
|
|
|
|
|
|
|
7
|
164
|
|
|
164
|
|
1119
|
use Carp qw/croak/; |
|
164
|
|
|
|
|
408
|
|
|
164
|
|
|
|
|
8056
|
|
8
|
164
|
|
|
164
|
|
1429
|
use Scalar::Util qw/reftype/; |
|
164
|
|
|
|
|
503
|
|
|
164
|
|
|
|
|
8592
|
|
9
|
|
|
|
|
|
|
|
10
|
164
|
|
|
164
|
|
1708
|
use Test2::API qw/context/; |
|
164
|
|
|
|
|
74022
|
|
|
164
|
|
|
|
|
8178
|
|
11
|
164
|
|
|
164
|
|
66304
|
use Test2::Util::Ref qw/rtype/; |
|
164
|
|
|
|
|
446
|
|
|
164
|
|
|
|
|
9126
|
|
12
|
164
|
|
|
164
|
|
1148
|
use Test2::Util qw/pkg_to_file/; |
|
164
|
|
|
|
|
338
|
|
|
164
|
|
|
|
|
7228
|
|
13
|
|
|
|
|
|
|
|
14
|
164
|
|
|
|
|
12521
|
use Test2::Compare qw{ |
15
|
|
|
|
|
|
|
compare |
16
|
|
|
|
|
|
|
get_build push_build pop_build build |
17
|
|
|
|
|
|
|
strict_convert relaxed_convert |
18
|
164
|
|
|
164
|
|
70065
|
}; |
|
164
|
|
|
|
|
447
|
|
19
|
|
|
|
|
|
|
|
20
|
164
|
|
|
164
|
|
71686
|
use Test2::Compare::Array(); |
|
164
|
|
|
|
|
614
|
|
|
164
|
|
|
|
|
4905
|
|
21
|
164
|
|
|
164
|
|
76814
|
use Test2::Compare::Bag(); |
|
164
|
|
|
|
|
445
|
|
|
164
|
|
|
|
|
3655
|
|
22
|
164
|
|
|
164
|
|
67196
|
use Test2::Compare::Bool(); |
|
164
|
|
|
|
|
448
|
|
|
164
|
|
|
|
|
3619
|
|
23
|
164
|
|
|
164
|
|
73019
|
use Test2::Compare::Custom(); |
|
164
|
|
|
|
|
457
|
|
|
164
|
|
|
|
|
3505
|
|
24
|
164
|
|
|
164
|
|
65519
|
use Test2::Compare::Event(); |
|
164
|
|
|
|
|
465
|
|
|
164
|
|
|
|
|
3518
|
|
25
|
164
|
|
|
164
|
|
66626
|
use Test2::Compare::Float(); |
|
164
|
|
|
|
|
464
|
|
|
164
|
|
|
|
|
3573
|
|
26
|
164
|
|
|
164
|
|
70572
|
use Test2::Compare::Hash(); |
|
164
|
|
|
|
|
457
|
|
|
164
|
|
|
|
|
4112
|
|
27
|
164
|
|
|
164
|
|
1047
|
use Test2::Compare::Isa(); |
|
164
|
|
|
|
|
393
|
|
|
164
|
|
|
|
|
2364
|
|
28
|
164
|
|
|
164
|
|
812
|
use Test2::Compare::Meta(); |
|
164
|
|
|
|
|
355
|
|
|
164
|
|
|
|
|
2332
|
|
29
|
164
|
|
|
164
|
|
66998
|
use Test2::Compare::Number(); |
|
164
|
|
|
|
|
451
|
|
|
164
|
|
|
|
|
3507
|
|
30
|
164
|
|
|
164
|
|
1026
|
use Test2::Compare::Object(); |
|
164
|
|
|
|
|
394
|
|
|
164
|
|
|
|
|
2524
|
|
31
|
164
|
|
|
164
|
|
70025
|
use Test2::Compare::OrderedSubset(); |
|
164
|
|
|
|
|
523
|
|
|
164
|
|
|
|
|
3373
|
|
32
|
164
|
|
|
164
|
|
65881
|
use Test2::Compare::Pattern(); |
|
164
|
|
|
|
|
420
|
|
|
164
|
|
|
|
|
3682
|
|
33
|
164
|
|
|
164
|
|
64061
|
use Test2::Compare::Ref(); |
|
164
|
|
|
|
|
461
|
|
|
164
|
|
|
|
|
3340
|
|
34
|
164
|
|
|
164
|
|
64770
|
use Test2::Compare::DeepRef(); |
|
164
|
|
|
|
|
450
|
|
|
164
|
|
|
|
|
3293
|
|
35
|
164
|
|
|
164
|
|
62488
|
use Test2::Compare::Regex(); |
|
164
|
|
|
|
|
483
|
|
|
164
|
|
|
|
|
3284
|
|
36
|
164
|
|
|
164
|
|
64278
|
use Test2::Compare::Scalar(); |
|
164
|
|
|
|
|
439
|
|
|
164
|
|
|
|
|
3745
|
|
37
|
164
|
|
|
164
|
|
66217
|
use Test2::Compare::Set(); |
|
164
|
|
|
|
|
446
|
|
|
164
|
|
|
|
|
3507
|
|
38
|
164
|
|
|
164
|
|
64487
|
use Test2::Compare::String(); |
|
164
|
|
|
|
|
475
|
|
|
164
|
|
|
|
|
3339
|
|
39
|
164
|
|
|
164
|
|
63966
|
use Test2::Compare::Undef(); |
|
164
|
|
|
|
|
417
|
|
|
164
|
|
|
|
|
3284
|
|
40
|
164
|
|
|
164
|
|
64217
|
use Test2::Compare::Wildcard(); |
|
164
|
|
|
|
|
434
|
|
|
164
|
|
|
|
|
21431
|
|
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
|
164
|
|
|
164
|
|
1200
|
use base 'Exporter'; |
|
164
|
|
|
|
|
342
|
|
|
164
|
|
|
|
|
715322
|
|
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
|
1377
|
|
|
1377
|
1
|
82630
|
my ($got, $exp, $name, @diag) = @_; |
104
|
1377
|
|
|
|
|
4466
|
my $ctx = context(); |
105
|
|
|
|
|
|
|
|
106
|
1377
|
|
|
|
|
163621
|
my $delta = compare($got, $exp, \&strict_convert); |
107
|
|
|
|
|
|
|
|
108
|
1377
|
100
|
|
|
|
4811
|
if ($delta) { |
109
|
|
|
|
|
|
|
# Temporary thing. |
110
|
210
|
|
|
|
|
366
|
my $count = 0; |
111
|
210
|
|
|
|
|
310
|
my $implicit = 0; |
112
|
210
|
|
|
|
|
446
|
my @deltas = ($delta); |
113
|
210
|
|
|
|
|
545
|
while (my $d = shift @deltas) { |
114
|
313
|
|
|
|
|
1125
|
my $add = $d->children; |
115
|
313
|
100
|
100
|
|
|
1745
|
push @deltas => @$add if $add && @$add; |
116
|
313
|
100
|
|
|
|
658
|
next if $d->verified; |
117
|
252
|
|
|
|
|
1004
|
$count++; |
118
|
252
|
100
|
66
|
|
|
552
|
$implicit++ if $d->note && $d->note eq 'implicit end'; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
210
|
50
|
|
|
|
1319
|
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
|
210
|
|
|
|
|
542
|
$ctx->fail($name, $delta->diag, @diag); |
139
|
210
|
|
|
|
|
42710
|
$ctx->$_autodump($got); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
else { |
143
|
1167
|
|
|
|
|
4596
|
$ctx->ok(1, $name); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
1377
|
|
|
|
|
178346
|
$ctx->release; |
147
|
1377
|
|
|
|
|
39602
|
return !$delta; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub isnt($$;$@) { |
151
|
12
|
|
|
12
|
1
|
1150
|
my ($got, $exp, $name, @diag) = @_; |
152
|
12
|
|
|
|
|
239
|
my $ctx = context(); |
153
|
|
|
|
|
|
|
|
154
|
12
|
|
|
|
|
3577
|
my $delta = compare($got, $exp, \&strict_convert); |
155
|
|
|
|
|
|
|
|
156
|
12
|
100
|
|
|
|
190
|
if ($delta) { |
157
|
8
|
|
|
|
|
223
|
$ctx->ok(1, $name); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
else { |
160
|
4
|
|
|
|
|
22
|
$ctx->ok(0, $name, ["Comparison matched (it should not).", @diag]); |
161
|
4
|
|
|
|
|
2363
|
$ctx->$_autodump($got); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
12
|
|
|
|
|
4923
|
$ctx->release; |
165
|
12
|
100
|
|
|
|
891
|
return $delta ? 1 : 0; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub like($$;$@) { |
169
|
334
|
|
|
334
|
1
|
47414
|
my ($got, $exp, $name, @diag) = @_; |
170
|
334
|
|
|
|
|
1063
|
my $ctx = context(); |
171
|
|
|
|
|
|
|
|
172
|
334
|
|
|
|
|
33094
|
my $delta = compare($got, $exp, \&relaxed_convert); |
173
|
|
|
|
|
|
|
|
174
|
334
|
100
|
|
|
|
1686
|
if ($delta) { |
175
|
3
|
|
|
|
|
12
|
$ctx->fail($name, $delta->diag, @diag); |
176
|
3
|
|
|
|
|
652
|
$ctx->$_autodump($got); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
else { |
179
|
331
|
|
|
|
|
1457
|
$ctx->ok(1, $name); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
334
|
|
|
|
|
58481
|
$ctx->release; |
183
|
334
|
|
|
|
|
9925
|
return !$delta; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub unlike($$;$@) { |
187
|
9
|
|
|
9
|
1
|
731
|
my ($got, $exp, $name, @diag) = @_; |
188
|
9
|
|
|
|
|
24
|
my $ctx = context(); |
189
|
|
|
|
|
|
|
|
190
|
9
|
|
|
|
|
784
|
my $delta = compare($got, $exp, \&relaxed_convert); |
191
|
|
|
|
|
|
|
|
192
|
9
|
100
|
|
|
|
47
|
if ($delta) { |
193
|
4
|
|
|
|
|
14
|
$ctx->ok(1, $name); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
else { |
196
|
5
|
|
|
|
|
29
|
$ctx->ok(0, $name, ["Comparison matched (it should not).", @diag]); |
197
|
5
|
|
|
|
|
2772
|
$ctx->$_autodump($got); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
9
|
|
|
|
|
575
|
$ctx->release; |
201
|
9
|
100
|
|
|
|
254
|
return $delta ? 1 : 0; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
7
|
|
|
7
|
1
|
308
|
sub meta(&) { build('Test2::Compare::Meta', @_) } |
205
|
0
|
|
|
0
|
1
|
0
|
sub meta_check(&) { build('Test2::Compare::Meta', @_) } |
206
|
517
|
|
|
517
|
1
|
4013
|
sub hash(&) { build('Test2::Compare::Hash', @_) } |
207
|
631
|
|
|
631
|
1
|
603992
|
sub array(&) { build('Test2::Compare::Array', @_) } |
208
|
401
|
|
|
401
|
1
|
3106
|
sub bag(&) { build('Test2::Compare::Bag', @_) } |
209
|
10
|
|
|
10
|
1
|
378
|
sub object(&) { build('Test2::Compare::Object', @_) } |
210
|
31
|
|
|
31
|
1
|
36114
|
sub subset(&) { build('Test2::Compare::OrderedSubset', @_) } |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub U() { |
213
|
2
|
|
|
2
|
1
|
339
|
my @caller = caller; |
214
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
215
|
2
|
100
|
|
2
|
|
16
|
code => sub { defined $_ ? 0 : 1 }, name => 'UNDEFINED', operator => '!DEFINED()', |
|
2
|
|
|
|
|
12
|
|
216
|
|
|
|
|
|
|
file => $caller[1], |
217
|
|
|
|
|
|
|
lines => [$caller[2]], |
218
|
|
|
|
|
|
|
); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub D() { |
222
|
6
|
|
|
6
|
1
|
367
|
my @caller = caller; |
223
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
224
|
6
|
100
|
|
6
|
|
61
|
code => sub { defined $_ ? 1 : 0 }, name => 'DEFINED', operator => 'DEFINED()', |
|
6
|
|
|
|
|
23
|
|
225
|
|
|
|
|
|
|
file => $caller[1], |
226
|
|
|
|
|
|
|
lines => [$caller[2]], |
227
|
|
|
|
|
|
|
); |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub DF() { |
231
|
6
|
|
|
6
|
1
|
377
|
my @caller = caller; |
232
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
233
|
6
|
100
|
100
|
6
|
|
37
|
code => sub { defined $_ && ( ! ref $_ && ! $_ ) ? 1 : 0 }, name => 'DEFINED BUT FALSE', operator => 'DEFINED() && FALSE()', |
|
6
|
|
|
|
|
47
|
|
234
|
|
|
|
|
|
|
file => $caller[1], |
235
|
|
|
|
|
|
|
lines => [$caller[2]], |
236
|
|
|
|
|
|
|
); |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub DNE() { |
240
|
26
|
|
|
26
|
1
|
816
|
my @caller = caller; |
241
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
242
|
26
|
100
|
|
30
|
|
250
|
code => sub { my %p = @_; $p{exists} ? 0 : 1 }, name => '', operator => '!exists', |
|
30
|
|
|
|
|
112
|
|
|
30
|
|
|
|
|
120
|
|
243
|
|
|
|
|
|
|
file => $caller[1], |
244
|
|
|
|
|
|
|
lines => [$caller[2]], |
245
|
|
|
|
|
|
|
); |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub E() { |
249
|
2
|
|
|
2
|
1
|
312
|
my @caller = caller; |
250
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
251
|
2
|
100
|
|
2
|
|
21
|
code => sub { my %p = @_; $p{exists} ? 1 : 0 }, name => '', operator => '!exists', |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
10
|
|
252
|
|
|
|
|
|
|
file => $caller[1], |
253
|
|
|
|
|
|
|
lines => [$caller[2]], |
254
|
|
|
|
|
|
|
); |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub F() { |
258
|
32
|
|
|
32
|
1
|
682
|
my @caller = caller; |
259
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
260
|
32
|
100
|
|
30
|
|
227
|
code => sub { my %p = @_; $p{got} ? 0 : $p{exists} }, name => 'FALSE', operator => 'FALSE()', |
|
30
|
|
|
|
|
106
|
|
|
30
|
|
|
|
|
119
|
|
261
|
|
|
|
|
|
|
file => $caller[1], |
262
|
|
|
|
|
|
|
lines => [$caller[2]], |
263
|
|
|
|
|
|
|
); |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
sub FDNE() { |
267
|
6
|
|
|
6
|
1
|
445
|
my @caller = caller; |
268
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
269
|
|
|
|
|
|
|
code => sub { |
270
|
6
|
|
|
6
|
|
25
|
my %p = @_; |
271
|
6
|
100
|
|
|
|
20
|
return 1 unless $p{exists}; |
272
|
4
|
100
|
|
|
|
33
|
return $p{got} ? 0 : 1; |
273
|
|
|
|
|
|
|
}, |
274
|
6
|
|
|
|
|
42
|
name => 'FALSE', operator => 'FALSE() || !exists', |
275
|
|
|
|
|
|
|
file => $caller[1], |
276
|
|
|
|
|
|
|
lines => [$caller[2]], |
277
|
|
|
|
|
|
|
); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
sub T() { |
281
|
164
|
|
|
164
|
1
|
2772
|
my @caller = caller; |
282
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
283
|
|
|
|
|
|
|
code => sub { |
284
|
163
|
|
|
163
|
|
766
|
my %p = @_; |
285
|
163
|
50
|
|
|
|
572
|
return 0 unless $p{exists}; |
286
|
163
|
100
|
|
|
|
668
|
return $p{got} ? 1 : 0; |
287
|
|
|
|
|
|
|
}, |
288
|
164
|
|
|
|
|
2752
|
name => 'TRUE', operator => 'TRUE()', |
289
|
|
|
|
|
|
|
file => $caller[1], |
290
|
|
|
|
|
|
|
lines => [$caller[2]], |
291
|
|
|
|
|
|
|
); |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
sub L() { |
295
|
5
|
|
|
5
|
1
|
436
|
my @caller = caller; |
296
|
|
|
|
|
|
|
Test2::Compare::Custom->new( |
297
|
5
|
100
|
100
|
5
|
|
36
|
code => sub { defined $_ && length $_ ? 1 : 0 }, name => 'LENGTH', operator => 'DEFINED() && LENGTH()', |
|
5
|
|
|
|
|
37
|
|
298
|
|
|
|
|
|
|
file => $caller[1], |
299
|
|
|
|
|
|
|
lines => [$caller[2]], |
300
|
|
|
|
|
|
|
); |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
sub exact_ref($) { |
304
|
30
|
|
|
30
|
1
|
648
|
my @caller = caller; |
305
|
30
|
|
|
|
|
163
|
return Test2::Compare::Ref->new( |
306
|
|
|
|
|
|
|
file => $caller[1], |
307
|
|
|
|
|
|
|
lines => [$caller[2]], |
308
|
|
|
|
|
|
|
input => $_[0], |
309
|
|
|
|
|
|
|
); |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub match($) { |
313
|
548
|
|
|
548
|
1
|
10375
|
my @caller = caller; |
314
|
548
|
|
|
|
|
2285
|
return Test2::Compare::Pattern->new( |
315
|
|
|
|
|
|
|
file => $caller[1], |
316
|
|
|
|
|
|
|
lines => [$caller[2]], |
317
|
|
|
|
|
|
|
pattern => $_[0], |
318
|
|
|
|
|
|
|
); |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
sub mismatch($) { |
322
|
4
|
|
|
4
|
1
|
513
|
my @caller = caller; |
323
|
4
|
|
|
|
|
31
|
return Test2::Compare::Pattern->new( |
324
|
|
|
|
|
|
|
file => $caller[1], |
325
|
|
|
|
|
|
|
lines => [$caller[2]], |
326
|
|
|
|
|
|
|
negate => 1, |
327
|
|
|
|
|
|
|
pattern => $_[0], |
328
|
|
|
|
|
|
|
); |
329
|
|
|
|
|
|
|
} |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
sub validator { |
332
|
6
|
|
|
6
|
1
|
28100
|
my $code = pop; |
333
|
6
|
|
|
|
|
18
|
my $cname = pop; |
334
|
6
|
|
|
|
|
14
|
my $op = pop; |
335
|
|
|
|
|
|
|
|
336
|
6
|
|
|
|
|
31
|
my @caller = caller; |
337
|
6
|
|
|
|
|
87
|
return Test2::Compare::Custom->new( |
338
|
|
|
|
|
|
|
file => $caller[1], |
339
|
|
|
|
|
|
|
lines => [$caller[2]], |
340
|
|
|
|
|
|
|
code => $code, |
341
|
|
|
|
|
|
|
name => $cname, |
342
|
|
|
|
|
|
|
operator => $op, |
343
|
|
|
|
|
|
|
); |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
sub number($;@) { |
347
|
3
|
|
|
3
|
1
|
253
|
my ($num, @args) = @_; |
348
|
3
|
|
|
|
|
11
|
my @caller = caller; |
349
|
3
|
|
|
|
|
25
|
return Test2::Compare::Number->new( |
350
|
|
|
|
|
|
|
file => $caller[1], |
351
|
|
|
|
|
|
|
lines => [$caller[2]], |
352
|
|
|
|
|
|
|
input => $num, |
353
|
|
|
|
|
|
|
@args, |
354
|
|
|
|
|
|
|
); |
355
|
|
|
|
|
|
|
} |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
sub float($;@) { |
358
|
6
|
|
|
6
|
1
|
458
|
my ($num, @args) = @_; |
359
|
6
|
|
|
|
|
22
|
my @caller = caller; |
360
|
6
|
|
|
|
|
37
|
return Test2::Compare::Float->new( |
361
|
|
|
|
|
|
|
file => $caller[1], |
362
|
|
|
|
|
|
|
lines => [$caller[2]], |
363
|
|
|
|
|
|
|
input => $num, |
364
|
|
|
|
|
|
|
@args, |
365
|
|
|
|
|
|
|
); |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
sub rounded($$) { |
369
|
1
|
|
|
1
|
1
|
20
|
my ($num, $precision) = @_; |
370
|
1
|
|
|
|
|
7
|
my @caller = caller; |
371
|
1
|
|
|
|
|
11
|
return Test2::Compare::Float->new( |
372
|
|
|
|
|
|
|
file => $caller[1], |
373
|
|
|
|
|
|
|
lines => [$caller[2]], |
374
|
|
|
|
|
|
|
input => $num, |
375
|
|
|
|
|
|
|
precision => $precision, |
376
|
|
|
|
|
|
|
); |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
sub within($;$) { |
380
|
2
|
|
|
2
|
1
|
202
|
my ($num, $tolerance) = @_; |
381
|
2
|
|
|
|
|
8
|
my @caller = caller; |
382
|
2
|
100
|
|
|
|
10
|
return Test2::Compare::Float->new( |
383
|
|
|
|
|
|
|
file => $caller[1], |
384
|
|
|
|
|
|
|
lines => [$caller[2]], |
385
|
|
|
|
|
|
|
input => $num, |
386
|
|
|
|
|
|
|
defined $tolerance ? ( tolerance => $tolerance ) : (), |
387
|
|
|
|
|
|
|
); |
388
|
|
|
|
|
|
|
} |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
sub bool($;@) { |
391
|
203
|
|
|
203
|
1
|
31303
|
my ($bool, @args) = @_; |
392
|
203
|
|
|
|
|
719
|
my @caller = caller; |
393
|
203
|
|
|
|
|
886
|
return Test2::Compare::Bool->new( |
394
|
|
|
|
|
|
|
file => $caller[1], |
395
|
|
|
|
|
|
|
lines => [$caller[2]], |
396
|
|
|
|
|
|
|
input => $bool, |
397
|
|
|
|
|
|
|
@args, |
398
|
|
|
|
|
|
|
); |
399
|
|
|
|
|
|
|
} |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
sub string($;@) { |
402
|
4
|
|
|
4
|
1
|
234
|
my ($str, @args) = @_; |
403
|
4
|
|
|
|
|
17
|
my @caller = caller; |
404
|
4
|
|
|
|
|
38
|
return Test2::Compare::String->new( |
405
|
|
|
|
|
|
|
file => $caller[1], |
406
|
|
|
|
|
|
|
lines => [$caller[2]], |
407
|
|
|
|
|
|
|
input => $str, |
408
|
|
|
|
|
|
|
@args, |
409
|
|
|
|
|
|
|
); |
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
sub check_isa($;@) { |
413
|
3
|
|
|
3
|
1
|
372
|
my ($class_name, @args) = @_; |
414
|
3
|
|
|
|
|
16
|
my @caller = caller; |
415
|
3
|
|
|
|
|
26
|
return Test2::Compare::Isa->new( |
416
|
|
|
|
|
|
|
file => $caller[1], |
417
|
|
|
|
|
|
|
lines => [$caller[2]], |
418
|
|
|
|
|
|
|
input => $class_name, |
419
|
|
|
|
|
|
|
@args, |
420
|
|
|
|
|
|
|
); |
421
|
|
|
|
|
|
|
} |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
sub filter_items(&) { |
424
|
18
|
100
|
|
18
|
1
|
222
|
defined( my $build = get_build() ) or croak "No current build!"; |
425
|
|
|
|
|
|
|
|
426
|
17
|
100
|
|
|
|
195
|
croak "'$build' does not support filters" |
427
|
|
|
|
|
|
|
unless $build->can('add_filter'); |
428
|
|
|
|
|
|
|
|
429
|
16
|
100
|
|
|
|
165
|
croak "'filter_items' should only ever be called in void context" |
430
|
|
|
|
|
|
|
if defined wantarray; |
431
|
|
|
|
|
|
|
|
432
|
15
|
|
|
|
|
68
|
$build->add_filter(@_); |
433
|
|
|
|
|
|
|
} |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
sub all_items { |
436
|
5
|
50
|
|
5
|
1
|
30
|
defined( my $build = get_build() ) or croak "No current build!"; |
437
|
|
|
|
|
|
|
|
438
|
5
|
50
|
|
|
|
27
|
croak "'$build' does not support all-items" |
439
|
|
|
|
|
|
|
unless $build->can('add_for_each'); |
440
|
|
|
|
|
|
|
|
441
|
5
|
50
|
|
|
|
19
|
croak "'all_items' should only ever be called in void context" |
442
|
|
|
|
|
|
|
if defined wantarray; |
443
|
|
|
|
|
|
|
|
444
|
5
|
|
|
|
|
22
|
$build->add_for_each(@_); |
445
|
|
|
|
|
|
|
} |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
sub all_keys { |
448
|
2
|
50
|
|
2
|
1
|
21
|
defined( my $build = get_build() ) or croak "No current build!"; |
449
|
|
|
|
|
|
|
|
450
|
2
|
50
|
|
|
|
12
|
croak "'$build' does not support all-keys" |
451
|
|
|
|
|
|
|
unless $build->can('add_for_each_key'); |
452
|
|
|
|
|
|
|
|
453
|
2
|
50
|
|
|
|
15
|
croak "'all_keys' should only ever be called in void context" |
454
|
|
|
|
|
|
|
if defined wantarray; |
455
|
|
|
|
|
|
|
|
456
|
2
|
|
|
|
|
14
|
$build->add_for_each_key(@_); |
457
|
|
|
|
|
|
|
} |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
*all_vals = *all_values; |
460
|
|
|
|
|
|
|
sub all_values { |
461
|
2
|
50
|
|
2
|
1
|
14
|
defined( my $build = get_build() ) or croak "No current build!"; |
462
|
|
|
|
|
|
|
|
463
|
2
|
50
|
|
|
|
11
|
croak "'$build' does not support all-values" |
464
|
|
|
|
|
|
|
unless $build->can('add_for_each_val'); |
465
|
|
|
|
|
|
|
|
466
|
2
|
50
|
|
|
|
7
|
croak "'all_values' should only ever be called in void context" |
467
|
|
|
|
|
|
|
if defined wantarray; |
468
|
|
|
|
|
|
|
|
469
|
2
|
|
|
|
|
8
|
$build->add_for_each_val(@_); |
470
|
|
|
|
|
|
|
} |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
sub end() { |
474
|
318
|
100
|
|
318
|
1
|
2701
|
defined( my $build = get_build() ) or croak "No current build!"; |
475
|
|
|
|
|
|
|
|
476
|
317
|
100
|
|
|
|
1509
|
croak "'$build' does not support 'ending'" |
477
|
|
|
|
|
|
|
unless $build->can('ending'); |
478
|
|
|
|
|
|
|
|
479
|
316
|
100
|
|
|
|
977
|
croak "'end' should only ever be called in void context" |
480
|
|
|
|
|
|
|
if defined wantarray; |
481
|
|
|
|
|
|
|
|
482
|
315
|
|
|
|
|
989
|
$build->set_ending(1); |
483
|
|
|
|
|
|
|
} |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
sub etc() { |
486
|
1040
|
50
|
|
1040
|
1
|
3017
|
defined( my $build = get_build() ) or croak "No current build!"; |
487
|
|
|
|
|
|
|
|
488
|
1040
|
50
|
|
|
|
3113
|
croak "'$build' does not support 'ending'" |
489
|
|
|
|
|
|
|
unless $build->can('ending'); |
490
|
|
|
|
|
|
|
|
491
|
1040
|
50
|
|
|
|
2055
|
croak "'etc' should only ever be called in void context" |
492
|
|
|
|
|
|
|
if defined wantarray; |
493
|
|
|
|
|
|
|
|
494
|
1040
|
|
|
|
|
2270
|
$build->set_ending(0); |
495
|
|
|
|
|
|
|
} |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
my $_call = sub { |
498
|
|
|
|
|
|
|
my ($name, $expect, $context, $func_name) = @_; |
499
|
|
|
|
|
|
|
defined( my $build = get_build() ) or croak "No current build!"; |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
croak "'$build' does not support method calls" |
502
|
|
|
|
|
|
|
unless $build->can('add_call'); |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
croak "'$func_name' should only ever be called in void context" |
505
|
|
|
|
|
|
|
if defined wantarray; |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
my @caller = caller; |
508
|
|
|
|
|
|
|
$build->add_call( |
509
|
|
|
|
|
|
|
$name, |
510
|
|
|
|
|
|
|
Test2::Compare::Wildcard->new( |
511
|
|
|
|
|
|
|
expect => $expect, |
512
|
|
|
|
|
|
|
file => $caller[1], |
513
|
|
|
|
|
|
|
lines => [$caller[2]], |
514
|
|
|
|
|
|
|
), |
515
|
|
|
|
|
|
|
undef, |
516
|
|
|
|
|
|
|
$context, |
517
|
|
|
|
|
|
|
); |
518
|
|
|
|
|
|
|
}; |
519
|
|
|
|
|
|
|
|
520
|
1830
|
|
|
1830
|
1
|
47947
|
sub call($$) { $_call->(@_,'scalar','call') } |
521
|
7
|
|
|
7
|
1
|
82
|
sub call_list($$) { $_call->(@_,'list','call_list') } |
522
|
7
|
|
|
7
|
1
|
105
|
sub call_hash($$) { $_call->(@_,'hash','call_hash') } |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
sub prop($$) { |
525
|
822
|
|
|
822
|
1
|
8543
|
my ($name, $expect) = @_; |
526
|
822
|
100
|
|
|
|
1956
|
defined( my $build = get_build() ) or croak "No current build!"; |
527
|
|
|
|
|
|
|
|
528
|
821
|
50
|
|
|
|
2756
|
croak "'$build' does not support meta-checks" |
529
|
|
|
|
|
|
|
unless $build->can('add_prop'); |
530
|
|
|
|
|
|
|
|
531
|
821
|
100
|
|
|
|
1793
|
croak "'prop' should only ever be called in void context" |
532
|
|
|
|
|
|
|
if defined wantarray; |
533
|
|
|
|
|
|
|
|
534
|
820
|
|
|
|
|
2680
|
my @caller = caller; |
535
|
820
|
|
|
|
|
3533
|
$build->add_prop( |
536
|
|
|
|
|
|
|
$name, |
537
|
|
|
|
|
|
|
Test2::Compare::Wildcard->new( |
538
|
|
|
|
|
|
|
expect => $expect, |
539
|
|
|
|
|
|
|
file => $caller[1], |
540
|
|
|
|
|
|
|
lines => [$caller[2]], |
541
|
|
|
|
|
|
|
), |
542
|
|
|
|
|
|
|
); |
543
|
|
|
|
|
|
|
} |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
sub item($;$) { |
546
|
1423
|
|
|
1423
|
1
|
4546
|
my @args = @_; |
547
|
1423
|
|
|
|
|
2213
|
my $expect = pop @args; |
548
|
|
|
|
|
|
|
|
549
|
1423
|
100
|
|
|
|
2656
|
defined( my $build = get_build() ) or croak "No current build!"; |
550
|
|
|
|
|
|
|
|
551
|
1422
|
100
|
|
|
|
4158
|
croak "'$build' does not support array item checks" |
552
|
|
|
|
|
|
|
unless $build->can('add_item'); |
553
|
|
|
|
|
|
|
|
554
|
1421
|
100
|
|
|
|
2820
|
croak "'item' should only ever be called in void context" |
555
|
|
|
|
|
|
|
if defined wantarray; |
556
|
|
|
|
|
|
|
|
557
|
1420
|
|
|
|
|
3684
|
my @caller = caller; |
558
|
1420
|
|
|
|
|
4365
|
push @args => Test2::Compare::Wildcard->new( |
559
|
|
|
|
|
|
|
expect => $expect, |
560
|
|
|
|
|
|
|
file => $caller[1], |
561
|
|
|
|
|
|
|
lines => [$caller[2]], |
562
|
|
|
|
|
|
|
); |
563
|
|
|
|
|
|
|
|
564
|
1420
|
|
|
|
|
5837
|
$build->add_item(@args); |
565
|
|
|
|
|
|
|
} |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
sub field($$) { |
568
|
967
|
|
|
967
|
1
|
2860
|
my ($name, $expect) = @_; |
569
|
|
|
|
|
|
|
|
570
|
967
|
100
|
|
|
|
1955
|
defined( my $build = get_build() ) or croak "No current build!"; |
571
|
|
|
|
|
|
|
|
572
|
966
|
100
|
|
|
|
3117
|
croak "'$build' does not support hash field checks" |
573
|
|
|
|
|
|
|
unless $build->can('add_field'); |
574
|
|
|
|
|
|
|
|
575
|
965
|
100
|
|
|
|
2003
|
croak "'field' should only ever be called in void context" |
576
|
|
|
|
|
|
|
if defined wantarray; |
577
|
|
|
|
|
|
|
|
578
|
964
|
|
|
|
|
2384
|
my @caller = caller; |
579
|
964
|
|
|
|
|
3106
|
$build->add_field( |
580
|
|
|
|
|
|
|
$name, |
581
|
|
|
|
|
|
|
Test2::Compare::Wildcard->new( |
582
|
|
|
|
|
|
|
expect => $expect, |
583
|
|
|
|
|
|
|
file => $caller[1], |
584
|
|
|
|
|
|
|
lines => [$caller[2]], |
585
|
|
|
|
|
|
|
), |
586
|
|
|
|
|
|
|
); |
587
|
|
|
|
|
|
|
} |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
sub check($) { |
590
|
18
|
|
|
18
|
1
|
125
|
my ($check) = @_; |
591
|
|
|
|
|
|
|
|
592
|
18
|
100
|
|
|
|
38
|
defined( my $build = get_build() ) or croak "No current build!"; |
593
|
|
|
|
|
|
|
|
594
|
17
|
100
|
|
|
|
255
|
croak "'$build' is not a check-set" |
595
|
|
|
|
|
|
|
unless $build->can('add_check'); |
596
|
|
|
|
|
|
|
|
597
|
16
|
100
|
|
|
|
188
|
croak "'check' should only ever be called in void context" |
598
|
|
|
|
|
|
|
if defined wantarray; |
599
|
|
|
|
|
|
|
|
600
|
15
|
|
|
|
|
37
|
my @caller = caller; |
601
|
15
|
|
|
|
|
54
|
my $wc = Test2::Compare::Wildcard->new( |
602
|
|
|
|
|
|
|
expect => $check, |
603
|
|
|
|
|
|
|
file => $caller[1], |
604
|
|
|
|
|
|
|
lines => [$caller[2]], |
605
|
|
|
|
|
|
|
); |
606
|
|
|
|
|
|
|
|
607
|
15
|
|
|
|
|
64
|
$build->add_check($wc); |
608
|
|
|
|
|
|
|
} |
609
|
|
|
|
|
|
|
|
610
|
9
|
|
|
9
|
1
|
947
|
sub check_set { return _build_set('all' => @_) } |
611
|
9
|
|
|
9
|
1
|
556
|
sub in_set { return _build_set('any' => @_) } |
612
|
5
|
|
|
5
|
1
|
610
|
sub not_in_set { return _build_set('none' => @_) } |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
sub _build_set { |
615
|
23
|
|
|
23
|
|
83
|
my $redux = shift; |
616
|
23
|
|
|
|
|
69
|
my ($builder) = @_; |
617
|
23
|
|
100
|
|
|
151
|
my $btype = reftype($builder) || ''; |
618
|
|
|
|
|
|
|
|
619
|
23
|
|
|
|
|
48
|
my $set; |
620
|
23
|
100
|
|
|
|
85
|
if ($btype eq 'CODE') { |
621
|
7
|
|
|
|
|
36
|
$set = build('Test2::Compare::Set', $builder); |
622
|
6
|
|
|
|
|
26
|
$set->set_builder($builder); |
623
|
|
|
|
|
|
|
} |
624
|
|
|
|
|
|
|
else { |
625
|
16
|
|
|
|
|
180
|
$set = Test2::Compare::Set->new(checks => [@_]); |
626
|
|
|
|
|
|
|
} |
627
|
|
|
|
|
|
|
|
628
|
22
|
|
|
|
|
115
|
$set->set_reduction($redux); |
629
|
22
|
|
|
|
|
192
|
return $set; |
630
|
|
|
|
|
|
|
} |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
sub fail_events($;$) { |
633
|
37
|
|
|
37
|
1
|
532
|
my $event = &event(@_); |
634
|
|
|
|
|
|
|
|
635
|
37
|
|
|
|
|
109
|
my $diag = event('Diag'); |
636
|
|
|
|
|
|
|
|
637
|
37
|
50
|
|
|
|
142
|
return ($event, $diag) if defined wantarray; |
638
|
|
|
|
|
|
|
|
639
|
37
|
50
|
|
|
|
121
|
defined( my $build = get_build() ) or croak "No current build!"; |
640
|
37
|
|
|
|
|
141
|
$build->add_item($event); |
641
|
37
|
|
|
|
|
101
|
$build->add_item($diag); |
642
|
|
|
|
|
|
|
} |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
sub event($;$) { |
645
|
2195
|
|
|
2195
|
1
|
525299
|
my ($intype, $spec) = @_; |
646
|
|
|
|
|
|
|
|
647
|
2195
|
|
|
|
|
6678
|
my @caller = caller; |
648
|
|
|
|
|
|
|
|
649
|
2195
|
100
|
|
|
|
6281
|
croak "type is required" unless $intype; |
650
|
|
|
|
|
|
|
|
651
|
2194
|
|
|
|
|
3326
|
my $type; |
652
|
2194
|
100
|
|
|
|
6559
|
if ($intype =~ m/^\+(.*)$/) { |
653
|
99
|
|
|
|
|
997
|
$type = $1; |
654
|
|
|
|
|
|
|
} |
655
|
|
|
|
|
|
|
else { |
656
|
2095
|
|
|
|
|
4635
|
$type = "Test2::Event::$intype"; |
657
|
|
|
|
|
|
|
} |
658
|
|
|
|
|
|
|
|
659
|
2194
|
|
|
|
|
3334
|
my $event; |
660
|
2194
|
100
|
|
|
|
9987
|
if (!$spec) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
661
|
134
|
|
|
|
|
927
|
$event = Test2::Compare::Event->new( |
662
|
|
|
|
|
|
|
etype => $intype, |
663
|
|
|
|
|
|
|
file => $caller[1], |
664
|
|
|
|
|
|
|
lines => [$caller[2]], |
665
|
|
|
|
|
|
|
ending => 0, |
666
|
|
|
|
|
|
|
); |
667
|
|
|
|
|
|
|
} |
668
|
|
|
|
|
|
|
elsif (!ref $spec) { |
669
|
1
|
|
|
|
|
112
|
croak "'$spec' is not a valid event specification"; |
670
|
|
|
|
|
|
|
} |
671
|
|
|
|
|
|
|
elsif (reftype($spec) eq 'CODE') { |
672
|
841
|
|
|
|
|
2850
|
$event = build('Test2::Compare::Event', $spec); |
673
|
841
|
|
|
|
|
3177
|
$event->set_etype($intype); |
674
|
841
|
|
|
|
|
4925
|
$event->set_builder($spec); |
675
|
841
|
100
|
|
|
|
3749
|
$event->set_ending(0) unless defined $event->ending; |
676
|
|
|
|
|
|
|
} |
677
|
|
|
|
|
|
|
else { |
678
|
1218
|
|
|
|
|
5847
|
my $refcheck = Test2::Compare::Hash->new( |
679
|
|
|
|
|
|
|
inref => $spec, |
680
|
|
|
|
|
|
|
file => $caller[1], |
681
|
|
|
|
|
|
|
lines => [$caller[2]], |
682
|
|
|
|
|
|
|
); |
683
|
1218
|
|
|
|
|
6971
|
$event = Test2::Compare::Event->new( |
684
|
|
|
|
|
|
|
refcheck => $refcheck, |
685
|
|
|
|
|
|
|
file => $caller[1], |
686
|
|
|
|
|
|
|
lines => [$caller[2]], |
687
|
|
|
|
|
|
|
etype => $intype, |
688
|
|
|
|
|
|
|
ending => 0, |
689
|
|
|
|
|
|
|
); |
690
|
|
|
|
|
|
|
} |
691
|
|
|
|
|
|
|
|
692
|
2193
|
|
|
|
|
14257
|
$event->add_prop('blessed' => $type); |
693
|
|
|
|
|
|
|
|
694
|
2193
|
100
|
|
|
|
5092
|
return $event if defined wantarray; |
695
|
|
|
|
|
|
|
|
696
|
2108
|
100
|
|
|
|
4760
|
defined( my $build = get_build() ) or croak "No current build!"; |
697
|
2107
|
|
|
|
|
8089
|
$build->add_item($event); |
698
|
|
|
|
|
|
|
} |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
1; |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
__END__ |