This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Convert a pp_sys test to use warnings 'closed', instead of the broader 'io'.
[perl5.git] / t / lib / warnings / pp_sys
index 4149117..b278306 100644 (file)
@@ -131,20 +131,57 @@ Filehandle STDIN opened only for input at - line 5.
 use warnings 'closed' ;
 format STDIN =
 .
+format FOO =
+.
 close STDIN;
 write STDIN;
+write FOO;
 opendir STDIN, ".";
 write STDIN;
 closedir STDIN;
+opendir FOO, ".";
+write FOO;
+closedir FOO;
 no warnings 'closed' ;
 write STDIN;
+write FOO;
 opendir STDIN, ".";
+opendir FOO, ".";
 write STDIN;
+write FOO;
 EXPECT
-write() on closed filehandle STDIN at - line 6.
 write() on closed filehandle STDIN at - line 8.
+write() on closed filehandle STDIN at - line 11.
        (Are you trying to call write() on dirhandle STDIN?)
 ########
+########
+# pp_sys.c [pp_leavewrite]
+use warnings 'unopened';
+format STDIN =
+.
+format FOO =
+.
+close STDIN;
+write STDIN;
+write FOO;
+opendir STDIN, ".";
+write STDIN;
+closedir STDIN;
+opendir FOO, ".";
+write FOO;
+closedir FOO;
+no warnings 'unopened';
+write STDIN;
+write FOO;
+opendir STDIN, ".";
+opendir FOO, ".";
+write STDIN;
+write FOO;
+EXPECT
+write() on unopened filehandle FOO at - line 10.
+write() on unopened filehandle FOO at - line 15.
+       (Are you trying to call write() on dirhandle FOO?)
+########
 # pp_sys.c [pp_leavewrite]
 use warnings 'io' ;
 format STDOUT_TOP =
@@ -197,6 +234,14 @@ EXPECT
 Filehandle STDIN opened only for input at - line 3.
 ########
 # pp_sys.c [pp_send]
+use warnings 'io' ;
+syswrite STDIN, "fred";
+no warnings 'io' ;
+syswrite STDIN, "fred";
+EXPECT
+Filehandle STDIN opened only for input at - line 3.
+########
+# pp_sys.c [pp_send]
 use warnings 'closed' ;
 close STDIN; 
 syswrite STDIN, "fred", 1;
@@ -246,7 +291,7 @@ flock() on unopened filehandle FOO at - line 19.
 flock() on unopened filehandle at - line 20.
 ########
 # pp_sys.c [pp_prtf pp_send pp_bind pp_connect pp_listen pp_accept pp_shutdown pp_ssockopt ppp_getpeername]
-use warnings 'io' ;
+use warnings 'closed';
 use Config; 
 BEGIN { 
   if ( $^O ne 'VMS' and ! $Config{d_socket}) {
@@ -288,7 +333,7 @@ getsockopt STDIN, 1,2;
 getsockname STDIN;
 getpeername STDIN;
 closedir STDIN;
-no warnings 'io' ;
+no warnings 'closed';
 send STDIN, "fred", 1;
 bind STDIN, "fred" ;
 connect STDIN, "fred" ;
@@ -414,7 +459,7 @@ binmode() on unopened filehandle at - line 4.
 ########
 # pp_sys.c [pp_lstat]
 use warnings 'io';
-open FH, "harness" or die "# $!";
+open FH, "../harness" or die "# $!";
 lstat FH;
 open my $fh, $0 or die "# $!";
 lstat $fh;
@@ -452,12 +497,22 @@ getc() on closed filehandle FH2 at - line 12.
 # pp_sys.c [pp_sselect]
 use warnings 'misc';
 $x = 1;
-select $x, undef, undef, undef;
+select $x, undef, undef, 1;
 no warnings 'misc';
-select $x, undef, undef, undef;
+select $x, undef, undef, 1;
 EXPECT
 Non-string passed as bitmask at - line 4.
 ########
+use Config;
+BEGIN {
+    if (!$Config{d_fchdir}) {
+       print <<EOM;
+SKIPPED
+# fchdir not present
+EOM
+       exit;
+    }
+}
 opendir FOO, '.'; closedir FOO;
 open BAR, '.'; close BAR;
 opendir $dh, '.'; closedir $dh;
@@ -472,7 +527,33 @@ chdir BAR;
 chdir $dh;
 chdir $fh;
 EXPECT
-chdir() on unopened filehandle FOO at - line 10.
-chdir() on closed filehandle BAR at - line 11.
-chdir() on unopened filehandle $dh at - line 12.
-chdir() on closed filehandle $fh at - line 13.
+chdir() on unopened filehandle FOO at - line 20.
+chdir() on closed filehandle BAR at - line 21.
+chdir() on unopened filehandle $dh at - line 22.
+chdir() on closed filehandle $fh at - line 23.
+########
+# pp_sys.c [pp_open]
+use warnings;
+opendir FOO, ".";
+opendir my $foo, ".";
+open FOO, "../harness";
+open $foo, "../harness";
+no warnings qw(io deprecated);
+open FOO, "../harness";
+open $foo, "../harness";
+EXPECT
+Opening dirhandle FOO also as a file at - line 5.
+Opening dirhandle $foo also as a file at - line 6.
+########
+# pp_sys.c [pp_open_dir]
+use warnings;
+open FOO, "../harness";
+open my $foo, "../harness";
+opendir FOO, ".";
+opendir $foo, ".";
+no warnings qw(io deprecated);
+opendir FOO, ".";
+opendir $foo, ".";
+EXPECT
+Opening filehandle FOO also as a directory at - line 5.
+Opening filehandle $foo also as a directory at - line 6.