Integrate mainline
[p5sagit/p5-mst-13.2.git] / t / op / glob.t
index 4c27445..89263aa 100755 (executable)
@@ -2,16 +2,20 @@
 
 BEGIN {
     chdir 't' if -d 't';
-    unshift @INC, '../lib';
+    @INC = '../lib';
 }
 
-print "1..6\n";
+print "1..9\n";
 
 @oops = @ops = <op/*>;
 
 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]`,
 }
 else {
   map { $files{$_}++ } <op/*>;
@@ -38,3 +42,32 @@ print "@glops" eq "@oops" ? "ok 5\n" : "not ok 5\n";
 
 @glops = glob;
 print "@glops" eq "@oops" ? "ok 6\n" : "not ok 6\n";
+
+# glob should still work even after the File::Glob stash has gone away
+# (this used to dump core)
+my $i = 0;
+for (1..2) {
+    eval "<.>";
+    undef %File::Glob::;
+    ++$i;
+}
+print $i == 2 ? "ok 7\n" : "not ok 7\n";
+
+# ... 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";
+}
+
+
+# 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