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

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

Issue 1178193004: Add ToObject call in Array.prototype.sort (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 | « src/array.js ('k') | 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
diff --git a/test/mjsunit/array-sort.js b/test/mjsunit/array-sort.js
index 62755426ade76675c0e84f333ce18146d229d595..36608f5e142e455cb86659d2c8814007cb1fc579 100644
--- a/test/mjsunit/array-sort.js
+++ b/test/mjsunit/array-sort.js
@@ -445,6 +445,22 @@ function TestSortDoesNotDependOnArrayPrototypeSort() {
fail('Should not call sort');
};
sortfn.call(arr);
+ // Restore for the next test
+ Array.prototype.sort = sortfn;
}
TestSortDoesNotDependOnArrayPrototypeSort();
+
+function TestSortToObject() {
+ Number.prototype[0] = 5;
+ Number.prototype[1] = 4;
+ Number.prototype.length = 2;
+ x = new Number(0);
+ assertEquals(0, Number(Array.prototype.sort.call(x)));
+ assertEquals(4, x[0]);
+ assertEquals(5, x[1]);
+ assertArrayEquals(["0", "1"], Object.getOwnPropertyNames(x));
+ // The following would throw if ToObject weren't called.
+ assertEquals(0, Number(Array.prototype.sort.call(0)));
+}
+TestSortToObject();
« no previous file with comments | « src/array.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698