1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15let a = [];
16Object.defineProperty(a, "length", {writable: false});
17function f() {
18  return a.pop();
19}
20try{
21    f();
22} catch (e) {
23    print(e instanceof TypeError)
24}
25
26function f1() {
27    let x = [0,0,0,0,0];
28    Object.defineProperty(x, 'length', {value : 4, enumerable : true});
29}
30try{
31    f1();
32} catch (e) {
33    print(e instanceof TypeError)
34}
35
36let array = [];
37Object.defineProperty(array, 'length', {writable: false});
38print(array.length);
39try {
40    array.shift()
41} catch (e) {
42   print(e instanceof TypeError)
43}
44let object = { length: 0 };
45Object.defineProperty(object, 'length', {writable: false});
46print(object.length);
47try {
48    Array.prototype.shift.call(object)
49} catch {
50    print("true")
51}
52
53Object.defineProperty(this, 'x', {
54  configurable: true,
55  get: function () {return 100}
56});
57Object.defineProperty(this, 'x', {
58  value: 10
59});
60print(JSON.stringify(Object.getOwnPropertyDescriptor(this, 'x')));
61
62const o1 = {
63  k: 1
64};
65for (let i = 0; i < 1100; i++) {
66  Object.defineProperty(o1, "k" + i, {
67    value: 0,
68    enumerable: false
69  });
70}
71print(JSON.stringify(o1))
72
73function fn() { };
74let v0 = function fn1() { }.bind(fn);
75Object.defineProperty(v0, "length", {
76  writable: true
77})
78v0.length = 42;
79print(v0.length)
80