From d7507f7459e6b42ee8cfc80abf2510fc2ff6a5c0 Mon Sep 17 00:00:00 2001 From: Robin Houston Date: Fri, 4 Nov 2005 15:20:29 +0000 Subject: Re: [PATCH] sort/multicall patch Message-ID: <20051104152029.GA17169@rpc142.cs.man.ac.uk> p4raw-id: //depot/perl@25992 --- t/op/sort.t | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 't/op/sort.t') 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"); -- cgit v1.2.1