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

Side by Side Diff: test/mjsunit/regress/regress-595319.js

Issue 1814933002: Throw the right exceptions from setting elements in Array.prototype.concat (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: format Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « src/builtins.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // https://bugs.chromium.org/p/chromium/issues/detail?id=595319
6 // Ensure exceptions are checked for by Array.prototype.concat from adding
7 // an element, and that elements are added to array subclasses appropriately
8
9 // If adding a property does throw, the exception is propagated
10 class MyException extends Error { }
11 class NoDefinePropertyArray extends Array {
12 constructor(...args) {
13 super(...args);
14 return new Proxy(this, {
15 defineProperty() { throw new MyException(); }
16 });
17 }
18 }
19 assertThrows(() => new NoDefinePropertyArray().concat([1]), MyException);
20
21 // Ensure elements are added to the instance, rather than calling [[Set]].
22 class ZeroGetterArray extends Array { get 0() {} };
23 assertArrayEquals([1], new ZeroGetterArray().concat(1));
24
25 // Frozen arrays lead to throwing
26
27 class FrozenArray extends Array {
28 constructor(...args) { super(...args); Object.freeze(this); }
29 }
30 assertThrows(() => new FrozenArray().concat([1]), TypeError);
31
32 // Non-configurable non-writable zero leads to throwing
33 class ZeroFrozenArray extends Array {
34 constructor(...args) {
35 super(...args);
36 Object.defineProperty(this, 0, {value: 1});
37 }
38 }
39 assertThrows(() => new ZeroFrozenArray().concat([1]), TypeError);
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698