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:objoperate
18 * @tc.desc:test object hasOwnProperty
19 * @tc.type: FUNC
20 * @tc.require: issueI5NO8G
21 */
22var str = "wodehaoxiongditiantiandouxuyao";
23var str1 = "wodehaoxiongdi";
24var str2 = "回家好好slsa";
25var str3 = "jiarenmeng";
26var str4 = str1 + str2;
27var str5 = str1 + str3;
28function fn() {
29    this.大家 = "hao";
30    this[str1] = "hao1";
31    this[str2] = "hao2";
32    this[str4] = "hao3";
33    this[str5] = "hao4";
34}
35
36var obj = new fn();
37var str6 = str.substring(0, 20);
38obj[str6] = "hao5";
39print(obj.hasOwnProperty("大家"));
40print(obj.hasOwnProperty("wodehaoxiongdi"));
41print(obj.hasOwnProperty("回家好好slsa"));
42print(obj.hasOwnProperty("wodehaoxiongdi回家好好slsa"));
43print(obj.hasOwnProperty("wodehaoxiongdijiarenmeng"));
44print(obj.hasOwnProperty("wodehaoxiongditianti"));
45
46var arr = new Array(4);
47arr[0] = 3;
48print(arr.hasOwnProperty("0"));
49print(arr.hasOwnProperty("1"));
50print(arr.hasOwnProperty("wodehaoxiongdi"));
51
52Object.defineProperty(Array.prototype, "new1", {
53    value:37,
54    writable:false,
55});
56
57var arr1 = new Array(4);
58print(arr1.new1);
59print(arr1.hasOwnProperty("0"));
60print(arr1.hasOwnProperty("new1"));
61
62var k = 5;
63print(str5.hasOwnProperty("t"));
64print(str5.hasOwnProperty("wode"));
65print(k.hasOwnProperty("t"));
66
67var person = {name: "hhh"};
68var proxy = new Proxy(person, {
69    get: function(target, property) {
70        if (property in target) {
71            return target[property];
72        } else {
73            return "cuowu";
74        }
75    }
76});
77print(proxy.name);
78print(proxy.age);
79print(proxy.hasOwnProperty('name'));
80print(proxy.hasOwnProperty('age'));
81
82let obj2 = {};
83obj2.property1 = 12;
84// is not intern string branch and not found in intern string table
85print(obj2.hasOwnProperty(String.fromCodePoint("")));
86// is not intern string branch and found in intern string table
87print(obj2.hasOwnProperty(String.fromCodePoint(123)));