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

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

Issue 2664173002: Throw when a holey property is set in Array.sort (Closed)
Patch Set: Use preventExtensions for test Created 3 years, 11 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/js/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 fdd2333d7c8a1332e2ae7b5d6667218037c62993..da0dac093be02a6ffd71b83f25270bebcee3cc24 100644
--- a/test/mjsunit/array-sort.js
+++ b/test/mjsunit/array-sort.js
@@ -480,6 +480,30 @@ function TestSortOnProxy() {
}
TestSortOnProxy();
+function TestSortOnNonExtensible() {
+ {
+ var arr = [1,,2];
+ Object.preventExtensions(arr);
+ var exception = false;
+ try {
+ arr.sort();
+ } catch (e) {
+ exception = true;
+ assertTrue(e instanceof TypeError);
+ }
+ assertTrue(exception);
+ assertEquals(arr, [1,,2]);
+ }
+ {
+ var arr = [1,undefined,2];
+ Object.preventExtensions(arr);
+ arr.sort();
+ assertEquals(3, arr.length);
+ assertEquals(arr, [1,2,undefined]);
adamk 2017/02/01 16:39:13 Shouldn't this fail now?
Choongwoo Han 2017/02/01 18:21:07 Yes. In this case, this arr does not have any hole
+ }
+}
+TestSortOnNonExtensible();
+
// Test special prototypes
(function testSortSpecialPrototypes() {
« no previous file with comments | « src/js/array.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698