summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2004-07-13 14:23:28 +0000
committerNicholas Clark <nick@ccl4.org>2004-07-13 14:23:28 +0000
commit75dd5fa499dd672c3f86079e60a7657e149999a8 (patch)
tree9115dad474e23b733fc915956af3854ecc9fcdd9 /t
parent6c3fb703f2b4baeb80013bb4dcb062d7252ba482 (diff)
downloadperl-75dd5fa499dd672c3f86079e60a7657e149999a8.tar.gz
Also test reverse sort in scalar context
p4raw-id: //depot/perl@23097
Diffstat (limited to 't')
-rwxr-xr-xt/op/sort.t28
1 files changed, 27 insertions, 1 deletions
diff --git a/t/op/sort.t b/t/op/sort.t
index 63b3bbb25e..5707ef9a2f 100755
--- a/t/op/sort.t
+++ b/t/op/sort.t
@@ -5,7 +5,7 @@ BEGIN {
@INC = '../lib';
}
use warnings;
-print "1..99\n";
+print "1..105\n";
# these shouldn't hang
{
@@ -444,6 +444,7 @@ ok join(" ", map {0+$_} @output), "6 7 8 3 4 5 0 1 2", 'stable $b cmp $a sort';
ok join(" ", map {0+$_} @input), "6 7 8 3 4 5 0 1 2",
'stable $b cmp $a in place sort';
+@input = &generate;
@output = reverse sort @input;
ok join(" ", map {0+$_} @output), "8 7 6 5 4 3 2 1 0", "Reversed stable sort";
@@ -452,6 +453,10 @@ ok join(" ", map {0+$_} @output), "8 7 6 5 4 3 2 1 0", "Reversed stable sort";
ok join(" ", map {0+$_} @input), "8 7 6 5 4 3 2 1 0",
"Reversed stable in place sort";
+@input = &generate;
+my $output = reverse sort @input;
+ok $output, "CCCBBBAAA", "Reversed stable sort in scalar context";
+
@input = &generate;
@output = reverse sort {$a cmp $b} @input;
@@ -464,6 +469,10 @@ ok join(" ", map {0+$_} @input), "8 7 6 5 4 3 2 1 0",
'revesed stable $a cmp $b in place sort';
@input = &generate;
+$output = reverse sort @input;
+ok $output, "CCCBBBAAA", 'Reversed stable $a cmp $b sort in scalar context';
+
+@input = &generate;
@output = reverse sort {$b cmp $a} @input;
ok join(" ", map {0+$_} @output), "2 1 0 5 4 3 8 7 6",
'reversed stable $b cmp $a sort';
@@ -473,6 +482,10 @@ ok join(" ", map {0+$_} @output), "2 1 0 5 4 3 8 7 6",
ok join(" ", map {0+$_} @input), "2 1 0 5 4 3 8 7 6",
'revesed stable $b cmp $a in place sort';
+@input = &generate;
+$output = reverse sort {$b cmp $a} @input;
+ok $output, "AAABBBCCC", 'Reversed stable $b cmp $a sort in scalar context';
+
# And now with numbers
@@ -503,6 +516,7 @@ ok "@output", "G H I D E F A B C", 'stable $b <=> $a sort';
ok "@input", "G H I D E F A B C", 'stable $b <=> $a in place sort';
# These two are actually doing string cmp on 0 1 and 2
+@input = &generate1;
@output = reverse sort @input;
ok "@output", "I H G F E D C B A", "Reversed stable sort";
@@ -511,6 +525,10 @@ ok "@output", "I H G F E D C B A", "Reversed stable sort";
ok "@input", "I H G F E D C B A", "Reversed stable in place sort";
@input = &generate1;
+$output = reverse sort @input;
+ok $output, "IHGFEDCBA", "Reversed stable sort in scalar context";
+
+@input = &generate1;
@output = reverse sort {$a <=> $b} @input;
ok "@output", "I H G F E D C B A", 'reversed stable $a <=> $b sort';
@@ -519,9 +537,17 @@ ok "@output", "I H G F E D C B A", 'reversed stable $a <=> $b sort';
ok "@input", "I H G F E D C B A", 'revesed stable $a <=> $b in place sort';
@input = &generate1;
+$output = reverse sort {$a <=> $b} @input;
+ok $output, "IHGFEDCBA", 'reversed stable $a <=> $b sort in scalar context';
+
+@input = &generate1;
@output = reverse sort {$b <=> $a} @input;
ok "@output", "C B A F E D I H G", 'reversed stable $b <=> $a sort';
@input = &generate1;
@input = reverse sort {$b <=> $a} @input;
ok "@input", "C B A F E D I H G", 'revesed stable $b <=> $a in place sort';
+
+@input = &generate1;
+$output = reverse sort {$b <=> $a} @input;
+ok $output, "CBAFEDIHG", 'reversed stable $b <=> $a sort in scalar context';