Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1773)

Unified Diff: test/mjsunit/array-sort.js

Issue 7137: Testing that sorting behaves reasonably with a bad comparison function. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/array-sort.js
===================================================================
--- test/mjsunit/array-sort.js (revision 493)
+++ test/mjsunit/array-sort.js (working copy)
@@ -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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698