line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Plugin::Warnings; |
2
|
95
|
|
|
95
|
|
991
|
use strict; |
|
95
|
|
|
|
|
173
|
|
|
95
|
|
|
|
|
2542
|
|
3
|
95
|
|
|
95
|
|
465
|
use warnings; |
|
95
|
|
|
|
|
175
|
|
|
95
|
|
|
|
|
2652
|
|
4
|
|
|
|
|
|
|
|
5
|
95
|
|
|
95
|
|
456
|
use Carp qw/croak/; |
|
95
|
|
|
|
|
174
|
|
|
95
|
|
|
|
|
4389
|
|
6
|
95
|
|
|
95
|
|
488
|
use Test::Stream::Util qw/protect/; |
|
95
|
|
|
|
|
164
|
|
|
95
|
|
|
|
|
605
|
|
7
|
|
|
|
|
|
|
|
8
|
95
|
|
|
95
|
|
503
|
use Test::Stream::Exporter; |
|
95
|
|
|
|
|
165
|
|
|
95
|
|
|
|
|
594
|
|
9
|
|
|
|
|
|
|
default_exports qw/warning warns no_warnings/; |
10
|
95
|
|
|
95
|
|
495
|
no Test::Stream::Exporter; |
|
95
|
|
|
|
|
158
|
|
|
95
|
|
|
|
|
380
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub warning(&) { |
13
|
17
|
|
100
|
17
|
1
|
135
|
my $warnings = &warns(@_) || []; |
14
|
17
|
100
|
|
|
|
58
|
if (@$warnings != 1) { |
15
|
2
|
|
|
|
|
11
|
warn $_ for @$warnings; |
16
|
2
|
|
|
|
|
265
|
croak "Got " . scalar(@$warnings) . " warnings, expected exactly 1" |
17
|
|
|
|
|
|
|
} |
18
|
15
|
|
|
|
|
85
|
return $warnings->[0]; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub no_warnings(&) { |
22
|
3
|
|
|
3
|
1
|
28
|
my $warnings = &warns(@_); |
23
|
3
|
100
|
|
|
|
14
|
return 1 unless defined $warnings; |
24
|
1
|
|
|
|
|
8
|
warn $_ for @$warnings; |
25
|
1
|
|
|
|
|
6
|
return 0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub warns(&) { |
29
|
35
|
|
|
35
|
1
|
151
|
my @warnings; |
30
|
|
|
|
|
|
|
local $SIG{__WARN__} = sub { |
31
|
41
|
|
|
41
|
|
808
|
push @warnings => @_; |
32
|
35
|
|
|
|
|
236
|
}; |
33
|
35
|
|
|
|
|
164
|
&protect(@_); |
34
|
35
|
100
|
|
|
|
140
|
return undef unless @warnings; |
35
|
29
|
|
|
|
|
363
|
return \@warnings; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |