This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
change#3612 is buggy when quotemeta argument matches target
[perl5.git] / t / pragma / warn / pp_sys
CommitLineData
599cee73
PM
1 pp_sys.c AOK
2
3 untie attempted while %d inner references still exist
4 sub TIESCALAR { bless [] } ; tie $a, 'main'; untie $a ;
5
af8c498a 6 Filehandle %s opened only for input
599cee73
PM
7 format STDIN =
8 .
9 write STDIN;
10
af8c498a 11 Write on closed filehandle %s
599cee73
PM
12 format STDIN =
13 .
14 close STDIN;
15 write STDIN ;
16
17 page overflow
18
19 Filehandle %s never opened
20 $a = "abc"; printf $a "fred"
21
22 Filehandle %s opened only for input
23 $a = "abc";
24 printf $a "fred"
25
26 printf on closed filehandle %s
27 close STDIN ;
28 printf STDIN "fred"
29
30 Syswrite on closed filehandle
31 close STDIN;
32 syswrite STDIN, "fred", 1;
33
34 Send on closed socket
35 close STDIN;
36 send STDIN, "fred", 1
37
38 bind() on closed fd
39 close STDIN;
40 bind STDIN, "fred" ;
41
42
43 connect() on closed fd
44 close STDIN;
45 connect STDIN, "fred" ;
46
47 listen() on closed fd
48 close STDIN;
49 listen STDIN, 2;
50
51 accept() on closed fd
52 close STDIN;
53 accept STDIN, "fred" ;
54
55 shutdown() on closed fd
56 close STDIN;
57 shutdown STDIN, 0;
58
59 [gs]etsockopt() on closed fd
60 close STDIN;
61 setsockopt STDIN, 1,2,3;
62 getsockopt STDIN, 1,2;
63
64 get{sock, peer}name() on closed fd
65 close STDIN;
66 getsockname STDIN;
67 getpeername STDIN;
68
69 warn(warn_nl, "stat");
70
71 Test on unopened file <%s>
72 close STDIN ; -T STDIN ;
73
74 warn(warn_nl, "open");
75 -T "abc\ndef" ;
76
77
78
79__END__
80# pp_sys.c
4438c4b7 81use warnings 'untie' ;
599cee73
PM
82sub TIESCALAR { bless [] } ;
83$b = tie $a, 'main';
84untie $a ;
4438c4b7 85no warnings 'untie' ;
0453d815
PM
86$c = tie $d, 'main';
87untie $d ;
599cee73
PM
88EXPECT
89untie attempted while 1 inner references still exist at - line 5.
90########
91# pp_sys.c
4438c4b7 92use warnings 'io' ;
599cee73
PM
93format STDIN =
94.
95write STDIN;
4438c4b7 96no warnings 'io' ;
0453d815 97write STDIN;
599cee73 98EXPECT
af8c498a 99Filehandle main::STDIN opened only for input at - line 5.
599cee73
PM
100########
101# pp_sys.c
4438c4b7 102use warnings 'closed' ;
599cee73
PM
103format STDIN =
104.
105close STDIN;
106write STDIN;
4438c4b7 107no warnings 'closed' ;
0453d815 108write STDIN;
599cee73 109EXPECT
af8c498a 110Write on closed filehandle main::STDIN at - line 6.
599cee73
PM
111########
112# pp_sys.c
4438c4b7 113use warnings 'io' ;
599cee73
PM
114format STDOUT_TOP =
115abc
116.
117format STDOUT =
118def
119ghi
120.
121$= = 1 ;
122$- =1 ;
3eeba6fb 123open STDOUT, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
599cee73 124write ;
4438c4b7 125no warnings 'io' ;
0453d815 126write ;
599cee73
PM
127EXPECT
128page overflow at - line 13.
129########
130# pp_sys.c
4438c4b7 131use warnings 'unopened' ;
599cee73 132$a = "abc";
0453d815 133printf $a "fred";
4438c4b7 134no warnings 'unopened' ;
0453d815 135printf $a "fred";
599cee73
PM
136EXPECT
137Filehandle main::abc never opened at - line 4.
138########
139# pp_sys.c
4438c4b7 140use warnings 'closed' ;
599cee73 141close STDIN ;
0453d815 142printf STDIN "fred";
4438c4b7 143no warnings 'closed' ;
0453d815 144printf STDIN "fred";
599cee73
PM
145EXPECT
146printf on closed filehandle main::STDIN at - line 4.
147########
148# pp_sys.c
4438c4b7 149use warnings 'io' ;
0453d815 150printf STDIN "fred";
4438c4b7 151no warnings 'io' ;
0453d815 152printf STDIN "fred";
599cee73
PM
153EXPECT
154Filehandle main::STDIN opened only for input at - line 3.
155########
156# pp_sys.c
4438c4b7 157use warnings 'closed' ;
599cee73
PM
158close STDIN;
159syswrite STDIN, "fred", 1;
4438c4b7 160no warnings 'closed' ;
0453d815 161syswrite STDIN, "fred", 1;
599cee73
PM
162EXPECT
163Syswrite on closed filehandle at - line 4.
164########
165# pp_sys.c
4438c4b7 166use warnings 'io' ;
599cee73
PM
167use Config;
168BEGIN {
169 if ( $^O ne 'VMS' and ! $Config{d_socket}) {
170 print <<EOM ;
171SKIPPED
172# send not present
173# bind not present
174# connect not present
175# accept not present
176# shutdown not present
177# setsockopt not present
178# getsockopt not present
179# getsockname not present
180# getpeername not present
181EOM
182 exit ;
183 }
184}
185close STDIN;
186send STDIN, "fred", 1;
187bind STDIN, "fred" ;
188connect STDIN, "fred" ;
189listen STDIN, 2;
190accept STDIN, "fred" ;
191shutdown STDIN, 0;
192setsockopt STDIN, 1,2,3;
193getsockopt STDIN, 1,2;
194getsockname STDIN;
195getpeername STDIN;
4438c4b7 196no warnings 'io' ;
0453d815
PM
197send STDIN, "fred", 1;
198bind STDIN, "fred" ;
199connect STDIN, "fred" ;
200listen STDIN, 2;
201accept STDIN, "fred" ;
202shutdown STDIN, 0;
203setsockopt STDIN, 1,2,3;
204getsockopt STDIN, 1,2;
205getsockname STDIN;
206getpeername STDIN;
599cee73
PM
207EXPECT
208Send on closed socket at - line 22.
209bind() on closed fd at - line 23.
210connect() on closed fd at - line 24.
211listen() on closed fd at - line 25.
212accept() on closed fd at - line 26.
213shutdown() on closed fd at - line 27.
214[gs]etsockopt() on closed fd at - line 28.
215[gs]etsockopt() on closed fd at - line 29.
216get{sock, peer}name() on closed fd at - line 30.
217get{sock, peer}name() on closed fd at - line 31.
218########
219# pp_sys.c
4438c4b7 220use warnings 'newline' ;
599cee73 221stat "abc\ndef";
4438c4b7 222no warnings 'newline' ;
0453d815 223stat "abc\ndef";
599cee73
PM
224EXPECT
225Unsuccessful stat on filename containing newline at - line 3.
226########
227# pp_sys.c
4438c4b7 228use warnings 'unopened' ;
599cee73
PM
229close STDIN ;
230-T STDIN ;
4438c4b7 231no warnings 'unopened' ;
0453d815 232-T STDIN ;
599cee73
PM
233EXPECT
234Test on unopened file <STDIN> at - line 4.
235########
236# pp_sys.c
4438c4b7 237use warnings 'newline' ;
599cee73 238-T "abc\ndef" ;
4438c4b7 239no warnings 'newline' ;
0453d815 240-T "abc\ndef" ;
599cee73
PM
241EXPECT
242Unsuccessful open on filename containing newline at - line 3.