Tests for having multiple pipes open simultaneously.
[p5sagit/p5-mst-13.2.git] / t / op / sort.t
index 1624b58..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 }
@@ -790,3 +793,13 @@ print(($@ =~ /^Modification of a read-only value attempted/ ?
 # Using return() should be okay even in a deeper context
 @b = sort {while (1) {return ($a <=> $b)} } 1..10;
 ok("@b", "1 2 3 4 5 6 7 8 9 10", "return within loop");
+
+# 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");