Author: olehougaard
Date: Tue Oct 14 03:50:44 2008
New Revision: 494
Modified:
branches/bleeding_edge/test/mjsunit/array-sort.js
Log:
Testing that sorting behaves reasonably with a bad comparison function.
Review URL: http://codereview.chromium.org/7137
Modified: branches/bleeding_edge/test/mjsunit/array-sort.js
==============================================================================
--- branches/bleeding_edge/test/mjsunit/array-sort.js (original)
+++ branches/bleeding_edge/test/mjsunit/array-sort.js Tue Oct 14 03:50:44
2008
@@ -134,9 +134,21 @@
// Test array sorting with undefined elemeents in the array.
function TestArraySortingWithUndefined() {
- var a = [3, void 0, 2];
+ var a = [ 3, void 0, 2 ];
a.sort();
- assertArrayEquals([ 2, 3, void 0], a);
+ assertArrayEquals([ 2, 3, void 0 ], a);
}
TestArraySortingWithUndefined();
+
+// Test that sorting using an unsound comparison function still gives a
+// sane result, i.e. it terminates without error and retains the elements
+// in the array.
+function TestArraySortingWithUnsoundComparisonFunction() {
+ var a = [ 3, void 0, 2 ];
+ a.sort(function(x, y) { return 1; });
+ a.sort();
+ assertArrayEquals([ 2, 3, void 0 ], a);
+}
+
+TestArraySortingWithUnsoundComparisonFunction();
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---