summaryrefslogtreecommitdiff
path: root/t/op/sort.t
diff options
context:
space:
mode:
authorRobin Houston <robin@cpan.org>2005-11-04 15:20:29 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-11-04 15:41:21 +0000
commitd7507f7459e6b42ee8cfc80abf2510fc2ff6a5c0 (patch)
treef65d067e8378f64ad895b29523a7dc15fe8b51df /t/op/sort.t
parent20fac488e1792684d006c2bb2c54d6cebc9696c0 (diff)
downloadperl-d7507f7459e6b42ee8cfc80abf2510fc2ff6a5c0.tar.gz
Re: [PATCH] sort/multicall patch
Message-ID: <20051104152029.GA17169@rpc142.cs.man.ac.uk> p4raw-id: //depot/perl@25992
Diffstat (limited to 't/op/sort.t')
-rwxr-xr-xt/op/sort.t12
1 files changed, 11 insertions, 1 deletions
diff --git a/t/op/sort.t b/t/op/sort.t
index 1624b58975..42ef5f3c6c 100755
--- a/t/op/sort.t
+++ b/t/op/sort.t
@@ -5,7 +5,7 @@ BEGIN {
@INC = '../lib';
}
use warnings;
-print "1..141\n";
+print "1..143\n";
# these shouldn't hang
{
@@ -790,3 +790,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");