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

Side by Side Diff: test/mjsunit/regress/regress-crbug-516775.js

Issue 1270403002: Fix Array.prototype.concat for arguments object with getter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove comment Created 5 years, 4 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/runtime/runtime-array.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 2015 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 // Flags: --allow-natives-syntax --harmony-concat-spreadable
6
7 function arguments_with_length_getter(f) {
8 arguments.__defineGetter__('length', f);
9 return arguments;
10 }
11
12 var count = 0;
13 function increment_count_return() { count++; return "boom"; }
14 function increment_count_throw() { count++; throw "boom"; }
15
16 // Do not read the length of an arguments object on the prototype chain of
17 // an array.
18 var a1 = [];
19 %NormalizeElements(a1);
20 a1.__proto__ = arguments_with_length_getter(increment_count_return);
21 [].concat(a1);
22 assertEquals(0, count);
23
24 var a2 = [];
25 %NormalizeElements(a2);
26 a2.__proto__ = arguments_with_length_getter(increment_count_throw);
27 [].concat(a2);
28 assertEquals(0, count);
29
30 // Do read the length of an arguments object if spreadable.
31 var a3 = arguments_with_length_getter(increment_count_return);
32 a3[Symbol.isConcatSpreadable] = true;
33 [].concat(a3);
34 assertEquals(1, count);
35
36 var a4 = arguments_with_length_getter(increment_count_throw);
37 a4[Symbol.isConcatSpreadable] = true;
38 assertThrows(function() { [].concat(a4); });
39 assertEquals(2, count);
40
41 // Do read the length of an arguments object on the prototype chain of
42 // an object.
43 var a5 = {};
44 a5.__proto__ = arguments_with_length_getter(increment_count_return);
45 a5[Symbol.isConcatSpreadable] = true;
46 [].concat(a5);
47 assertEquals(3, count);
48
49 var a6 = {};
50 a6.__proto__ = arguments_with_length_getter(increment_count_throw);
51 a6[Symbol.isConcatSpreadable] = true;
52 assertThrows(function() { [].concat(a6); });
53 assertEquals(4, count);
OLDNEW
« 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