xref: /openbsd-src/gnu/usr.bin/perl/t/lib/warnings/pp_sys (revision 91f110e064cd7c194e59e019b83bb7496c1c84d4)
1  pp_sys.c 	AOK
2
3  untie attempted while %d inner references still exist	[pp_untie]
4    sub TIESCALAR { bless [] } ; tie $a, 'main'; untie $a ;
5
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
15  Filehandle %s opened only for input		[pp_leavewrite]
16    format STDIN =
17    .
18    write STDIN;
19
20  write() on closed filehandle %s		[pp_leavewrite]
21    format STDIN =
22    .
23    close STDIN;
24    write STDIN ;
25
26  page overflow	 				[pp_leavewrite]
27
28  printf() on unopened filehandle abc		[pp_prtf]
29    $a = "abc"; printf $a "fred"
30
31  Filehandle %s opened only for input		[pp_prtf]
32    $a = "abc";
33    printf $a "fred"
34
35  printf() on closed filehandle %s		[pp_prtf]
36    close STDIN ;
37    printf STDIN "fred"
38
39  syswrite() on closed filehandle %s		[pp_send]
40    close STDIN;
41    syswrite STDIN, "fred", 1;
42
43  send() on closed socket %s			[pp_send]
44    close STDIN;
45    send STDIN, "fred", 1
46
47  bind() on closed socket %s			[pp_bind]
48    close STDIN;
49    bind STDIN, "fred" ;
50
51
52  connect() on closed socket %s			[pp_connect]
53    close STDIN;
54    connect STDIN, "fred" ;
55
56  listen() on closed socket %s			[pp_listen]
57    close STDIN;
58    listen STDIN, 2;
59
60  accept() on closed socket %s			[pp_accept]
61    close STDIN;
62    accept "fred", STDIN ;
63
64  shutdown() on closed socket %s		[pp_shutdown]
65    close STDIN;
66    shutdown STDIN, 0;
67
68  setsockopt() on closed socket %s		[pp_ssockopt]
69  getsockopt() on closed socket	%s		[pp_ssockopt]
70    close STDIN;
71    setsockopt STDIN, 1,2,3;
72    getsockopt STDIN, 1,2;
73
74  getsockname() on closed socket %s		[pp_getpeername]
75  getpeername() on closed socket %s		[pp_getpeername]
76    close STDIN;
77    getsockname STDIN;
78    getpeername STDIN;
79
80  flock() on closed socket %s			[pp_flock]
81  flock() on closed socket			[pp_flock]
82    close STDIN;
83    flock STDIN, 8;
84    flock $a, 8;
85
86  warn(warn_nl, "stat");			[pp_stat]
87
88  -T on closed filehandle %s
89  stat() on closed filehandle %s
90	close STDIN ; -T STDIN ; stat(STDIN) ;
91
92  warn(warn_nl, "open");			[pp_fttext]
93    -T "abc\ndef" ;
94
95  Filehandle %s opened only for output		[pp_sysread]
96	my $file = "./xcv" ;
97	open(F, ">$file") ;
98	my $a = sysread(F, $a,10) ;
99
100  lstat on filehandle %s			[pp_lstat]
101
102  getc() on unopened filehandle			[pp_getc]
103
104  getc() on closed filehandle			[pp_getc]
105
106  Non-string passed as bitmask			[pp_sselect]
107
108__END__
109# pp_sys.c [pp_untie]
110use warnings 'untie' ;
111sub TIESCALAR { bless [] } ;
112$b = tie $a, 'main';
113untie $a ;
114no warnings 'untie' ;
115$c = tie $d, 'main';
116untie $d ;
117EXPECT
118untie attempted while 1 inner references still exist at - line 5.
119########
120# pp_sys.c [pp_leavewrite]
121use warnings 'io' ;
122format STDIN =
123.
124write STDIN;
125no warnings 'io' ;
126write STDIN;
127EXPECT
128Filehandle STDIN opened only for input at - line 5.
129########
130# pp_sys.c [pp_leavewrite]
131use warnings 'closed' ;
132format STDIN =
133.
134format FOO =
135.
136close STDIN;
137write STDIN;
138write FOO;
139opendir STDIN, ".";
140write STDIN;
141closedir STDIN;
142opendir FOO, ".";
143write FOO;
144closedir FOO;
145no warnings 'closed' ;
146write STDIN;
147write FOO;
148opendir STDIN, ".";
149opendir FOO, ".";
150write STDIN;
151write FOO;
152EXPECT
153write() on closed filehandle STDIN at - line 8.
154write() on closed filehandle STDIN at - line 11.
155	(Are you trying to call write() on dirhandle STDIN?)
156########
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########
185# pp_sys.c [pp_leavewrite]
186use warnings 'io' ;
187format STDOUT_TOP =
188abc
189.
190format STDOUT =
191def
192ghi
193.
194$= = 1 ;
195$- =1 ;
196open STDOUT, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
197write ;
198no warnings 'io' ;
199write ;
200EXPECT
201page overflow at - line 13.
202########
203# pp_sys.c [pp_prtf]
204use warnings 'unopened' ;
205$a = "abc";
206printf $a "fred";
207no warnings 'unopened' ;
208printf $a "fred";
209EXPECT
210printf() on unopened filehandle abc at - line 4.
211########
212# pp_sys.c [pp_prtf]
213use warnings 'closed' ;
214close STDIN ;
215printf STDIN "fred";
216opendir STDIN, ".";
217printf STDIN "fred";
218closedir STDIN;
219no warnings 'closed' ;
220printf STDIN "fred";
221opendir STDIN, ".";
222printf STDIN "fred";
223EXPECT
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?)
227########
228# pp_sys.c [pp_prtf]
229use warnings 'io' ;
230printf STDIN "fred";
231no warnings 'io' ;
232printf STDIN "fred";
233EXPECT
234Filehandle STDIN opened only for input at - line 3.
235########
236# pp_sys.c [pp_send]
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]
245use warnings 'closed' ;
246close STDIN;
247syswrite STDIN, "fred", 1;
248opendir STDIN, ".";
249syswrite STDIN, "fred", 1;
250closedir STDIN;
251no warnings 'closed' ;
252syswrite STDIN, "fred", 1;
253opendir STDIN, ".";
254syswrite STDIN, "fred", 1;
255EXPECT
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?)
259########
260# pp_sys.c [pp_flock]
261use Config;
262BEGIN {
263  if ( !$Config{d_flock} &&
264       !$Config{d_fcntl_can_lock} &&
265       !$Config{d_lockf} ) {
266    print <<EOM ;
267SKIPPED
268# flock not present
269EOM
270    exit ;
271  }
272}
273use warnings qw(unopened closed);
274close STDIN;
275flock STDIN, 8;
276opendir STDIN, ".";
277flock STDIN, 8;
278flock FOO, 8;
279flock $a, 8;
280no warnings qw(unopened closed);
281flock STDIN, 8;
282opendir STDIN, ".";
283flock STDIN, 8;
284flock FOO, 8;
285flock $a, 8;
286EXPECT
287flock() on closed filehandle STDIN at - line 16.
288flock() on closed filehandle STDIN at - line 18.
289	(Are you trying to call flock() on dirhandle STDIN?)
290flock() on unopened filehandle FOO at - line 19.
291flock() on unopened filehandle at - line 20.
292########
293# pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
294use warnings 'closed';
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;
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;
330shutdown STDIN, 0;
331setsockopt STDIN, 1,2,3;
332getsockopt STDIN, 1,2;
333getsockname STDIN;
334getpeername STDIN;
335closedir STDIN;
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;
358no warnings 'closed';
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;
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;
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;
401EXPECT
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?)
432########
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########
573# pp_sys.c [pp_stat]
574use warnings 'newline' ;
575stat "abc\ndef";
576no warnings 'newline' ;
577stat "abc\ndef";
578EXPECT
579Unsuccessful stat on filename containing newline at - line 3.
580########
581# pp_sys.c [pp_fttext]
582use warnings qw(unopened closed) ;
583close STDIN ;
584-T STDIN ;
585stat(STDIN) ;
586-T HOCUS;
587stat(POCUS);
588stat "../test.pl";
589stat *foo;
590no warnings qw(unopened closed) ;
591-T STDIN ;
592stat(STDIN);
593-T HOCUS;
594stat(POCUS);
595stat "../test.pl";
596stat *foo;
597EXPECT
598-T on closed filehandle STDIN at - line 4.
599stat() on closed filehandle STDIN at - line 5.
600-T on unopened filehandle HOCUS at - line 6.
601stat() on unopened filehandle POCUS at - line 7.
602stat() on unopened filehandle foo at - line 9.
603########
604# pp_sys.c [pp_fttext]
605use warnings 'newline' ;
606-T "abc\ndef" ;
607no warnings 'newline' ;
608-T "abc\ndef" ;
609EXPECT
610Unsuccessful open on filename containing newline at - line 3.
611########
612# pp_sys.c [pp_sysread]
613use warnings 'io' ;
614if ($^O eq 'dos') {
615    print <<EOM ;
616SKIPPED
617# skipped on dos
618EOM
619    exit ;
620}
621my $file = "./xcv" ;
622open(F, ">$file") ;
623my $a = sysread(F, $a,10) ;
624no warnings 'io' ;
625my $a = sysread(F, $a,10) ;
626close F ;
627use warnings 'io' ;
628sysread(F, $a, 10);
629read(F, $a, 10);
630sysread(NONEXISTENT, $a, 10);
631read(NONEXISTENT, $a, 10);
632unlink $file ;
633EXPECT
634Filehandle F opened only for output at - line 12.
635sysread() on closed filehandle F at - line 17.
636read() on closed filehandle F at - line 18.
637sysread() on unopened filehandle NONEXISTENT at - line 19.
638read() on unopened filehandle NONEXISTENT at - line 20.
639########
640# pp_sys.c [pp_binmode]
641use warnings 'unopened' ;
642binmode(BLARG);
643$a = "BLERG";binmode($a);
644EXPECT
645binmode() on unopened filehandle BLARG at - line 3.
646binmode() on unopened filehandle at - line 4.
647########
648# pp_sys.c [pp_lstat]
649use warnings 'io';
650open FH, "../harness" or die "# $!";
651lstat FH;
652lstat *FH;
653lstat \*FH;
654open my $fh, $0 or die "# $!";
655lstat $fh;
656lstat *FH{IO};
657no warnings 'io';
658lstat FH;
659lstat $fh;
660close FH;
661close $fh;
662EXPECT
663lstat() on filehandle FH at - line 4.
664lstat() on filehandle FH at - line 5.
665lstat() on filehandle FH at - line 6.
666lstat() on filehandle $fh at - line 8.
667lstat() on filehandle at - line 9.
668########
669
670# pp_sys.c [pp_lstat]
671use warnings 'io';
672use utf8;
673use open qw( :utf8 :std );
674open ᶠḨ, "../harness" or die "# $!";
675lstat ᶠḨ;
676open my $fᚺ, $0 or die "# $!";
677lstat $fᚺ;
678no warnings 'io';
679lstat ᶠḨ;
680lstat $fᚺ;
681close ᶠḨ;
682close $fᚺ;
683EXPECT
684lstat() on filehandle ᶠḨ at - line 7.
685lstat() on filehandle $fᚺ at - line 9.
686########
687# pp_sys.c [pp_getc]
688use warnings qw(unopened closed) ;
689getc FOO;
690close STDIN;
691getc STDIN;
692# Create an empty file
693$file = 'getcwarn.tmp';
694open FH1, ">$file" or die "# $!"; close FH1;
695open FH2, $file    or die "# $!";
696getc FH2; # Should not warn at EOF
697close FH2;
698getc FH2; # Warns, now
699unlink $file;
700no warnings qw(unopened closed) ;
701getc FOO;
702getc STDIN;
703getc FH2;
704EXPECT
705getc() on unopened filehandle FOO at - line 3.
706getc() on closed filehandle STDIN at - line 5.
707getc() on closed filehandle FH2 at - line 12.
708########
709# pp_sys.c [pp_sselect]
710use warnings 'misc';
711$x = 1;
712select $x, undef, undef, 1;
713sub TIESCALAR{bless[]} sub FETCH {"hello"} sub STORE{}
714tie $y, "";
715select $y, undef, undef, 1;
716no warnings 'misc';
717select $x, undef, undef, 1;
718EXPECT
719Non-string passed as bitmask at - line 4.
720########
721use Config;
722BEGIN {
723    if (!$Config{d_fchdir}) {
724	print <<EOM;
725SKIPPED
726# fchdir not present
727EOM
728	exit;
729    }
730}
731opendir FOO, '.'; closedir FOO;
732open BAR, '.'; close BAR;
733opendir $dh, '.'; closedir $dh;
734open $fh, '.'; close $fh;
735chdir FOO;
736chdir BAR;
737chdir $dh;
738chdir $fh;
739use warnings qw(unopened closed) ;
740chdir FOO;
741chdir BAR;
742chdir $dh;
743chdir $fh;
744EXPECT
745chdir() on unopened filehandle FOO at - line 20.
746chdir() on closed filehandle BAR at - line 21.
747chdir() on unopened filehandle $dh at - line 22.
748chdir() on closed filehandle $fh at - line 23.
749########
750# pp_sys.c [pp_open]
751use warnings;
752opendir FOO, ".";
753opendir my $foo, ".";
754open FOO, "../harness";
755open $foo, "../harness";
756no warnings qw(io deprecated);
757open FOO, "../harness";
758open $foo, "../harness";
759EXPECT
760Opening dirhandle FOO also as a file at - line 5.
761Opening dirhandle $foo also as a file at - line 6.
762########
763
764# pp_sys.c [pp_open]
765use utf8;
766use open qw( :utf8 :std );
767use warnings;
768opendir FOO, ".";
769opendir $foo, ".";
770open FOO, "../harness";
771open $foo, "../harness";
772no warnings qw(io deprecated);
773open FOO, "../harness";
774open $foo, "../harness";
775EXPECT
776Opening dirhandle FOO also as a file at - line 8.
777Opening dirhandle $foo also as a file at - line 9.
778########
779# pp_sys.c [pp_open_dir]
780use warnings;
781open FOO, "../harness";
782open my $foo, "../harness";
783opendir FOO, ".";
784opendir $foo, ".";
785no warnings qw(io deprecated);
786opendir FOO, ".";
787opendir $foo, ".";
788EXPECT
789Opening filehandle FOO also as a directory at - line 5.
790Opening filehandle $foo also as a directory at - line 6.
791########
792
793# pp_sys.c [pp_open_dir]
794use utf8;
795use open qw( :utf8 :std );
796use warnings;
797use warnings;
798open FOO, "../harness";
799open $foo, "../harness";
800opendir FOO, ".";
801opendir $foo, ".";
802no warnings qw(io deprecated);
803opendir FOO, ".";
804opendir $foo, ".";
805EXPECT
806Opening filehandle FOO also as a directory at - line 9.
807Opening filehandle $foo also as a directory at - line 10.
808########
809# pp_sys.c [pp_*dir]
810use warnings 'io';
811opendir FOO, ".";
812opendir $foo, ".";
813closedir FOO;
814closedir $foo;
815
816readdir(FOO);
817telldir(FOO);
818seekdir(FOO, 0);
819rewinddir(FOO);
820closedir(FOO);
821
822readdir($foo);
823telldir($foo);
824seekdir($foo, 0);
825rewinddir($foo);
826closedir($foo);
827
828EXPECT
829readdir() attempted on invalid dirhandle FOO at - line 8.
830telldir() attempted on invalid dirhandle FOO at - line 9.
831seekdir() attempted on invalid dirhandle FOO at - line 10.
832rewinddir() attempted on invalid dirhandle FOO at - line 11.
833closedir() attempted on invalid dirhandle FOO at - line 12.
834readdir() attempted on invalid dirhandle $foo at - line 14.
835telldir() attempted on invalid dirhandle $foo at - line 15.
836seekdir() attempted on invalid dirhandle $foo at - line 16.
837rewinddir() attempted on invalid dirhandle $foo at - line 17.
838closedir() attempted on invalid dirhandle $foo at - line 18.
839########
840
841# pp_sys.c [pp_*dir]
842use utf8;
843use open qw( :utf8 :std );
844use warnings 'io';
845opendir FOO, ".";
846opendir $foo, ".";
847opendir FOO, ".";
848opendir $foo, ".";
849closedir FOO;
850closedir $foo;
851
852readdir(FOO);
853telldir(FOO);
854seekdir(FOO, 0);
855rewinddir(FOO);
856closedir(FOO);
857
858readdir($foo);
859telldir($foo);
860seekdir($foo, 0);
861rewinddir($foo);
862closedir($foo);
863
864EXPECT
865readdir() attempted on invalid dirhandle FOO at - line 13.
866telldir() attempted on invalid dirhandle FOO at - line 14.
867seekdir() attempted on invalid dirhandle FOO at - line 15.
868rewinddir() attempted on invalid dirhandle FOO at - line 16.
869closedir() attempted on invalid dirhandle FOO at - line 17.
870readdir() attempted on invalid dirhandle $foo at - line 19.
871telldir() attempted on invalid dirhandle $foo at - line 20.
872seekdir() attempted on invalid dirhandle $foo at - line 21.
873rewinddir() attempted on invalid dirhandle $foo at - line 22.
874closedir() attempted on invalid dirhandle $foo at - line 23.
875