Re: the remaining bugs in \x escapes (was Re: [PATCH] oct and hex in glorious 64...
[p5sagit/p5-mst-13.2.git] / t / op / sort.t
index 00b2dac..2a86b38 100755 (executable)
@@ -2,16 +2,10 @@
 
 BEGIN {
     chdir 't' if -d 't';
-    unshift @INC, '../lib';
+    @INC = '../lib';
 }
 use warnings;
-print "1..55\n";
-
-# XXX known to leak scalars
-{
-  no warnings 'uninitialized';
-  $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
-}
+print "1..58\n";
 
 # these shouldn't hang
 {
@@ -303,3 +297,28 @@ sub cxt_five { sort { test_if_scalar($a,$b); } 1,2 }
 @x = cxt_five();
 sub cxt_six { sort test_if_scalar 1,2 }
 @x = cxt_six();
+
+# test against a reentrancy bug
+{
+    package Bar;
+    sub compare { $a cmp $b }
+    sub reenter { my @force = sort compare qw/a b/ }
+}
+{
+    my($def, $init) = (0, 0);
+    @b = sort {
+       $def = 1 if defined $Bar::a;
+       Bar::reenter() unless $init++;
+       $a <=> $b
+    } qw/4 3 1 2/;
+    print ("@b" eq '1 2 3 4' ? "ok 56\n" : "not ok 56\n");
+    print "# x = '@b'\n";
+    print !$def ? "ok 57\n" : "not ok 57\n";
+}
+
+# Bug 19991001.003
+{
+    sub routine { "one", "two" };
+    @a = sort(routine(1));
+    print "@a" eq "one two" ? "ok 58\n" : "not ok 58\n";
+}