line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::Warnings; |
2
|
156
|
|
|
156
|
|
1518
|
use strict; |
|
156
|
|
|
|
|
343
|
|
|
156
|
|
|
|
|
5159
|
|
3
|
156
|
|
|
156
|
|
871
|
use warnings; |
|
156
|
|
|
|
|
336
|
|
|
156
|
|
|
|
|
6934
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
6
|
|
|
|
|
|
|
|
7
|
156
|
|
|
156
|
|
927
|
use Test2::API qw/context/; |
|
156
|
|
|
|
|
335
|
|
|
156
|
|
|
|
|
11204
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw/warns warning warnings no_warnings/; |
10
|
156
|
|
|
156
|
|
1122
|
use base 'Exporter'; |
|
156
|
|
|
|
|
485
|
|
|
156
|
|
|
|
|
67420
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub warns(&) { |
13
|
6
|
|
|
6
|
1
|
404
|
my $code = shift; |
14
|
6
|
|
|
|
|
13
|
my $warnings = 0; |
15
|
6
|
|
|
6
|
|
33
|
local $SIG{__WARN__} = sub { $warnings++ }; |
|
6
|
|
|
|
|
73
|
|
16
|
6
|
|
|
|
|
21
|
$code->(); |
17
|
6
|
|
|
|
|
101
|
return $warnings; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
2
|
1
|
9
|
sub no_warnings(&) { return !&warns(@_) } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub warning(&) { |
23
|
14
|
|
|
14
|
1
|
1107
|
my $code = shift; |
24
|
14
|
|
|
|
|
27
|
my @warnings; |
25
|
|
|
|
|
|
|
{ |
26
|
14
|
|
|
14
|
|
24
|
local $SIG{__WARN__} = sub { push @warnings => @_ }; |
|
14
|
|
|
|
|
94
|
|
|
14
|
|
|
|
|
289
|
|
27
|
14
|
|
|
|
|
51
|
$code->(); |
28
|
14
|
100
|
|
|
|
18126
|
return unless @warnings; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
13
|
100
|
|
|
|
47
|
if (@warnings > 1) { |
32
|
1
|
|
|
|
|
16
|
my $ctx = context(); |
33
|
1
|
|
|
|
|
112
|
$ctx->alert("Extra warnings in warning { ... }"); |
34
|
1
|
|
|
|
|
12
|
$ctx->note($_) for @warnings; |
35
|
1
|
|
|
|
|
547
|
$ctx->release; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
13
|
|
|
|
|
87
|
return $warnings[0]; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub warnings(&) { |
42
|
5
|
|
|
5
|
1
|
339
|
my $code = shift; |
43
|
|
|
|
|
|
|
|
44
|
5
|
|
|
|
|
9
|
my @warnings; |
45
|
5
|
|
|
10
|
|
35
|
local $SIG{__WARN__} = sub { push @warnings => @_ }; |
|
10
|
|
|
|
|
182
|
|
46
|
5
|
|
|
|
|
19
|
$code->(); |
47
|
|
|
|
|
|
|
|
48
|
5
|
|
|
|
|
109
|
return \@warnings; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |