tests are expected to fail if dirfd () does not exist
[p5sagit/p5-mst-13.2.git] / t / op / glob.t
index 2eb371a..d03d75f 100755 (executable)
@@ -11,7 +11,16 @@ print "1..10\n";
 
 if ($^O eq 'MSWin32') {
   map { $files{lc($_)}++ } <op/*>;
-  map { delete $files{"op/$_"} } split /[\s\n]/, `cmd /c "dir /b /l op & dir /b /l /ah op 2>nul"`,
+  map { delete $files{"op/$_"} } split /[\s\n]/, `dir /b /l op & dir /b /l /ah op 2>nul`,
+}
+elsif ($^O eq 'VMS') {
+  map { $files{lc($_)}++ } <[.op]*>;
+  map { s/;.*$//; delete $files{lc($_)}; } split /[\n]/, `directory/noheading/notrailing/versions=1 [.op]`,
+}
+elsif ($^O eq 'MacOS') {
+  @oops = @ops = <:op:*>;
+  map { $files{$_}++ } <:op:*>;
+  map { delete $files{$_} } split /[\s\n]/, `echo :op:\xc5`;
 }
 else {
   map { $files{$_}++ } <op/*>;
@@ -23,16 +32,23 @@ if (keys %files) {
 
 print $/ eq "\n" ? "ok 2\n" : "not ok 2\n";
 
-while (<jskdfjskdfj* op/* jskdjfjkosvk*>) {
-    $not = "not " unless $_ eq shift @ops;
-    $not = "not at all " if $/ eq "\0";
+if ($^O eq 'MacOS') {
+    while (<jskdfjskdfj* :op:* jskdjfjkosvk*>) {
+       $not = "not " unless $_ eq shift @ops;
+       $not = "not at all " if $/ eq "\0";
+    }
+} else {
+    while (<jskdfjskdfj* op/* jskdjfjkosvk*>) {
+       $not = "not " unless $_ eq shift @ops;
+       $not = "not at all " if $/ eq "\0";
+    }
 }
 print "${not}ok 3\n";
 
 print $/ eq "\n" ? "ok 4\n" : "not ok 4\n";
 
 # test the "glob" operator
-$_ = "op/*";
+$_ = $^O eq 'MacOS' ? ":op:*" : "op/*";
 @glops = glob $_;
 print "@glops" eq "@oops" ? "ok 5\n" : "not ok 5\n";
 
@@ -49,10 +65,27 @@ for (1..2) {
 }
 print $i == 2 ? "ok 7\n" : "not ok 7\n";
 
-# [ID 20010526.001] localized glob loses value when assigned to
+# ... while ($var = glob(...)) should test definedness not truth
+
+if( $INC{'File/Glob.pm'} ) {
+    my $ok = "not ok 8\n";
+    $ok = "ok 8\n" while my $var = glob("0");
+    print $ok;
+}
+else {
+    print "ok 8 # skip: File::Glob emulated Unixism\n";
+}
+
 
-$j=1; %j=(a=>1); @j=(1); local *j=*j; *j = sub{};
+# The formerly-broken test for the situation above would accidentally
+# test definedness for an assignment with a LOGOP on the right:
+my $f=0;
+$ok="ok 9\n";
+$ok="not ok 9\n", undef $f while $x = $f||$f;
+print $ok;
 
-print $j    == 1 ? "ok 8\n"  : "not ok 8\n";
-print $j{a} == 1 ? "ok 9\n"  : "not ok 9\n";
-print $j[0] == 1 ? "ok 10\n" : "not ok 10\n";
+# Better check that glob actually returned some entries
+{
+   my $not = (scalar @oops > 0) ? '' : 'not ';
+   print "${not}ok 10\n";
+}