summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authordavid nicol <whatever@davidnicol.com>2004-07-21 12:10:05 -0500
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-07-28 06:31:06 +0000
commit59608b94bdb1503711d01a3b061daf424794da04 (patch)
treed025b13e94e971a1527ef3658aad5ef748034eaa /t
parentdc75166c4b1f2f1385d7343c148574549c247a51 (diff)
downloadperl-59608b94bdb1503711d01a3b061daf424794da04.tar.gz
Re: more 5.9 sort tests (second draft)
Message-Id: <1090447805.995.24.camel@plaza.davidnicol.com> p4raw-id: //depot/perl@23166
Diffstat (limited to 't')
-rwxr-xr-xt/op/sort.t13
1 files changed, 11 insertions, 2 deletions
diff --git a/t/op/sort.t b/t/op/sort.t
index 5aa71a49ec..bdb48856b9 100755
--- a/t/op/sort.t
+++ b/t/op/sort.t
@@ -5,7 +5,7 @@ BEGIN {
@INC = '../lib';
}
use warnings;
-print "1..127\n";
+print "1..129\n";
# these shouldn't hang
{
@@ -22,7 +22,7 @@ sub Backwards_stacked($$) { my($a,$b) = @_; $a lt $b ? 1 : $a gt $b ? -1 : 0 }
my $upperfirst = 'A' lt 'a';
# Beware: in future this may become hairier because of possible
-# collation complications: qw(A a B c) can be sorted at least as
+# collation complications: qw(A a B b) can be sorted at least as
# any of the following
#
# A a B b
@@ -577,6 +577,15 @@ ok "@output", "G H I D E F A B C", 'stable $b <=> $a sort';
@input = sort {$b <=> $a} @input;
ok "@input", "G H I D E F A B C", 'stable $b <=> $a in place sort';
+# test that optimized {$b cmp $a} and {$b <=> $a} remain stable
+# (new in 5.9) without overloading
+{ no warnings;
+@b = sort { $b <=> $a } @input = qw/5first 6first 5second 6second/;
+ok "@b" , "6first 6second 5first 5second", "optimized {$b <=> $a} without overloading" ;
+@input = sort {$b <=> $a} @input;
+ok "@input" , "6first 6second 5first 5second","inline optimized {$b <=> $a} without overloading" ;
+};
+
# These two are actually doing string cmp on 0 1 and 2
@input = &generate1;
@output = reverse sort @input;