• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 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:objectcloneproperties
18 * @tc.desc:test object clone properties
19 * @tc.type: FUNC
20 * @tc.require: issueI5NO8G
21 */
22let obj = {
23    a: "something",
24    42: 42,
25    c: "string",
26    d: undefined
27}
28print(Object.keys(obj));
29
30let obj2 = {
31    a: "aa",
32    get b() {
33        this.e = "ee";
34        Object.defineProperty(obj, "c", {
35            value: "c",
36            enumerable: false
37        });
38        return "bb";
39    },
40    c: "cc",
41    123: "123"
42};
43for (const [key, value] of Object.entries(obj)) {
44    print(key + "," + value);
45}
46print("e," + obj.e);