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