blob: f359cfd80b5e7ba1bdc990bed4298f867a2b4a13 [file] [log] [blame]
Ben Murdoch097c5b22016-05-18 11:27:45 +01001// 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// Flags: --expose-gc
6
7array = new Array(10);
8array[0] = 0.1;
9// array[1] = THE_HOLE, reading through the prototype chain
10array[2] = 2.1;
11array[3] = 3.1;
12
13var copy = array.slice(0, array.length);
14
15// Use the defaul array prototype.
16var proto = array.__proto__;
17
18// Define [1] on the prototype to alter the array during concatenation.
19Object.defineProperty(
20 proto, 1, {
21 get() {
22 // Alter the array.
23 array.length = 1;
24 // Force gc to move the array.
25 gc();
26 return "value from proto";
27 },
28 set(new_value) { }
29});
30
31var concatted_array = Array.prototype.concat.call(array);
32assertEquals(concatted_array[0], 0.1);
33assertEquals(concatted_array[1], "value from proto");
34assertEquals(concatted_array[2], undefined);
35assertEquals(concatted_array[3], undefined);