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 */
15
16/*
17 * @tc.name:objectkeys
18 * @tc.desc:test object keys
19 * @tc.type: FUNC
20 */
21
22(function() {
23    const a = {};
24    Object.defineProperty(a, 'x', {
25        value: 1,
26        enumerable: false
27    });
28    let k = Object.keys(a);
29    print(k.length);
30    a.y = 2;
31    k = Object.keys(a);
32    print(k);
33})();
34
35(function() {
36    const a = {x:1, y:2};
37    let k = Object.keys(a);
38    print(k[0]);
39    print(k[1]);
40})();
41
42let obj = {
43    a: "something",
44    10: 42,
45    10: 34,
46    c: "string",
47    d: undefined,
48    d: "str",
49}
50print(Object.keys(obj));
51
52(function() {
53    let obj = {
54        '0': { x: 12, y: 24 },
55        '1000000': { x: 1, y: 2 }
56    };
57    print(Object.keys(obj));
58    print(Object.keys(obj[0]));
59    print(Object.keys(obj[1000000]));
60
61    var o = {
62        1: 1,
63        2.: 2,
64        3.0: 3,
65        4e0: 4,
66        5E0: 5,
67        6e-0: 6,
68        7E-0: 7,
69        0x8: 8,
70        0X9: 9,
71    };
72    let o1 = {1024: true};
73    let o2 = {1024: 1024};
74    print(Object.keys(o));
75    print(Object.keys(o1));
76    print(Object.keys(o2));
77})();
78
79const firstname = Symbol("firstname");
80var object = { wode:1, wode1:2, wode2:3, wod38:4, wode4:5, wodejn5:6, wode6:7, wode7:8, wewnde8:9, wode9:10, wode10:11, wfde11:12, w32de12:13, u231mk3:14, [firstname]:"symmmm"};
81print(object[firstname]);
82print(object.u231mk3);
83print(object.wodejn5);
84print(object.wewnde8);
85print(object.wode10);
86print(object.u231mk3);
87print(object[firstname]);
88print(object.hhh);
89print(object.hhh);
90Object.defineProperty(object, "deffff", {
91    value: object.wode4,
92    writable:false,
93    enumerable:true
94})
95print(object.deffff);
96object.fff = "haode";
97print(object.fff);