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

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

Issue 2664173002: Throw when a holey property is set in Array.sort (Closed)
Patch Set: Not allow adding propertes in non-extensible array Created 3 years, 10 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/objects.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 fdd2333d7c8a1332e2ae7b5d6667218037c62993..ddfeffe4a20b98583f08f97b5ca09ddcc3631c13 100644
--- a/test/mjsunit/array-sort.js
+++ b/test/mjsunit/array-sort.js
@@ -480,6 +480,29 @@ function TestSortOnProxy() {
}
TestSortOnProxy();
+function TestSortOnNonExtensible() {
+ {
+ var arr = [1,,2];
+ Object.preventExtensions(arr);
+ assertThrows(() => arr.sort(), TypeError);
+ assertEquals(arr, [1,,2]);
+ }
+ {
+ var arr = [1,,undefined];
+ Object.preventExtensions(arr);
+ assertThrows(() => arr.sort(), TypeError);
+ assertFalse(arr.hasOwnProperty(1));
+ assertEquals(arr, [1,,undefined]);
+ }
+ {
+ var arr = [1,undefined,2];
+ Object.preventExtensions(arr);
+ arr.sort();
+ assertEquals(arr, [1,2,undefined]);
+ }
+}
+TestSortOnNonExtensible();
+
// Test special prototypes
(function testSortSpecialPrototypes() {
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698