blob: 208bf26b1504f499442eae14c549b63468e8e161 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
pp_hot.c AOK
Filehandle %s never opened
$f = $a = "abc" ; print $f $a
Filehandle %s opened only for input
print STDIN "abc" ;
Filehandle %s opened only for output
print <STDOUT> ;
print on closed filehandle %s
close STDIN ; print STDIN "abc" ;
uninitialized
my $a = undef ; my @b = @$a
uninitialized
my $a = undef ; my %b = %$a
Odd number of elements in hash list
%X = (1,2,3) ;
Reference found where even-sized list expected
$X = [ 1 ..3 ];
Read on closed filehandle %s
close STDIN ; $a = <STDIN>;
Deep recursion on subroutine \"%s\"
sub fred { fred() if $a++ < 200} fred()
Deep recursion on anonymous subroutine
$a = sub { &$a if $a++ < 200} &$a
__END__
# pp_hot.c
use warning 'unopened' ;
$f = $a = "abc" ;
print $f $a;
no warning 'unopened' ;
print $f $a;
EXPECT
Filehandle main::abc never opened at - line 4.
########
# pp_hot.c
use warning 'io' ;
print STDIN "anc";
print <STDOUT>;
print <STDERR>;
open(FOO, ">&STDOUT") and print <FOO>;
print getc(STDERR);
print getc(FOO);
read(FOO,$_,1);
no warning 'io' ;
print STDIN "anc";
####################################################################
# N O T E #
# This test is known to fail on Linux and *BSD systems with glibc. #
# The glibc development team is aware of the problem, and has #
# determined a fix for the next release of that library. #
####################################################################
EXPECT
Filehandle main::STDIN opened only for input at - line 3.
Filehandle main::STDOUT opened only for output at - line 4.
Filehandle main::STDERR opened only for output at - line 5.
Filehandle main::FOO opened only for output at - line 6.
Filehandle main::STDERR opened only for output at - line 7.
Filehandle main::FOO opened only for output at - line 8.
Filehandle main::FOO opened only for output at - line 9.
########
# pp_hot.c
use warning 'closed' ;
close STDIN ;
print STDIN "anc";
no warning 'closed' ;
print STDIN "anc";
EXPECT
print on closed filehandle main::STDIN at - line 4.
########
# pp_hot.c
use warning 'uninitialized' ;
my $a = undef ;
my @b = @$a;
no warning 'uninitialized' ;
my @c = @$a;
EXPECT
Use of uninitialized value at - line 4.
########
# pp_hot.c
use warning 'uninitialized' ;
my $a = undef ;
my %b = %$a;
no warning 'uninitialized' ;
my %c = %$a;
EXPECT
Use of uninitialized value at - line 4.
########
# pp_hot.c
use warning 'unsafe' ;
my %X ; %X = (1,2,3) ;
no warning 'unsafe' ;
my %Y ; %Y = (1,2,3) ;
EXPECT
Odd number of elements in hash assignment at - line 3.
########
# pp_hot.c
use warning 'unsafe' ;
my %X ; %X = [1 .. 3] ;
no warning 'unsafe' ;
my %Y ; %Y = [1 .. 3] ;
EXPECT
Reference found where even-sized list expected at - line 3.
########
# pp_hot.c
use warning 'closed' ;
close STDIN ; $a = <STDIN> ;
no warning 'closed' ;
$a = <STDIN> ;
EXPECT
Read on closed filehandle main::STDIN at - line 3.
########
# pp_hot.c
use warning 'recursion' ;
sub fred
{
fred() if $a++ < 200
}
{
local $SIG{__WARN__} = sub {
die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/
};
fred();
}
EXPECT
ok
########
# pp_hot.c
no warning 'recursion' ;
sub fred
{
fred() if $a++ < 200
}
{
local $SIG{__WARN__} = sub {
die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/
};
fred();
}
EXPECT
########
# pp_hot.c
use warning 'recursion' ;
$b = sub
{
&$b if $a++ < 200
} ;
&$b ;
EXPECT
Deep recursion on anonymous subroutine at - line 5.
########
# pp_hot.c
no warning 'recursion' ;
$b = sub
{
&$b if $a++ < 200
} ;
&$b ;
EXPECT
|