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

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

Issue 2051413004: [arrays] Fix %GetArrayKeys for special element kinds (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixed typed arrays are also packed Created 4 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/runtime/runtime-array.cc ('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 ae9f6efa663bb8aa610321898429defb03cb8d10..fdd2333d7c8a1332e2ae7b5d6667218037c62993 100644
--- a/test/mjsunit/array-sort.js
+++ b/test/mjsunit/array-sort.js
@@ -479,3 +479,68 @@ function TestSortOnProxy() {
}
}
TestSortOnProxy();
+
+
+// Test special prototypes
+(function testSortSpecialPrototypes() {
+ function test(proto, length, expected) {
+ var result = {
+ length: length,
+ __proto__: proto,
+ };
+ Array.prototype.sort.call(result);
+ assertEquals(expected.length, result.length, "result.length");
+ for (var i = 0; i<expected.length; i++) {
+ assertEquals(expected[i], result[i], "result["+i+"]");
+ }
+ }
+
+ (function fast() {
+ // Fast elements, non-empty
+ test(arguments, 0, []);
+ test(arguments, 1, [2]);
+ test(arguments, 2, [1, 2]);
+ test(arguments, 4, [1, 2, 3, 4]);
+ delete arguments[0]
+ // sort copies down the properties to the receiver, hence result[1]
+ // is read on the arguments through the hole on the receiver.
+ test(arguments, 2, [1, 1]);
+ arguments[0] = undefined;
+ test(arguments, 2, [1, undefined]);
+ })(2, 1, 4, 3);
+
+ (function fastSloppy(a) {
+ // Fast sloppy
+ test(arguments, 0, []);
+ test(arguments, 1, [2]);
+ test(arguments, 2, [1, 2]);
+ delete arguments[0]
+ test(arguments, 2, [1, 1]);
+ arguments[0] = undefined;
+ test(arguments, 2, [1, undefined]);
+ })(2, 1);
+
+ (function fastEmpty() {
+ test(arguments, 0, []);
+ test(arguments, 1, [undefined]);
+ test(arguments, 2, [undefined, undefined]);
+ })();
+
+ (function stringWrapper() {
+ // cannot redefine string wrapper properties
+ assertThrows(() => test(new String('cba'), 3, []), TypeError);
+ })();
+
+ (function typedArrys() {
+ test(new Int32Array(0), 0, []);
+ test(new Int32Array(1), 1, [0]);
+ var array = new Int32Array(3);
+ array[0] = 2;
+ array[1] = 1;
+ array[2] = 3;
+ test(array, 1, [2]);
+ test(array, 2, [1, 2]);
+ test(array, 3, [1, 2, 3]);
+ })()
+
+})();
« no previous file with comments | « src/runtime/runtime-array.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698