RT#69616: regexp SVs lose regexpness in assignment
[p5sagit/p5-mst-13.2.git] / t / op / sort.t
index 616761a..8484827 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     require 'test.pl';
 }
 use warnings;
-plan( tests => 144 );
+plan( tests => 146 );
 
 # these shouldn't hang
 {
@@ -801,3 +801,10 @@ is("@b", "10 9 8 7 6 5 4 3 2 1", "return with SVs on stack");
 sub ret_with_stacked { $_ = ($a<=>$b) + do {return $b <=> $a} }
 @b = sort ret_with_stacked 1..10;
 is("@b", "10 9 8 7 6 5 4 3 2 1", "return with SVs on stack");
+
+# Comparison code should be able to give result in non-integer representation.
+sub cmp_as_string($$) { $_[0] < $_[1] ? "-1" : $_[0] == $_[1] ? "0" : "+1" }
+@b = sort { cmp_as_string($a, $b) } (1,5,4,7,3,2,3);
+is("@b", "1 2 3 3 4 5 7", "comparison result as string");
+@b = sort cmp_as_string (1,5,4,7,3,2,3);
+is("@b", "1 2 3 3 4 5 7", "comparison result as string");