Re: Untested builtins
[p5sagit/p5-mst-13.2.git] / t / op / stat.t
index 6afbadc..6eb5c9a 100755 (executable)
@@ -9,7 +9,7 @@ BEGIN {
 use Config;
 use File::Spec;
 
-plan tests => 78;
+plan tests => 82;
 
 my $Perl = which_perl();
 
@@ -49,6 +49,8 @@ close FOO;
 open(FOO, ">$tmpfile") || DIE("Can't open temp test file: $!");
 
 my($nlink, $mtime, $ctime) = (stat(FOO))[$NLINK, $MTIME, $CTIME];
+
+#VMS Fix-me: nlink should work on VMS if applicable link support configured.
 SKIP: {
     skip "No link count", 1 if $Is_VMS;
 
@@ -168,11 +170,6 @@ SKIP: {
 
 
 
-
-# in ms windows, $tmpfile inherits owner uid from directory
-# not sure about os/2, but chown is harmless anyway
-eval { chown $>,$tmpfile; 1 } or print "# $@" ;
-
 ok(chmod(0700,$tmpfile),    'chmod 0700');
 ok(-r $tmpfile,     '   -r');
 ok(-w $tmpfile,     '   -w');
@@ -217,6 +214,16 @@ SKIP: {
     skip "Skipping: unexpected ls output in MP-RAS", 6
       if $Is_MPRAS;
 
+    # VMS problem:  If GNV or other UNIX like tool is installed, then
+    # sometimes Perl will find /bin/ls, and will try to run it.
+    # But since Perl on VMS does not know to run it under Bash, it will
+    # try to run the DCL verb LS.  And if the VMS product Language
+    # Sensitive Editor is installed, or some other LS verb, that will
+    # be run instead.  So do not do this until we can teach Perl
+    # when to use BASH on VMS.
+    skip "ls command not available to Perl in OpenVMS right now.", 6
+      if $Is_VMS;
+
     my $LS  = $Config{d_readlink} ? "ls -lL" : "ls -l";
     my $CMD = "$LS /dev 2>/dev/null";
     my $DEV = qx($CMD);
@@ -406,16 +413,22 @@ unlink $tmpfile or print "# unlink failed: $!\n";
 my @r = \stat($Curdir);
 is(scalar @r, 13,   'stat returns full 13 elements');
 
+stat $0;
+eval { lstat _ };
+like( $@, qr/^The stat preceding lstat\(\) wasn't an lstat/,
+    'lstat _ croaks after stat' );
+eval { -l _ };
+like( $@, qr/^The stat preceding -l _ wasn't an lstat/,
+    '-l _ croaks after stat' );
+
+lstat $0;
+eval { lstat _ };
+is( "$@", "", "lstat _ ok after lstat" );
+eval { -l _ };
+is( "$@", "", "-l _ ok after lstat" );
+  
 SKIP: {
-    skip "No lstat", 4 unless $Config{d_lstat};
-
-    stat $0;
-    eval { lstat _ };
-    like( $@, qr/^The stat preceding lstat\(\) wasn't an lstat/,
-       'lstat _ croaks after stat' );
-    eval { -l _ };
-    like( $@, qr/^The stat preceding -l _ wasn't an lstat/,
-       '-l _ croaks after stat' );
+    skip "No lstat", 2 unless $Config{d_lstat};
 
     # bug id 20020124.004
     # If we have d_lstat, we should have symlink()
@@ -447,6 +460,18 @@ ok( (-A _) < 0, 'negative -A works');
 ok( (-C _) < 0, 'negative -C works');
 ok(unlink($f), 'unlink tmp file');
 
+{
+    ok(open(F, ">", $tmpfile), 'can create temp file');
+    close F;
+    chmod 0077, $tmpfile;
+    my @a = stat($tmpfile);
+    my $s1 = -s _;
+    -T _;
+    my $s2 = -s _;
+    is($s1, $s2, q(-T _ doesn't break the statbuffer));
+    unlink $tmpfile;
+}
+
 END {
     1 while unlink $tmpfile;
 }