line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Plugin::Warnings; |
2
|
95
|
|
|
95
|
|
630
|
use strict; |
|
95
|
|
|
|
|
94
|
|
|
95
|
|
|
|
|
2118
|
|
3
|
95
|
|
|
95
|
|
279
|
use warnings; |
|
95
|
|
|
|
|
99
|
|
|
95
|
|
|
|
|
1862
|
|
4
|
|
|
|
|
|
|
|
5
|
95
|
|
|
95
|
|
270
|
use Carp qw/croak/; |
|
95
|
|
|
|
|
89
|
|
|
95
|
|
|
|
|
3449
|
|
6
|
95
|
|
|
95
|
|
314
|
use Test::Stream::Util qw/protect/; |
|
95
|
|
|
|
|
90
|
|
|
95
|
|
|
|
|
407
|
|
7
|
|
|
|
|
|
|
|
8
|
95
|
|
|
95
|
|
333
|
use Test::Stream::Exporter qw/import default_exports/; |
|
95
|
|
|
|
|
114
|
|
|
95
|
|
|
|
|
371
|
|
9
|
|
|
|
|
|
|
default_exports qw/warning warns no_warnings/; |
10
|
95
|
|
|
95
|
|
338
|
no Test::Stream::Exporter; |
|
95
|
|
|
|
|
99
|
|
|
95
|
|
|
|
|
249
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub warning(&) { |
13
|
17
|
|
100
|
17
|
1
|
101
|
my $warnings = &warns(@_) || []; |
14
|
17
|
100
|
|
|
|
42
|
if (@$warnings != 1) { |
15
|
2
|
|
|
|
|
8
|
warn $_ for @$warnings; |
16
|
2
|
|
|
|
|
196
|
croak "Got " . scalar(@$warnings) . " warnings, expected exactly 1" |
17
|
|
|
|
|
|
|
} |
18
|
15
|
|
|
|
|
63
|
return $warnings->[0]; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub no_warnings(&) { |
22
|
3
|
|
|
3
|
1
|
21
|
my $warnings = &warns(@_); |
23
|
3
|
100
|
|
|
|
9
|
return 1 unless defined $warnings; |
24
|
1
|
|
|
|
|
6
|
warn $_ for @$warnings; |
25
|
1
|
|
|
|
|
4
|
return 0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub warns(&) { |
29
|
35
|
|
|
35
|
1
|
110
|
my @warnings; |
30
|
|
|
|
|
|
|
local $SIG{__WARN__} = sub { |
31
|
41
|
|
|
41
|
|
664
|
push @warnings => @_; |
32
|
35
|
|
|
|
|
165
|
}; |
33
|
35
|
|
|
|
|
103
|
&protect(@_); |
34
|
35
|
100
|
|
|
|
103
|
return undef unless @warnings; |
35
|
29
|
|
|
|
|
214
|
return \@warnings; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |