Drop "v" prefix from sprintf("%vd", $^V).
[p5sagit/p5-mst-13.2.git] / t / op / sort.t
index 7081f21..c328b6e 100755 (executable)
@@ -5,7 +5,7 @@ BEGIN {
     @INC = '../lib';
 }
 use warnings;
-print "1..141\n";
+print "1..143\n";
 
 # these shouldn't hang
 {
@@ -14,6 +14,9 @@ print "1..141\n";
     sort { while(1) {}            } @a;
     sort { while(1) { last; }     } @a;
     sort { while(0) { last; }     } @a;
+
+    # Change 26011: Re: A surprising segfault
+    map scalar(sort(+())), ('')x68;
 }
 
 sub Backwards { $a lt $b ? 1 : $a gt $b ? -1 : 0 }
@@ -731,11 +734,15 @@ package main;
 my $answer = "ok ";
 () = sort OtherPack::foo 1,2,3,4;
 
-{package OtherPack; sub foo {
-  $answer = "not ok " if
-    defined($a) || defined($b) || !defined($main::a) || !defined($main::b);
-  $main::a <=> $main::b;
-}}
+{
+    package OtherPack;
+    no warnings 'once';
+    sub foo {
+       $answer = "not ok " if
+       defined($a) || defined($b) || !defined($main::a) || !defined($main::b);
+       $main::a <=> $main::b;
+    }
+}
 
 print $answer, $test++, "\n";
 
@@ -787,7 +794,12 @@ print(($@ =~ /^Modification of a read-only value attempted/ ?
 @b = sort {while (1) {return ($a <=> $b)} } 1..10;
 ok("@b", "1 2 3 4 5 6 7 8 9 10", "return within loop");
 
-# Clearing the array we're sorting should be okay.
-@a = (1..10);
-@b = sort {@a=(); ($a+1)<=>($b+1)} @a;
-ok("@b", "1 2 3 4 5 6 7 8 9 10", "clear array being sorted");
+# Using return() should be okay even if there are other items
+# on the stack at the time.
+@b = sort {$_ = ($a<=>$b) + do{return $b<=> $a}} 1..10;
+ok("@b", "10 9 8 7 6 5 4 3 2 1", "return with SVs on stack");
+
+# As above, but with a sort sub rather than a sort block.
+sub ret_with_stacked { $_ = ($a<=>$b) + do {return $b <=> $a} }
+@b = sort ret_with_stacked 1..10;
+ok("@b", "10 9 8 7 6 5 4 3 2 1", "return with SVs on stack");