line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::Warnings; |
2
|
156
|
|
|
156
|
|
1561
|
use strict; |
|
156
|
|
|
|
|
328
|
|
|
156
|
|
|
|
|
4872
|
|
3
|
156
|
|
|
156
|
|
789
|
use warnings; |
|
156
|
|
|
|
|
334
|
|
|
156
|
|
|
|
|
6732
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000156'; |
6
|
|
|
|
|
|
|
|
7
|
156
|
|
|
156
|
|
917
|
use Test2::API qw/context/; |
|
156
|
|
|
|
|
323
|
|
|
156
|
|
|
|
|
10672
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw/warns warning warnings no_warnings/; |
10
|
156
|
|
|
156
|
|
1132
|
use base 'Exporter'; |
|
156
|
|
|
|
|
465
|
|
|
156
|
|
|
|
|
69904
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub warns(&) { |
13
|
6
|
|
|
6
|
1
|
404
|
my $code = shift; |
14
|
6
|
|
|
|
|
10
|
my $warnings = 0; |
15
|
6
|
|
|
6
|
|
38
|
local $SIG{__WARN__} = sub { $warnings++ }; |
|
6
|
|
|
|
|
71
|
|
16
|
6
|
|
|
|
|
24
|
$code->(); |
17
|
6
|
|
|
|
|
107
|
return $warnings; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
2
|
1
|
8
|
sub no_warnings(&) { return !&warns(@_) } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub warning(&) { |
23
|
14
|
|
|
14
|
1
|
1116
|
my $code = shift; |
24
|
14
|
|
|
|
|
28
|
my @warnings; |
25
|
|
|
|
|
|
|
{ |
26
|
14
|
|
|
14
|
|
26
|
local $SIG{__WARN__} = sub { push @warnings => @_ }; |
|
14
|
|
|
|
|
78
|
|
|
14
|
|
|
|
|
336
|
|
27
|
14
|
|
|
|
|
47
|
$code->(); |
28
|
14
|
100
|
|
|
|
38053
|
return unless @warnings; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
13
|
100
|
|
|
|
46
|
if (@warnings > 1) { |
32
|
1
|
|
|
|
|
5
|
my $ctx = context(); |
33
|
1
|
|
|
|
|
140
|
$ctx->alert("Extra warnings in warning { ... }"); |
34
|
1
|
|
|
|
|
22
|
$ctx->note($_) for @warnings; |
35
|
1
|
|
|
|
|
552
|
$ctx->release; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
13
|
|
|
|
|
84
|
return $warnings[0]; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub warnings(&) { |
42
|
5
|
|
|
5
|
1
|
405
|
my $code = shift; |
43
|
|
|
|
|
|
|
|
44
|
5
|
|
|
|
|
11
|
my @warnings; |
45
|
5
|
|
|
10
|
|
32
|
local $SIG{__WARN__} = sub { push @warnings => @_ }; |
|
10
|
|
|
|
|
213
|
|
46
|
5
|
|
|
|
|
20
|
$code->(); |
47
|
|
|
|
|
|
|
|
48
|
5
|
|
|
|
|
133
|
return \@warnings; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |