This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlapi: Fix grammar
[perl5.git] / t / lib / warnings / pp_sys
CommitLineData
599cee73
PM
1 pp_sys.c AOK
2
767a6a26 3 untie attempted while %d inner references still exist [pp_untie]
599cee73
PM
4 sub TIESCALAR { bless [] } ; tie $a, 'main'; untie $a ;
5
c289d2f7
JH
6 fileno() on unopened filehandle abc [pp_fileno]
7 $a = "abc"; fileno($a)
8
9 binmode() on unopened filehandle abc [pp_binmode]
10 $a = "abc"; fileno($a)
11
12 printf() on unopened filehandle abc [pp_prtf]
13 $a = "abc"; printf $a "fred"
14
767a6a26 15 Filehandle %s opened only for input [pp_leavewrite]
599cee73
PM
16 format STDIN =
17 .
18 write STDIN;
19
9a7dcd9c 20 write() on closed filehandle %s [pp_leavewrite]
599cee73
PM
21 format STDIN =
22 .
23 close STDIN;
24 write STDIN ;
25
767a6a26 26 page overflow [pp_leavewrite]
599cee73 27
2dd78f96 28 printf() on unopened filehandle abc [pp_prtf]
599cee73
PM
29 $a = "abc"; printf $a "fred"
30
767a6a26 31 Filehandle %s opened only for input [pp_prtf]
599cee73
PM
32 $a = "abc";
33 printf $a "fred"
34
9a7dcd9c 35 printf() on closed filehandle %s [pp_prtf]
599cee73
PM
36 close STDIN ;
37 printf STDIN "fred"
38
69282e91 39 syswrite() on closed filehandle %s [pp_send]
599cee73
PM
40 close STDIN;
41 syswrite STDIN, "fred", 1;
42
69282e91 43 send() on closed socket %s [pp_send]
599cee73
PM
44 close STDIN;
45 send STDIN, "fred", 1
46
69282e91 47 bind() on closed socket %s [pp_bind]
599cee73
PM
48 close STDIN;
49 bind STDIN, "fred" ;
50
51
69282e91 52 connect() on closed socket %s [pp_connect]
599cee73
PM
53 close STDIN;
54 connect STDIN, "fred" ;
55
69282e91 56 listen() on closed socket %s [pp_listen]
599cee73
PM
57 close STDIN;
58 listen STDIN, 2;
59
69282e91 60 accept() on closed socket %s [pp_accept]
599cee73 61 close STDIN;
69282e91 62 accept "fred", STDIN ;
599cee73 63
69282e91 64 shutdown() on closed socket %s [pp_shutdown]
599cee73
PM
65 close STDIN;
66 shutdown STDIN, 0;
67
69282e91
GS
68 setsockopt() on closed socket %s [pp_ssockopt]
69 getsockopt() on closed socket %s [pp_ssockopt]
599cee73
PM
70 close STDIN;
71 setsockopt STDIN, 1,2,3;
72 getsockopt STDIN, 1,2;
73
69282e91
GS
74 getsockname() on closed socket %s [pp_getpeername]
75 getpeername() on closed socket %s [pp_getpeername]
599cee73
PM
76 close STDIN;
77 getsockname STDIN;
78 getpeername STDIN;
79
69282e91 80 flock() on closed socket %s [pp_flock]
bc37a18f 81 flock() on closed socket [pp_flock]
69282e91
GS
82 close STDIN;
83 flock STDIN, 8;
bc37a18f 84 flock $a, 8;
69282e91 85
767a6a26 86 warn(warn_nl, "stat"); [pp_stat]
599cee73 87
2dd78f96
JH
88 -T on closed filehandle %s
89 stat() on closed filehandle %s
90 close STDIN ; -T STDIN ; stat(STDIN) ;
599cee73 91
767a6a26 92 warn(warn_nl, "open"); [pp_fttext]
599cee73
PM
93 -T "abc\ndef" ;
94
767a6a26
PM
95 Filehandle %s opened only for output [pp_sysread]
96 my $file = "./xcv" ;
97 open(F, ">$file") ;
98 my $a = sysread(F, $a,10) ;
5d3e98de 99
90133b69
RGS
100 lstat on filehandle %s [pp_lstat]
101
102 getc() on unopened filehandle [pp_getc]
103
104 getc() on closed filehandle [pp_getc]
599cee73 105
4ef2275c
GA
106 Non-string passed as bitmask [pp_sselect]
107
d8bd3d82
FC
108 %s too large [pp_gmtime]
109
110 %s failed [pp_gmtime]
111
599cee73 112__END__
767a6a26 113# pp_sys.c [pp_untie]
4438c4b7 114use warnings 'untie' ;
599cee73
PM
115sub TIESCALAR { bless [] } ;
116$b = tie $a, 'main';
117untie $a ;
4438c4b7 118no warnings 'untie' ;
0453d815
PM
119$c = tie $d, 'main';
120untie $d ;
599cee73
PM
121EXPECT
122untie attempted while 1 inner references still exist at - line 5.
123########
767a6a26 124# pp_sys.c [pp_leavewrite]
4438c4b7 125use warnings 'io' ;
599cee73
PM
126format STDIN =
127.
128write STDIN;
4438c4b7 129no warnings 'io' ;
0453d815 130write STDIN;
599cee73 131EXPECT
43693395 132Filehandle STDIN opened only for input at - line 5.
599cee73 133########
767a6a26 134# pp_sys.c [pp_leavewrite]
4438c4b7 135use warnings 'closed' ;
599cee73
PM
136format STDIN =
137.
c521cf7c
NC
138format FOO =
139.
599cee73
PM
140close STDIN;
141write STDIN;
c521cf7c 142write FOO;
69282e91
GS
143opendir STDIN, ".";
144write STDIN;
145closedir STDIN;
c521cf7c
NC
146opendir FOO, ".";
147write FOO;
148closedir FOO;
4438c4b7 149no warnings 'closed' ;
0453d815 150write STDIN;
c521cf7c 151write FOO;
69282e91 152opendir STDIN, ".";
c521cf7c 153opendir FOO, ".";
69282e91 154write STDIN;
c521cf7c 155write FOO;
599cee73 156EXPECT
43693395 157write() on closed filehandle STDIN at - line 8.
c521cf7c 158write() on closed filehandle STDIN at - line 11.
43693395 159 (Are you trying to call write() on dirhandle STDIN?)
599cee73 160########
c521cf7c
NC
161# pp_sys.c [pp_leavewrite]
162use warnings 'unopened';
163format STDIN =
164.
165format FOO =
166.
167close STDIN;
168write STDIN;
169write FOO;
170opendir STDIN, ".";
171write STDIN;
172closedir STDIN;
173opendir FOO, ".";
174write FOO;
175closedir FOO;
176no warnings 'unopened';
177write STDIN;
178write FOO;
179opendir STDIN, ".";
180opendir FOO, ".";
181write STDIN;
182write FOO;
183EXPECT
f03aef05
NC
184write() on unopened filehandle FOO at - line 9.
185write() on unopened filehandle FOO at - line 14.
c521cf7c
NC
186 (Are you trying to call write() on dirhandle FOO?)
187########
767a6a26 188# pp_sys.c [pp_leavewrite]
4438c4b7 189use warnings 'io' ;
599cee73
PM
190format STDOUT_TOP =
191abc
192.
193format STDOUT =
194def
195ghi
196.
197$= = 1 ;
198$- =1 ;
3eeba6fb 199open STDOUT, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
599cee73 200write ;
4438c4b7 201no warnings 'io' ;
0453d815 202write ;
599cee73
PM
203EXPECT
204page overflow at - line 13.
205########
767a6a26 206# pp_sys.c [pp_prtf]
4438c4b7 207use warnings 'unopened' ;
599cee73 208$a = "abc";
0453d815 209printf $a "fred";
4438c4b7 210no warnings 'unopened' ;
0453d815 211printf $a "fred";
599cee73 212EXPECT
2dd78f96 213printf() on unopened filehandle abc at - line 4.
599cee73 214########
767a6a26 215# pp_sys.c [pp_prtf]
4438c4b7 216use warnings 'closed' ;
599cee73 217close STDIN ;
0453d815 218printf STDIN "fred";
69282e91
GS
219opendir STDIN, ".";
220printf STDIN "fred";
221closedir STDIN;
4438c4b7 222no warnings 'closed' ;
0453d815 223printf STDIN "fred";
69282e91
GS
224opendir STDIN, ".";
225printf STDIN "fred";
599cee73 226EXPECT
43693395
GS
227printf() on closed filehandle STDIN at - line 4.
228printf() on closed filehandle STDIN at - line 6.
229 (Are you trying to call printf() on dirhandle STDIN?)
599cee73 230########
767a6a26 231# pp_sys.c [pp_prtf]
4438c4b7 232use warnings 'io' ;
0453d815 233printf STDIN "fred";
4438c4b7 234no warnings 'io' ;
0453d815 235printf STDIN "fred";
599cee73 236EXPECT
43693395 237Filehandle STDIN opened only for input at - line 3.
599cee73 238########
767a6a26 239# pp_sys.c [pp_send]
cf167416
RGS
240use warnings 'io' ;
241syswrite STDIN, "fred";
242no warnings 'io' ;
243syswrite STDIN, "fred";
244EXPECT
245Filehandle STDIN opened only for input at - line 3.
246########
247# pp_sys.c [pp_send]
4438c4b7 248use warnings 'closed' ;
599cee73
PM
249close STDIN;
250syswrite STDIN, "fred", 1;
69282e91
GS
251opendir STDIN, ".";
252syswrite STDIN, "fred", 1;
253closedir STDIN;
4438c4b7 254no warnings 'closed' ;
0453d815 255syswrite STDIN, "fred", 1;
69282e91
GS
256opendir STDIN, ".";
257syswrite STDIN, "fred", 1;
599cee73 258EXPECT
43693395
GS
259syswrite() on closed filehandle STDIN at - line 4.
260syswrite() on closed filehandle STDIN at - line 6.
261 (Are you trying to call syswrite() on dirhandle STDIN?)
69282e91
GS
262########
263# pp_sys.c [pp_flock]
f0963acb
GS
264use Config;
265BEGIN {
9bdf8ebc
JH
266 if ( !$Config{d_flock} &&
267 !$Config{d_fcntl_can_lock} &&
268 !$Config{d_lockf} ) {
f0963acb
GS
269 print <<EOM ;
270SKIPPED
271# flock not present
272EOM
273 exit ;
274 }
275}
bc37a18f 276use warnings qw(unopened closed);
69282e91
GS
277close STDIN;
278flock STDIN, 8;
279opendir STDIN, ".";
280flock STDIN, 8;
bc37a18f
RG
281flock FOO, 8;
282flock $a, 8;
283no warnings qw(unopened closed);
69282e91
GS
284flock STDIN, 8;
285opendir STDIN, ".";
286flock STDIN, 8;
bc37a18f
RG
287flock FOO, 8;
288flock $a, 8;
69282e91 289EXPECT
43693395 290flock() on closed filehandle STDIN at - line 16.
c934501c 291flock() on closed filehandle STDIN at - line 18.
43693395 292 (Are you trying to call flock() on dirhandle STDIN?)
c934501c
JH
293flock() on unopened filehandle FOO at - line 19.
294flock() on unopened filehandle at - line 20.
599cee73 295########
767a6a26 296# pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
dc8c4646 297use warnings 'closed';
599cee73
PM
298use Config;
299BEGIN {
300 if ( $^O ne 'VMS' and ! $Config{d_socket}) {
301 print <<EOM ;
302SKIPPED
303# send not present
304# bind not present
305# connect not present
306# accept not present
307# shutdown not present
308# setsockopt not present
309# getsockopt not present
310# getsockname not present
311# getpeername not present
312EOM
313 exit ;
314 }
315}
316close STDIN;
317send STDIN, "fred", 1;
318bind STDIN, "fred" ;
319connect STDIN, "fred" ;
320listen STDIN, 2;
69282e91
GS
321accept "fred", STDIN;
322shutdown STDIN, 0;
323setsockopt STDIN, 1,2,3;
324getsockopt STDIN, 1,2;
325getsockname STDIN;
326getpeername STDIN;
327opendir STDIN, ".";
328send STDIN, "fred", 1;
329bind STDIN, "fred" ;
330connect STDIN, "fred" ;
331listen STDIN, 2;
332accept "fred", STDIN;
599cee73
PM
333shutdown STDIN, 0;
334setsockopt STDIN, 1,2,3;
335getsockopt STDIN, 1,2;
336getsockname STDIN;
337getpeername STDIN;
69282e91 338closedir STDIN;
fbcda526
NC
339send FOO, "fred", 1;
340bind FOO, "fred" ;
341connect FOO, "fred" ;
342listen FOO, 2;
343accept "fred", FOO;
344shutdown FOO, 0;
345setsockopt FOO, 1,2,3;
346getsockopt FOO, 1,2;
347getsockname FOO;
348getpeername FOO;
349opendir FOO, ".";
350send FOO, "fred", 1;
351bind FOO, "fred" ;
352connect FOO, "fred" ;
353listen FOO, 2;
354accept "fred", FOO;
355shutdown FOO, 0;
356setsockopt FOO, 1,2,3;
357getsockopt FOO, 1,2;
358getsockname FOO;
359getpeername FOO;
360closedir FOO;
dc8c4646 361no warnings 'closed';
0453d815
PM
362send STDIN, "fred", 1;
363bind STDIN, "fred" ;
364connect STDIN, "fred" ;
365listen STDIN, 2;
366accept STDIN, "fred" ;
367shutdown STDIN, 0;
368setsockopt STDIN, 1,2,3;
369getsockopt STDIN, 1,2;
370getsockname STDIN;
371getpeername STDIN;
69282e91
GS
372opendir STDIN, ".";
373send STDIN, "fred", 1;
374bind STDIN, "fred" ;
375connect STDIN, "fred" ;
376listen STDIN, 2;
377accept "fred", STDIN;
378shutdown STDIN, 0;
379setsockopt STDIN, 1,2,3;
380getsockopt STDIN, 1,2;
381getsockname STDIN;
382getpeername STDIN;
fbcda526
NC
383send FOO, "fred", 1;
384bind FOO, "fred" ;
385connect FOO, "fred" ;
386listen FOO, 2;
387accept FOO, "fred" ;
388shutdown FOO, 0;
389setsockopt FOO, 1,2,3;
390getsockopt FOO, 1,2;
391getsockname FOO;
392getpeername FOO;
393opendir FOO, ".";
394send FOO, "fred", 1;
395bind FOO, "fred" ;
396connect FOO, "fred" ;
397listen FOO, 2;
398accept "fred", FOO;
399shutdown FOO, 0;
400setsockopt FOO, 1,2,3;
401getsockopt FOO, 1,2;
402getsockname FOO;
403getpeername FOO;
599cee73 404EXPECT
43693395
GS
405send() on closed socket STDIN at - line 22.
406bind() on closed socket STDIN at - line 23.
407connect() on closed socket STDIN at - line 24.
408listen() on closed socket STDIN at - line 25.
409accept() on closed socket STDIN at - line 26.
410shutdown() on closed socket STDIN at - line 27.
411setsockopt() on closed socket STDIN at - line 28.
412getsockopt() on closed socket STDIN at - line 29.
413getsockname() on closed socket STDIN at - line 30.
414getpeername() on closed socket STDIN at - line 31.
415send() on closed socket STDIN at - line 33.
416 (Are you trying to call send() on dirhandle STDIN?)
417bind() on closed socket STDIN at - line 34.
418 (Are you trying to call bind() on dirhandle STDIN?)
419connect() on closed socket STDIN at - line 35.
420 (Are you trying to call connect() on dirhandle STDIN?)
421listen() on closed socket STDIN at - line 36.
422 (Are you trying to call listen() on dirhandle STDIN?)
423accept() on closed socket STDIN at - line 37.
424 (Are you trying to call accept() on dirhandle STDIN?)
425shutdown() on closed socket STDIN at - line 38.
426 (Are you trying to call shutdown() on dirhandle STDIN?)
427setsockopt() on closed socket STDIN at - line 39.
428 (Are you trying to call setsockopt() on dirhandle STDIN?)
429getsockopt() on closed socket STDIN at - line 40.
430 (Are you trying to call getsockopt() on dirhandle STDIN?)
431getsockname() on closed socket STDIN at - line 41.
432 (Are you trying to call getsockname() on dirhandle STDIN?)
433getpeername() on closed socket STDIN at - line 42.
434 (Are you trying to call getpeername() on dirhandle STDIN?)
599cee73 435########
fbcda526
NC
436# pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
437use warnings 'unopened';
438use Config;
439BEGIN {
440 if ( $^O ne 'VMS' and ! $Config{d_socket}) {
441 print <<EOM ;
442SKIPPED
443# send not present
444# bind not present
445# connect not present
446# accept not present
447# shutdown not present
448# setsockopt not present
449# getsockopt not present
450# getsockname not present
451# getpeername not present
452EOM
453 exit ;
454 }
455}
456close STDIN;
457send STDIN, "fred", 1;
458bind STDIN, "fred" ;
459connect STDIN, "fred" ;
460listen STDIN, 2;
461accept "fred", STDIN;
462shutdown STDIN, 0;
463setsockopt STDIN, 1,2,3;
464getsockopt STDIN, 1,2;
465getsockname STDIN;
466getpeername STDIN;
467opendir STDIN, ".";
468send STDIN, "fred", 1;
469bind STDIN, "fred" ;
470connect STDIN, "fred" ;
471listen STDIN, 2;
472accept "fred", STDIN;
473shutdown STDIN, 0;
474setsockopt STDIN, 1,2,3;
475getsockopt STDIN, 1,2;
476getsockname STDIN;
477getpeername STDIN;
478closedir STDIN;
479send FOO, "fred", 1;
480bind FOO, "fred" ;
481connect FOO, "fred" ;
482listen FOO, 2;
483accept "fred", FOO;
484shutdown FOO, 0;
485setsockopt FOO, 1,2,3;
486getsockopt FOO, 1,2;
487getsockname FOO;
488getpeername FOO;
489opendir FOO, ".";
490send FOO, "fred", 1;
491bind FOO, "fred" ;
492connect FOO, "fred" ;
493listen FOO, 2;
494accept "fred", FOO;
495shutdown FOO, 0;
496setsockopt FOO, 1,2,3;
497getsockopt FOO, 1,2;
498getsockname FOO;
499getpeername FOO;
500closedir FOO;
501no warnings 'unopened';
502send STDIN, "fred", 1;
503bind STDIN, "fred" ;
504connect STDIN, "fred" ;
505listen STDIN, 2;
506accept STDIN, "fred" ;
507shutdown STDIN, 0;
508setsockopt STDIN, 1,2,3;
509getsockopt STDIN, 1,2;
510getsockname STDIN;
511getpeername STDIN;
512opendir STDIN, ".";
513send STDIN, "fred", 1;
514bind STDIN, "fred" ;
515connect STDIN, "fred" ;
516listen STDIN, 2;
517accept "fred", STDIN;
518shutdown STDIN, 0;
519setsockopt STDIN, 1,2,3;
520getsockopt STDIN, 1,2;
521getsockname STDIN;
522getpeername STDIN;
523send FOO, "fred", 1;
524bind FOO, "fred" ;
525connect FOO, "fred" ;
526listen FOO, 2;
527accept FOO, "fred" ;
528shutdown FOO, 0;
529setsockopt FOO, 1,2,3;
530getsockopt FOO, 1,2;
531getsockname FOO;
532getpeername FOO;
533opendir FOO, ".";
534send FOO, "fred", 1;
535bind FOO, "fred" ;
536connect FOO, "fred" ;
537listen FOO, 2;
538accept "fred", FOO;
539shutdown FOO, 0;
540setsockopt FOO, 1,2,3;
541getsockopt FOO, 1,2;
542getsockname FOO;
543getpeername FOO;
544EXPECT
545send() on unopened socket FOO at - line 44.
546bind() on unopened socket FOO at - line 45.
547connect() on unopened socket FOO at - line 46.
548listen() on unopened socket FOO at - line 47.
549accept() on unopened socket FOO at - line 48.
550shutdown() on unopened socket FOO at - line 49.
551setsockopt() on unopened socket FOO at - line 50.
552getsockopt() on unopened socket FOO at - line 51.
553getsockname() on unopened socket FOO at - line 52.
554getpeername() on unopened socket FOO at - line 53.
555send() on unopened socket FOO at - line 55.
556 (Are you trying to call send() on dirhandle FOO?)
557bind() on unopened socket FOO at - line 56.
558 (Are you trying to call bind() on dirhandle FOO?)
559connect() on unopened socket FOO at - line 57.
560 (Are you trying to call connect() on dirhandle FOO?)
561listen() on unopened socket FOO at - line 58.
562 (Are you trying to call listen() on dirhandle FOO?)
563accept() on unopened socket FOO at - line 59.
564 (Are you trying to call accept() on dirhandle FOO?)
565shutdown() on unopened socket FOO at - line 60.
566 (Are you trying to call shutdown() on dirhandle FOO?)
567setsockopt() on unopened socket FOO at - line 61.
568 (Are you trying to call setsockopt() on dirhandle FOO?)
569getsockopt() on unopened socket FOO at - line 62.
570 (Are you trying to call getsockopt() on dirhandle FOO?)
571getsockname() on unopened socket FOO at - line 63.
572 (Are you trying to call getsockname() on dirhandle FOO?)
573getpeername() on unopened socket FOO at - line 64.
574 (Are you trying to call getpeername() on dirhandle FOO?)
575########
767a6a26 576# pp_sys.c [pp_stat]
4438c4b7 577use warnings 'newline' ;
599cee73 578stat "abc\ndef";
7cb3f959
TC
579stat "abcdef\n";
580stat "abcdef\n\0";
4438c4b7 581no warnings 'newline' ;
0453d815 582stat "abc\ndef";
7cb3f959
TC
583stat "abcdef\n";
584stat "abcdef\n\0";
599cee73 585EXPECT
7cb3f959
TC
586Unsuccessful stat on filename containing newline at - line 4.
587Unsuccessful stat on filename containing newline at - line 5.
599cee73 588########
767a6a26 589# pp_sys.c [pp_fttext]
2dd78f96 590use warnings qw(unopened closed) ;
599cee73
PM
591close STDIN ;
592-T STDIN ;
9ddeeac9 593stat(STDIN) ;
2dd78f96
JH
594-T HOCUS;
595stat(POCUS);
05bb32d2
FC
596stat "../test.pl";
597stat *foo;
2dd78f96 598no warnings qw(unopened closed) ;
0453d815 599-T STDIN ;
9ddeeac9 600stat(STDIN);
2dd78f96
JH
601-T HOCUS;
602stat(POCUS);
05bb32d2
FC
603stat "../test.pl";
604stat *foo;
599cee73 605EXPECT
2dd78f96
JH
606-T on closed filehandle STDIN at - line 4.
607stat() on closed filehandle STDIN at - line 5.
608-T on unopened filehandle HOCUS at - line 6.
609stat() on unopened filehandle POCUS at - line 7.
05bb32d2 610stat() on unopened filehandle foo at - line 9.
599cee73 611########
767a6a26 612# pp_sys.c [pp_fttext]
4438c4b7 613use warnings 'newline' ;
599cee73 614-T "abc\ndef" ;
7cb3f959
TC
615-T "abcdef\n" ;
616-T "abcdef\n\0" ;
4438c4b7 617no warnings 'newline' ;
0453d815 618-T "abc\ndef" ;
7cb3f959
TC
619-T "abcdef\n" ;
620-T "abcdef\n\0" ;
599cee73 621EXPECT
7cb3f959
TC
622Unsuccessful open on filename containing newline at - line 4.
623Unsuccessful open on filename containing newline at - line 5.
767a6a26
PM
624########
625# pp_sys.c [pp_sysread]
626use warnings 'io' ;
6bbf1b34
LM
627if ($^O eq 'dos') {
628 print <<EOM ;
629SKIPPED
630# skipped on dos
631EOM
632 exit ;
633}
767a6a26
PM
634my $file = "./xcv" ;
635open(F, ">$file") ;
60e67244 636binmode F;
767a6a26
PM
637my $a = sysread(F, $a,10) ;
638no warnings 'io' ;
639my $a = sysread(F, $a,10) ;
640close F ;
b5fe5ca2
SR
641use warnings 'io' ;
642sysread(F, $a, 10);
643read(F, $a, 10);
644sysread(NONEXISTENT, $a, 10);
645read(NONEXISTENT, $a, 10);
767a6a26
PM
646unlink $file ;
647EXPECT
60e67244
TC
648Filehandle F opened only for output at - line 13.
649sysread() on closed filehandle F at - line 18.
650read() on closed filehandle F at - line 19.
651sysread() on unopened filehandle NONEXISTENT at - line 20.
652read() on unopened filehandle NONEXISTENT at - line 21.
c289d2f7
JH
653########
654# pp_sys.c [pp_binmode]
655use warnings 'unopened' ;
656binmode(BLARG);
657$a = "BLERG";binmode($a);
658EXPECT
659binmode() on unopened filehandle BLARG at - line 3.
660binmode() on unopened filehandle at - line 4.
5d3e98de
RGS
661########
662# pp_sys.c [pp_lstat]
663use warnings 'io';
463cf062 664open FH, "../harness" or die "# $!";
365c80fa 665lstat FH;
109c43ed
FC
666lstat *FH;
667lstat \*FH;
5d3e98de
RGS
668open my $fh, $0 or die "# $!";
669lstat $fh;
93fad930 670lstat *FH{IO};
5d3e98de 671no warnings 'io';
365c80fa 672lstat FH;
5d3e98de 673lstat $fh;
365c80fa 674close FH;
5d3e98de
RGS
675close $fh;
676EXPECT
365c80fa 677lstat() on filehandle FH at - line 4.
109c43ed
FC
678lstat() on filehandle FH at - line 5.
679lstat() on filehandle FH at - line 6.
680lstat() on filehandle $fh at - line 8.
93fad930 681lstat() on filehandle at - line 9.
90133b69 682########
2dc9cdca 683
bf29d05f
BF
684# pp_sys.c [pp_lstat]
685use warnings 'io';
686use utf8;
687use open qw( :utf8 :std );
688open ᶠḨ, "../harness" or die "# $!";
689lstat ᶠḨ;
690open my $fᚺ, $0 or die "# $!";
691lstat $fᚺ;
692no warnings 'io';
693lstat ᶠḨ;
694lstat $fᚺ;
695close ᶠḨ;
696close $fᚺ;
697EXPECT
2dc9cdca
BF
698lstat() on filehandle ᶠḨ at - line 7.
699lstat() on filehandle $fᚺ at - line 9.
bf29d05f 700########
90133b69
RGS
701# pp_sys.c [pp_getc]
702use warnings qw(unopened closed) ;
703getc FOO;
704close STDIN;
705getc STDIN;
97e322ff
RGS
706# Create an empty file
707$file = 'getcwarn.tmp';
708open FH1, ">$file" or die "# $!"; close FH1;
709open FH2, $file or die "# $!";
710getc FH2; # Should not warn at EOF
711close FH2;
712getc FH2; # Warns, now
713unlink $file;
90133b69
RGS
714no warnings qw(unopened closed) ;
715getc FOO;
716getc STDIN;
97e322ff 717getc FH2;
90133b69
RGS
718EXPECT
719getc() on unopened filehandle FOO at - line 3.
720getc() on closed filehandle STDIN at - line 5.
97e322ff 721getc() on closed filehandle FH2 at - line 12.
4ef2275c
GA
722########
723# pp_sys.c [pp_sselect]
724use warnings 'misc';
725$x = 1;
ce712ebb 726select $x, undef, undef, 1;
9d6d5a79
FC
727sub TIESCALAR{bless[]} sub FETCH {"hello"} sub STORE{}
728tie $y, "";
729select $y, undef, undef, 1;
4ef2275c 730no warnings 'misc';
ce712ebb 731select $x, undef, undef, 1;
4ef2275c
GA
732EXPECT
733Non-string passed as bitmask at - line 4.
4dc171f0 734########
8aee01e7
RGS
735use Config;
736BEGIN {
737 if (!$Config{d_fchdir}) {
738 print <<EOM;
739SKIPPED
740# fchdir not present
741EOM
742 exit;
743 }
744}
4dc171f0
PD
745opendir FOO, '.'; closedir FOO;
746open BAR, '.'; close BAR;
747opendir $dh, '.'; closedir $dh;
748open $fh, '.'; close $fh;
749chdir FOO;
750chdir BAR;
751chdir $dh;
752chdir $fh;
753use warnings qw(unopened closed) ;
754chdir FOO;
755chdir BAR;
756chdir $dh;
757chdir $fh;
758EXPECT
8aee01e7
RGS
759chdir() on unopened filehandle FOO at - line 20.
760chdir() on closed filehandle BAR at - line 21.
761chdir() on unopened filehandle $dh at - line 22.
762chdir() on closed filehandle $fh at - line 23.
abc718f2
RGS
763########
764# pp_sys.c [pp_open]
765use warnings;
766opendir FOO, ".";
767opendir my $foo, ".";
463cf062
NC
768open FOO, "../harness";
769open $foo, "../harness";
abc718f2 770no warnings qw(io deprecated);
463cf062
NC
771open FOO, "../harness";
772open $foo, "../harness";
abc718f2 773EXPECT
122d6c09
A
774Opening dirhandle FOO also as a file. This will be a fatal error in Perl 5.28 at - line 5.
775Opening dirhandle $foo also as a file. This will be a fatal error in Perl 5.28 at - line 6.
abc718f2 776########
2dc9cdca 777
bf29d05f
BF
778# pp_sys.c [pp_open]
779use utf8;
780use open qw( :utf8 :std );
781use warnings;
782opendir FOO, ".";
783opendir $foo, ".";
784open FOO, "../harness";
785open $foo, "../harness";
786no warnings qw(io deprecated);
787open FOO, "../harness";
788open $foo, "../harness";
789EXPECT
122d6c09
A
790Opening dirhandle FOO also as a file. This will be a fatal error in Perl 5.28 at - line 8.
791Opening dirhandle $foo also as a file. This will be a fatal error in Perl 5.28 at - line 9.
bf29d05f 792########
abc718f2
RGS
793# pp_sys.c [pp_open_dir]
794use warnings;
463cf062
NC
795open FOO, "../harness";
796open my $foo, "../harness";
abc718f2
RGS
797opendir FOO, ".";
798opendir $foo, ".";
799no warnings qw(io deprecated);
800opendir FOO, ".";
801opendir $foo, ".";
802EXPECT
122d6c09
A
803Opening filehandle FOO also as a directory. This will be a fatal error in Perl 5.28 at - line 5.
804Opening filehandle $foo also as a directory. This will be a fatal error in Perl 5.28 at - line 6.
bf29d05f 805########
2dc9cdca 806
bf29d05f
BF
807# pp_sys.c [pp_open_dir]
808use utf8;
809use open qw( :utf8 :std );
810use warnings;
811use warnings;
812open FOO, "../harness";
813open $foo, "../harness";
814opendir FOO, ".";
815opendir $foo, ".";
816no warnings qw(io deprecated);
817opendir FOO, ".";
818opendir $foo, ".";
819EXPECT
122d6c09
A
820Opening filehandle FOO also as a directory. This will be a fatal error in Perl 5.28 at - line 9.
821Opening filehandle $foo also as a directory. This will be a fatal error in Perl 5.28 at - line 10.
bf29d05f
BF
822########
823# pp_sys.c [pp_*dir]
bad5a428
BF
824use Config ;
825BEGIN {
826 if ( ! $Config{d_telldir}) {
827 print <<EOM ;
828SKIPPED
829# telldir not present
830EOM
831 exit
832 }
833}
834#line 2
bf29d05f
BF
835use warnings 'io';
836opendir FOO, ".";
837opendir $foo, ".";
838closedir FOO;
839closedir $foo;
840
841readdir(FOO);
842telldir(FOO);
843seekdir(FOO, 0);
844rewinddir(FOO);
845closedir(FOO);
846
847readdir($foo);
848telldir($foo);
849seekdir($foo, 0);
850rewinddir($foo);
851closedir($foo);
852
853EXPECT
854readdir() attempted on invalid dirhandle FOO at - line 8.
855telldir() attempted on invalid dirhandle FOO at - line 9.
856seekdir() attempted on invalid dirhandle FOO at - line 10.
857rewinddir() attempted on invalid dirhandle FOO at - line 11.
858closedir() attempted on invalid dirhandle FOO at - line 12.
859readdir() attempted on invalid dirhandle $foo at - line 14.
860telldir() attempted on invalid dirhandle $foo at - line 15.
861seekdir() attempted on invalid dirhandle $foo at - line 16.
862rewinddir() attempted on invalid dirhandle $foo at - line 17.
863closedir() attempted on invalid dirhandle $foo at - line 18.
864########
2dc9cdca 865
bf29d05f 866# pp_sys.c [pp_*dir]
bad5a428
BF
867use Config ;
868BEGIN {
869 if ( ! $Config{d_telldir}) {
870 print <<EOM ;
871SKIPPED
872# telldir not present
873EOM
874 exit
875 }
876}
877#line 3
bf29d05f
BF
878use utf8;
879use open qw( :utf8 :std );
880use warnings 'io';
881opendir FOO, ".";
882opendir $foo, ".";
883opendir FOO, ".";
884opendir $foo, ".";
885closedir FOO;
886closedir $foo;
887
888readdir(FOO);
889telldir(FOO);
890seekdir(FOO, 0);
891rewinddir(FOO);
892closedir(FOO);
893
894readdir($foo);
895telldir($foo);
896seekdir($foo, 0);
897rewinddir($foo);
898closedir($foo);
899
900EXPECT
2dc9cdca
BF
901readdir() attempted on invalid dirhandle FOO at - line 13.
902telldir() attempted on invalid dirhandle FOO at - line 14.
903seekdir() attempted on invalid dirhandle FOO at - line 15.
904rewinddir() attempted on invalid dirhandle FOO at - line 16.
905closedir() attempted on invalid dirhandle FOO at - line 17.
906readdir() attempted on invalid dirhandle $foo at - line 19.
907telldir() attempted on invalid dirhandle $foo at - line 20.
908seekdir() attempted on invalid dirhandle $foo at - line 21.
909rewinddir() attempted on invalid dirhandle $foo at - line 22.
910closedir() attempted on invalid dirhandle $foo at - line 23.
d8bd3d82
FC
911########
912
913# pp_sys.c [pp_gmtime]
059d8568 914use Config;
85272d31 915unless ($Config{d_double_has_nan}) {
059d8568
JH
916 print <<EOM ;
917SKIPPED
918# No nan support
919EOM
920 exit ;
921}
d8bd3d82
FC
922gmtime("NaN");
923localtime("NaN");
924use warnings "overflow";
925gmtime("NaN");
926localtime("NaN");
927
928EXPECT
85272d31
JH
929gmtime(NaN) too large at - line 14.
930gmtime(NaN) failed at - line 14.
931localtime(NaN) too large at - line 15.
932localtime(NaN) failed at - line 15.
add0dc91
JH
933
934########
935# pp_sys.c [pp_alarm]
936alarm(-1);
937no warnings "misc";
938alarm(-1);
939
940EXPECT
941alarm() with negative argument at - line 2.
393bc9b3
JH
942
943########
944# pp_sys.c [pp_sleep]
945sleep(-1);
946no warnings "misc";
947sleep(-1);
948
949EXPECT
950sleep() with negative argument at - line 2.
fb10a8a7
TC
951########
952# NAME sysread() deprecated on :utf8
60e67244 953open my $fh, "<:raw", "../harness" or die "# $!";
fb10a8a7
TC
954my $buf;
955sysread $fh, $buf, 10;
956binmode $fh, ':utf8';
957sysread $fh, $buf, 10;
89e5a021
TC
958no warnings 'deprecated';
959sysread $fh, $buf, 10;
fb10a8a7 960EXPECT
1972ac5c 961sysread() is deprecated on :utf8 handles. This will be a fatal error in Perl 5.30 at - line 5.
fb10a8a7
TC
962########
963# NAME syswrite() deprecated on :utf8
964my $file = "syswwarn.tmp";
60e67244 965open my $fh, ">:raw", $file or die "# $!";
fb10a8a7
TC
966syswrite $fh, 'ABC';
967binmode $fh, ':utf8';
968syswrite $fh, 'ABC';
89e5a021
TC
969no warnings 'deprecated';
970syswrite $fh, 'ABC';
fb10a8a7
TC
971close $fh;
972unlink $file;
973EXPECT
1972ac5c 974syswrite() is deprecated on :utf8 handles. This will be a fatal error in Perl 5.30 at - line 5.