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