line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Plugin::Warnings; |
2
|
95
|
|
|
95
|
|
984
|
use strict; |
|
95
|
|
|
|
|
165
|
|
|
95
|
|
|
|
|
2434
|
|
3
|
95
|
|
|
95
|
|
455
|
use warnings; |
|
95
|
|
|
|
|
166
|
|
|
95
|
|
|
|
|
2535
|
|
4
|
|
|
|
|
|
|
|
5
|
95
|
|
|
95
|
|
442
|
use Carp qw/croak/; |
|
95
|
|
|
|
|
180
|
|
|
95
|
|
|
|
|
4464
|
|
6
|
95
|
|
|
95
|
|
487
|
use Test::Stream::Util qw/protect/; |
|
95
|
|
|
|
|
154
|
|
|
95
|
|
|
|
|
720
|
|
7
|
|
|
|
|
|
|
|
8
|
95
|
|
|
95
|
|
486
|
use Test::Stream::Exporter; |
|
95
|
|
|
|
|
196
|
|
|
95
|
|
|
|
|
578
|
|
9
|
|
|
|
|
|
|
default_exports qw/warning warns no_warnings/; |
10
|
95
|
|
|
95
|
|
491
|
no Test::Stream::Exporter; |
|
95
|
|
|
|
|
162
|
|
|
95
|
|
|
|
|
375
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub warning(&) { |
13
|
17
|
|
100
|
17
|
1
|
128
|
my $warnings = &warns(@_) || []; |
14
|
17
|
100
|
|
|
|
62
|
if (@$warnings != 1) { |
15
|
2
|
|
|
|
|
11
|
warn $_ for @$warnings; |
16
|
2
|
|
|
|
|
291
|
croak "Got " . scalar(@$warnings) . " warnings, expected exactly 1" |
17
|
|
|
|
|
|
|
} |
18
|
15
|
|
|
|
|
79
|
return $warnings->[0]; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub no_warnings(&) { |
22
|
3
|
|
|
3
|
1
|
25
|
my $warnings = &warns(@_); |
23
|
3
|
100
|
|
|
|
16
|
return 1 unless defined $warnings; |
24
|
1
|
|
|
|
|
7
|
warn $_ for @$warnings; |
25
|
1
|
|
|
|
|
5
|
return 0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub warns(&) { |
29
|
35
|
|
|
35
|
1
|
138
|
my @warnings; |
30
|
|
|
|
|
|
|
local $SIG{__WARN__} = sub { |
31
|
41
|
|
|
41
|
|
801
|
push @warnings => @_; |
32
|
35
|
|
|
|
|
218
|
}; |
33
|
35
|
|
|
|
|
203
|
&protect(@_); |
34
|
35
|
100
|
|
|
|
150
|
return undef unless @warnings; |
35
|
29
|
|
|
|
|
262
|
return \@warnings; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |