1// Copyright 2014 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
6
7function set_length(a, l) {
8  a.length = l;
9}
10
11function test1() {
12  var l = {};
13  var a = Array(l);
14  set_length(a, 3);
15  set_length(a, 3);
16  assertEquals(3, a.length);
17}
18
19function test2() {
20  var a = [];
21  set_length(a, 10);
22  set_length(a, 10);
23  Object.freeze(a);
24  set_length(a, 3);
25  set_length(a, 3);
26  assertEquals(10, a.length);
27}
28
29function test3() {
30  var a = [2];
31  Object.defineProperty(a, "length", {value:2, writable: false});
32  %ToFastProperties(a);
33  set_length([], 10);
34  set_length([], 10);
35  set_length(a, 10);
36  set_length(a, 10);
37  assertEquals(2, a.length);
38}
39
40test1();
41test2();
42test3();
43