14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci/* 174514f5e3Sopenharmony_ci * @tc.name:sharedcheck 184514f5e3Sopenharmony_ci * @tc.desc:test sharedcheck 194514f5e3Sopenharmony_ci * @tc.type: FUNC 204514f5e3Sopenharmony_ci * @tc.require: issueI8QUU0 214514f5e3Sopenharmony_ci */ 224514f5e3Sopenharmony_ci 234514f5e3Sopenharmony_ci// @ts-nocheck 244514f5e3Sopenharmony_ci/* 254514f5e3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 264514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 274514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 284514f5e3Sopenharmony_ci * You may obtain a copy of the License at 294514f5e3Sopenharmony_ci * 304514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 314514f5e3Sopenharmony_ci * 324514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 334514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 344514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 354514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 364514f5e3Sopenharmony_ci * limitations under the License. 374514f5e3Sopenharmony_ci */ 384514f5e3Sopenharmony_ci 394514f5e3Sopenharmony_ci/* 404514f5e3Sopenharmony_ci * @tc.name:sharedcheck 414514f5e3Sopenharmony_ci * @tc.desc:test sharedcheck 424514f5e3Sopenharmony_ci * @tc.type: FUNC 434514f5e3Sopenharmony_ci * @tc.require: issueI8QUU0 444514f5e3Sopenharmony_ci */ 454514f5e3Sopenharmony_ci 464514f5e3Sopenharmony_ci// @ts-nocheck 474514f5e3Sopenharmony_cideclare function print(str: any): string; 484514f5e3Sopenharmony_ci 494514f5e3Sopenharmony_ciclass SimpleStringSendable { 504514f5e3Sopenharmony_ci propString: string = "I'm simple sendable's propString"; 514514f5e3Sopenharmony_ci constructor() { 524514f5e3Sopenharmony_ci "use sendable" 534514f5e3Sopenharmony_ci print(this.propString) 544514f5e3Sopenharmony_ci } 554514f5e3Sopenharmony_ci} 564514f5e3Sopenharmony_ci 574514f5e3Sopenharmony_ciclass SimpleNumberSendable { 584514f5e3Sopenharmony_ci propNumber: number = 2023; 594514f5e3Sopenharmony_ci constructor() { 604514f5e3Sopenharmony_ci "use sendable" 614514f5e3Sopenharmony_ci print("I'm constructor for SimpleNumberSendable") 624514f5e3Sopenharmony_ci } 634514f5e3Sopenharmony_ci} 644514f5e3Sopenharmony_ci 654514f5e3Sopenharmony_ciclass SimpleSendableClass { 664514f5e3Sopenharmony_ci propNumber: number = 2023; 674514f5e3Sopenharmony_ci constructor() { 684514f5e3Sopenharmony_ci "use sendable" 694514f5e3Sopenharmony_ci } 704514f5e3Sopenharmony_ci} 714514f5e3Sopenharmony_ci 724514f5e3Sopenharmony_ciclass SuperClass { 734514f5e3Sopenharmony_ci propString: string = "I'm propString" 744514f5e3Sopenharmony_ci propNumber: number = 5 754514f5e3Sopenharmony_ci propBool: boolean = false 764514f5e3Sopenharmony_ci propBigInt1: bigint = BigInt(12345678910) 774514f5e3Sopenharmony_ci propBigInt2: bigint = BigInt(987654321) 784514f5e3Sopenharmony_ci propStringOrNull: string | null = "I'm propStringOrNull" 794514f5e3Sopenharmony_ci propStringOrUndefined: string | undefined = "I'm propStringOrUndefined" 804514f5e3Sopenharmony_ci propNumberOrNull: number | null = 1 814514f5e3Sopenharmony_ci propNumberOrUndefined: number | undefined = 1 824514f5e3Sopenharmony_ci propBoolOrNull: boolean | null = true 834514f5e3Sopenharmony_ci propBoolOrUndefined: boolean | undefined = true 844514f5e3Sopenharmony_ci propBigIntOrNull: bigint | null = BigInt(12345678910) 854514f5e3Sopenharmony_ci propBigIntOrUndefined: bigint | undefined = BigInt(12345678910) 864514f5e3Sopenharmony_ci propSenableOrNull: SimpleStringSendable | null 874514f5e3Sopenharmony_ci propSenableOrUndefined: SimpleStringSendable | undefined 884514f5e3Sopenharmony_ci static staticPropString: string = "I'm staticPropString"; 894514f5e3Sopenharmony_ci publicPropString: string = "I'm privatePropString"; 904514f5e3Sopenharmony_ci propNumberToString: string = "I'm prop NumberToString"; 914514f5e3Sopenharmony_ci propSendableObj: SimpleSendableClass | null; 924514f5e3Sopenharmony_ci 934514f5e3Sopenharmony_ci get accessorPrivatePropString() { 944514f5e3Sopenharmony_ci return this.publicPropString; 954514f5e3Sopenharmony_ci } 964514f5e3Sopenharmony_ci 974514f5e3Sopenharmony_ci set accessorPrivatePropString(prop: string) { 984514f5e3Sopenharmony_ci this.publicPropString = prop; 994514f5e3Sopenharmony_ci } 1004514f5e3Sopenharmony_ci 1014514f5e3Sopenharmony_ci set accessorNumberToString(prop: string) { 1024514f5e3Sopenharmony_ci this.propNumberToString = String(prop); 1034514f5e3Sopenharmony_ci } 1044514f5e3Sopenharmony_ci 1054514f5e3Sopenharmony_ci set accessorGenerateSendable(prop: Array<number>) { 1064514f5e3Sopenharmony_ci let obj = new SimpleSendableClass(); 1074514f5e3Sopenharmony_ci obj.propNumber = prop.pop(); 1084514f5e3Sopenharmony_ci this.propSendableObj = obj; 1094514f5e3Sopenharmony_ci } 1104514f5e3Sopenharmony_ci 1114514f5e3Sopenharmony_ci constructor() { 1124514f5e3Sopenharmony_ci "use sendable" 1134514f5e3Sopenharmony_ci print(this.propString) 1144514f5e3Sopenharmony_ci } 1154514f5e3Sopenharmony_ci} 1164514f5e3Sopenharmony_ci 1174514f5e3Sopenharmony_ciclass SubClass extends SuperClass { 1184514f5e3Sopenharmony_ci static staticSubClassPropString: string = "I'm staticSubClassPropString"; 1194514f5e3Sopenharmony_ci static staticFunc() { 1204514f5e3Sopenharmony_ci print("Hi static func"); 1214514f5e3Sopenharmony_ci } 1224514f5e3Sopenharmony_ci static staticFunc1() { 1234514f5e3Sopenharmony_ci print("Hi static func1"); 1244514f5e3Sopenharmony_ci } 1254514f5e3Sopenharmony_ci 1264514f5e3Sopenharmony_ci func() { 1274514f5e3Sopenharmony_ci print("Hi func"); 1284514f5e3Sopenharmony_ci this.publicFunc(); 1294514f5e3Sopenharmony_ci } 1304514f5e3Sopenharmony_ci 1314514f5e3Sopenharmony_ci publicFunc() { 1324514f5e3Sopenharmony_ci print("Hi public func"); 1334514f5e3Sopenharmony_ci } 1344514f5e3Sopenharmony_ci 1354514f5e3Sopenharmony_ci subClassPropString: string = "I'm subClassPropString" 1364514f5e3Sopenharmony_ci subClassPropSendable: SimpleStringSendable 1374514f5e3Sopenharmony_ci constructor() { 1384514f5e3Sopenharmony_ci "use sendable" 1394514f5e3Sopenharmony_ci super() 1404514f5e3Sopenharmony_ci } 1414514f5e3Sopenharmony_ci} 1424514f5e3Sopenharmony_ci 1434514f5e3Sopenharmony_cifunction testDelete(testObj: SubClass) { 1444514f5e3Sopenharmony_ci print("Start testDelete"); 1454514f5e3Sopenharmony_ci try { 1464514f5e3Sopenharmony_ci delete testObj.propNumber; 1474514f5e3Sopenharmony_ci print("Success delete propNumber") 1484514f5e3Sopenharmony_ci } catch (error) { 1494514f5e3Sopenharmony_ci print("Fail to delete propNumber. err: " + error) 1504514f5e3Sopenharmony_ci } 1514514f5e3Sopenharmony_ci} 1524514f5e3Sopenharmony_ci 1534514f5e3Sopenharmony_cifunction testExtend(testObj: SubClass) { 1544514f5e3Sopenharmony_ci print("Start testExtend"); 1554514f5e3Sopenharmony_ci try { 1564514f5e3Sopenharmony_ci Object.defineProperty(testObj, "tmpProp", {value: 321, writable: true }); 1574514f5e3Sopenharmony_ci print("Success to extend prop with defineProperty") 1584514f5e3Sopenharmony_ci } catch (error) { 1594514f5e3Sopenharmony_ci print("Fail to extend prop with defineProperty. err: " + error); 1604514f5e3Sopenharmony_ci } 1614514f5e3Sopenharmony_ci 1624514f5e3Sopenharmony_ci try { 1634514f5e3Sopenharmony_ci Object.defineProperty(testObj, "prop1", { writable: true }); 1644514f5e3Sopenharmony_ci print("Success extend prop1 with defineProperty") 1654514f5e3Sopenharmony_ci } catch (error) { 1664514f5e3Sopenharmony_ci print("Fail to extend prop1 with defineProperty. err: " + error) 1674514f5e3Sopenharmony_ci } 1684514f5e3Sopenharmony_ci 1694514f5e3Sopenharmony_ci try { 1704514f5e3Sopenharmony_ci Object.defineProperties(testObj, { prop2: { writable: true } }); 1714514f5e3Sopenharmony_ci print("Success extend prop2 with defineProperties") 1724514f5e3Sopenharmony_ci } catch (error) { 1734514f5e3Sopenharmony_ci print("Fail to extend prop2 with defineProperties. err: " + error) 1744514f5e3Sopenharmony_ci } 1754514f5e3Sopenharmony_ci 1764514f5e3Sopenharmony_ci try { 1774514f5e3Sopenharmony_ci testObj.prop3 = {}; 1784514f5e3Sopenharmony_ci print("Success extend prop3 with stobjbyname") 1794514f5e3Sopenharmony_ci } catch (error) { 1804514f5e3Sopenharmony_ci print("Fail to extend prop3 with stobjbyname. err: " + error) 1814514f5e3Sopenharmony_ci } 1824514f5e3Sopenharmony_ci} 1834514f5e3Sopenharmony_ci 1844514f5e3Sopenharmony_cifunction testUpdateInstanceFunction(testObj: SubClass) { 1854514f5e3Sopenharmony_ci print("Start testUpdateInstanceFunction"); 1864514f5e3Sopenharmony_ci try { 1874514f5e3Sopenharmony_ci testObj.func = function () { } 1884514f5e3Sopenharmony_ci print("Success replace instance's func"); 1894514f5e3Sopenharmony_ci } catch (error) { 1904514f5e3Sopenharmony_ci print("Fail to replace instance's func. err: " + error); 1914514f5e3Sopenharmony_ci } 1924514f5e3Sopenharmony_ci} 1934514f5e3Sopenharmony_ci 1944514f5e3Sopenharmony_cifunction testUpdatePrototype(testObj: SubClass) { 1954514f5e3Sopenharmony_ci print("Start testUpdatePrototype"); 1964514f5e3Sopenharmony_ci try { 1974514f5e3Sopenharmony_ci SuperClass.prototype.staticSubClassPropString = 1; 1984514f5e3Sopenharmony_ci print("Success update prototype") 1994514f5e3Sopenharmony_ci } catch (error) { 2004514f5e3Sopenharmony_ci print("Fail to update prototype. err: " + error) 2014514f5e3Sopenharmony_ci } 2024514f5e3Sopenharmony_ci 2034514f5e3Sopenharmony_ci try { 2044514f5e3Sopenharmony_ci SubClass.prototype.tmpProp = 123; 2054514f5e3Sopenharmony_ci print("Success to extend prop to constructor's prototype."); 2064514f5e3Sopenharmony_ci } catch (error) { 2074514f5e3Sopenharmony_ci print("Fail to extend prop to constructor's prototype. err: " + error); 2084514f5e3Sopenharmony_ci } 2094514f5e3Sopenharmony_ci 2104514f5e3Sopenharmony_ci let superClass = new SuperClass() 2114514f5e3Sopenharmony_ci try { 2124514f5e3Sopenharmony_ci testObj.__proto__.constructor = superClass.__proto__.constructor; 2134514f5e3Sopenharmony_ci print("Success to change constructor of instance's prototype."); 2144514f5e3Sopenharmony_ci } catch (error) { 2154514f5e3Sopenharmony_ci print("Fail to change constructor of instance's prototype. err: " + error); 2164514f5e3Sopenharmony_ci } 2174514f5e3Sopenharmony_ci 2184514f5e3Sopenharmony_ci try { 2194514f5e3Sopenharmony_ci testObj.__proto__ = superClass.__proto__; 2204514f5e3Sopenharmony_ci print("Success to replace instance's prototype."); 2214514f5e3Sopenharmony_ci } catch (error) { 2224514f5e3Sopenharmony_ci print("Fail to replace instance's prototype. err: " + error); 2234514f5e3Sopenharmony_ci } 2244514f5e3Sopenharmony_ci 2254514f5e3Sopenharmony_ci try { 2264514f5e3Sopenharmony_ci Object.defineProperty(testObj.__proto__, "abc", { value: 123 }); 2274514f5e3Sopenharmony_ci print("Success to extend instance's prototype."); 2284514f5e3Sopenharmony_ci } catch (error) { 2294514f5e3Sopenharmony_ci print("Fail to extend instance's prototype. err: " + error); 2304514f5e3Sopenharmony_ci } 2314514f5e3Sopenharmony_ci} 2324514f5e3Sopenharmony_ci 2334514f5e3Sopenharmony_cifunction testUpdateInstancePropsToNull(testObj: SubClass) { 2344514f5e3Sopenharmony_ci print("Start testUpdateInstancePropsToNull"); 2354514f5e3Sopenharmony_ci try { 2364514f5e3Sopenharmony_ci testObj.propString = null 2374514f5e3Sopenharmony_ci print("Success update propString to null with stobjbyname") 2384514f5e3Sopenharmony_ci } catch (error) { 2394514f5e3Sopenharmony_ci print("Fail to update propString to null with stobjbyname. err: " + error) 2404514f5e3Sopenharmony_ci } 2414514f5e3Sopenharmony_ci 2424514f5e3Sopenharmony_ci try { 2434514f5e3Sopenharmony_ci testObj.subClassPropSendable = null 2444514f5e3Sopenharmony_ci print("Success update subClassPropSendable to null with stobjbyname") 2454514f5e3Sopenharmony_ci } catch (error) { 2464514f5e3Sopenharmony_ci print("Fail to update subClassPropSendable to null with stobjbyname. err: " + error) 2474514f5e3Sopenharmony_ci } 2484514f5e3Sopenharmony_ci 2494514f5e3Sopenharmony_ci try { 2504514f5e3Sopenharmony_ci testObj.propNumber = null 2514514f5e3Sopenharmony_ci print("Success update propNumber to null with stobjbyname") 2524514f5e3Sopenharmony_ci } catch (error) { 2534514f5e3Sopenharmony_ci print("Fail to update propNumber to null with stobjbyname. err: " + error) 2544514f5e3Sopenharmony_ci } 2554514f5e3Sopenharmony_ci 2564514f5e3Sopenharmony_ci try { 2574514f5e3Sopenharmony_ci testObj.propBool = null 2584514f5e3Sopenharmony_ci print("Success update propBool to null with stobjbyname") 2594514f5e3Sopenharmony_ci } catch (error) { 2604514f5e3Sopenharmony_ci print("Fail to update propBool to null with stobjbyname. err: " + error) 2614514f5e3Sopenharmony_ci } 2624514f5e3Sopenharmony_ci 2634514f5e3Sopenharmony_ci try { 2644514f5e3Sopenharmony_ci testObj.propBigInt1 = null 2654514f5e3Sopenharmony_ci print("Success update propBigInt1 to null with stobjbyname") 2664514f5e3Sopenharmony_ci } catch (error) { 2674514f5e3Sopenharmony_ci print("Fail to update propBigInt1 to null with stobjbyname. err: " + error) 2684514f5e3Sopenharmony_ci } 2694514f5e3Sopenharmony_ci 2704514f5e3Sopenharmony_ci try { 2714514f5e3Sopenharmony_ci testObj.propBigInt2 = null 2724514f5e3Sopenharmony_ci print("Success update propBigInt2 to null with stobjbyname") 2734514f5e3Sopenharmony_ci } catch (error) { 2744514f5e3Sopenharmony_ci print("Fail to update propBigInt2 to null with stobjbyname. err: " + error) 2754514f5e3Sopenharmony_ci } 2764514f5e3Sopenharmony_ci 2774514f5e3Sopenharmony_ci try { 2784514f5e3Sopenharmony_ci testObj.propStringOrNull = null 2794514f5e3Sopenharmony_ci print("Success update propStringOrNull to null with stobjbyname") 2804514f5e3Sopenharmony_ci } catch (error) { 2814514f5e3Sopenharmony_ci print("Fail to update propStringOrNull to null with stobjbyname. err: " + error) 2824514f5e3Sopenharmony_ci } 2834514f5e3Sopenharmony_ci 2844514f5e3Sopenharmony_ci try { 2854514f5e3Sopenharmony_ci testObj.propNumberOrNull = null 2864514f5e3Sopenharmony_ci print("Success update propNumberOrNull to null with stobjbyname") 2874514f5e3Sopenharmony_ci } catch (error) { 2884514f5e3Sopenharmony_ci print("Fail to update propNumberOrNull to null with stobjbyname. err: " + error) 2894514f5e3Sopenharmony_ci } 2904514f5e3Sopenharmony_ci 2914514f5e3Sopenharmony_ci try { 2924514f5e3Sopenharmony_ci testObj.propBoolOrNull = null 2934514f5e3Sopenharmony_ci print("Success update propBoolOrNull to null with stobjbyname") 2944514f5e3Sopenharmony_ci } catch (error) { 2954514f5e3Sopenharmony_ci print("Fail to update propBoolOrNull to null with stobjbyname. err: " + error) 2964514f5e3Sopenharmony_ci } 2974514f5e3Sopenharmony_ci 2984514f5e3Sopenharmony_ci try { 2994514f5e3Sopenharmony_ci testObj.propBigIntOrNull = null 3004514f5e3Sopenharmony_ci print("Success update propBigIntOrNull to null with stobjbyname") 3014514f5e3Sopenharmony_ci } catch (error) { 3024514f5e3Sopenharmony_ci print("Fail to update propBigIntOrNull to null with stobjbyname. err: " + error) 3034514f5e3Sopenharmony_ci } 3044514f5e3Sopenharmony_ci 3054514f5e3Sopenharmony_ci try { 3064514f5e3Sopenharmony_ci testObj.propSenableOrNull = null 3074514f5e3Sopenharmony_ci print("Success update propSenableOrNull to null with stobjbyname") 3084514f5e3Sopenharmony_ci } catch (error) { 3094514f5e3Sopenharmony_ci print("Fail to update propSenableOrNull to null with stobjbyname. err: " + error) 3104514f5e3Sopenharmony_ci } 3114514f5e3Sopenharmony_ci} 3124514f5e3Sopenharmony_ci 3134514f5e3Sopenharmony_cifunction testUpdateInstancePropsToUndefined(testObj: SubClass) { 3144514f5e3Sopenharmony_ci print("Start testUpdateInstancePropsToUndefined"); 3154514f5e3Sopenharmony_ci try { 3164514f5e3Sopenharmony_ci testObj.propString = undefined 3174514f5e3Sopenharmony_ci print("Success update propString to undefined with stobjbyname") 3184514f5e3Sopenharmony_ci } catch (error) { 3194514f5e3Sopenharmony_ci print("Fail to update propString to undefined with stobjbyname. err: " + error) 3204514f5e3Sopenharmony_ci } 3214514f5e3Sopenharmony_ci 3224514f5e3Sopenharmony_ci try { 3234514f5e3Sopenharmony_ci testObj.subClassPropSendable = undefined 3244514f5e3Sopenharmony_ci print("Success update subClassPropSendable to undefined with stobjbyname") 3254514f5e3Sopenharmony_ci } catch (error) { 3264514f5e3Sopenharmony_ci print("Fail to update subClassPropSendable to undefined with stobjbyname. err: " + error) 3274514f5e3Sopenharmony_ci } 3284514f5e3Sopenharmony_ci 3294514f5e3Sopenharmony_ci try { 3304514f5e3Sopenharmony_ci testObj.propNumber = undefined 3314514f5e3Sopenharmony_ci print("Success update propNumber to undefined with stobjbyname") 3324514f5e3Sopenharmony_ci } catch (error) { 3334514f5e3Sopenharmony_ci print("Fail to update propNumber to undefined with stobjbyname. err: " + error) 3344514f5e3Sopenharmony_ci } 3354514f5e3Sopenharmony_ci 3364514f5e3Sopenharmony_ci try { 3374514f5e3Sopenharmony_ci testObj.propBool = undefined 3384514f5e3Sopenharmony_ci print("Success update propBool to undefined with stobjbyname") 3394514f5e3Sopenharmony_ci } catch (error) { 3404514f5e3Sopenharmony_ci print("Fail to update propBool to undefined with stobjbyname. err: " + error) 3414514f5e3Sopenharmony_ci } 3424514f5e3Sopenharmony_ci 3434514f5e3Sopenharmony_ci try { 3444514f5e3Sopenharmony_ci testObj.propBigInt1 = undefined 3454514f5e3Sopenharmony_ci print("Success update propBigInt1 to undefined with stobjbyname") 3464514f5e3Sopenharmony_ci } catch (error) { 3474514f5e3Sopenharmony_ci print("Fail to update propBigInt1 to undefined with stobjbyname. err: " + error) 3484514f5e3Sopenharmony_ci } 3494514f5e3Sopenharmony_ci 3504514f5e3Sopenharmony_ci try { 3514514f5e3Sopenharmony_ci testObj.propBigInt2 = undefined 3524514f5e3Sopenharmony_ci print("Success update propBigInt2 to undefined with stobjbyname") 3534514f5e3Sopenharmony_ci } catch (error) { 3544514f5e3Sopenharmony_ci print("Fail to update propBigInt2 to undefined with stobjbyname. err: " + error) 3554514f5e3Sopenharmony_ci } 3564514f5e3Sopenharmony_ci 3574514f5e3Sopenharmony_ci try { 3584514f5e3Sopenharmony_ci testObj.propStringOrUndefined = undefined 3594514f5e3Sopenharmony_ci print("Success update propStringOrUndefined to undefined with stobjbyname") 3604514f5e3Sopenharmony_ci } catch (error) { 3614514f5e3Sopenharmony_ci print("Fail to update propStringOrUndefined to undefined with stobjbyname. err: " + error) 3624514f5e3Sopenharmony_ci } 3634514f5e3Sopenharmony_ci 3644514f5e3Sopenharmony_ci try { 3654514f5e3Sopenharmony_ci testObj.propNumberOrUndefined = undefined 3664514f5e3Sopenharmony_ci print("Success update propNumberOrUndefined to undefined with stobjbyname") 3674514f5e3Sopenharmony_ci } catch (error) { 3684514f5e3Sopenharmony_ci print("Fail to update propNumberOrUndefined to undefined with stobjbyname. err: " + error) 3694514f5e3Sopenharmony_ci } 3704514f5e3Sopenharmony_ci 3714514f5e3Sopenharmony_ci try { 3724514f5e3Sopenharmony_ci testObj.propBoolOrUndefined = undefined 3734514f5e3Sopenharmony_ci print("Success update propBoolOrUndefined to undefined with stobjbyname") 3744514f5e3Sopenharmony_ci } catch (error) { 3754514f5e3Sopenharmony_ci print("Fail to update propBoolOrUndefined to undefined with stobjbyname. err: " + error) 3764514f5e3Sopenharmony_ci } 3774514f5e3Sopenharmony_ci 3784514f5e3Sopenharmony_ci try { 3794514f5e3Sopenharmony_ci testObj.propBigIntOrUndefined = undefined 3804514f5e3Sopenharmony_ci print("Success update propBigIntOrUndefined to undefined with stobjbyname") 3814514f5e3Sopenharmony_ci } catch (error) { 3824514f5e3Sopenharmony_ci print("Fail to update propBigIntOrUndefined to undefined with stobjbyname. err: " + error) 3834514f5e3Sopenharmony_ci } 3844514f5e3Sopenharmony_ci 3854514f5e3Sopenharmony_ci try { 3864514f5e3Sopenharmony_ci testObj.propSenableOrUndefined = undefined 3874514f5e3Sopenharmony_ci print("Success update propSenableOrUndefined to undefined with stobjbyname") 3884514f5e3Sopenharmony_ci } catch (error) { 3894514f5e3Sopenharmony_ci print("Fail to update propSenableOrUndefined to undefined with stobjbyname. err: " + error) 3904514f5e3Sopenharmony_ci } 3914514f5e3Sopenharmony_ci} 3924514f5e3Sopenharmony_ci 3934514f5e3Sopenharmony_cifunction testUpdateInstanceProps(testObj: SubClass) { 3944514f5e3Sopenharmony_ci testUpdateInstancePropsToNull(testObj); 3954514f5e3Sopenharmony_ci testUpdateInstancePropsToUndefined(testObj); 3964514f5e3Sopenharmony_ci try { 3974514f5e3Sopenharmony_ci Object.defineProperties(testObj, { subClassPropString: { value: "hello", writable: true } }); 3984514f5e3Sopenharmony_ci print("Success update subClassPropString with defineProperties") 3994514f5e3Sopenharmony_ci } catch (error) { 4004514f5e3Sopenharmony_ci print("Fail to update subClassPropString with defineProperties. err: " + error) 4014514f5e3Sopenharmony_ci } 4024514f5e3Sopenharmony_ci 4034514f5e3Sopenharmony_ci try { 4044514f5e3Sopenharmony_ci Object.defineProperty(testObj, "propNumber", { value: 100, configurable: false }); 4054514f5e3Sopenharmony_ci print("Success update propNumber with defineProperty") 4064514f5e3Sopenharmony_ci } catch (error) { 4074514f5e3Sopenharmony_ci print("Fail to update propNumber with defineProperty. err: " + error) 4084514f5e3Sopenharmony_ci } 4094514f5e3Sopenharmony_ci 4104514f5e3Sopenharmony_ci try { 4114514f5e3Sopenharmony_ci testObj.subClassPropString = 33; 4124514f5e3Sopenharmony_ci print("Success update subClassPropString with stobjbyname") 4134514f5e3Sopenharmony_ci } catch (error) { 4144514f5e3Sopenharmony_ci print("Fail to update subClassPropString with stobjbyname. err: " + error) 4154514f5e3Sopenharmony_ci } 4164514f5e3Sopenharmony_ci} 4174514f5e3Sopenharmony_ci 4184514f5e3Sopenharmony_cifunction testUpdateInstanceAccessor(testObj: SubClass) { 4194514f5e3Sopenharmony_ci print("Start testUpdateInstanceAccessor"); 4204514f5e3Sopenharmony_ci try { 4214514f5e3Sopenharmony_ci Object.defineProperty(testObj, "accessorPrivatePropString", 4224514f5e3Sopenharmony_ci { 4234514f5e3Sopenharmony_ci get accessorPrivatePropString() { print("Replaced get accessor") }, 4244514f5e3Sopenharmony_ci set accessorPrivatePropString(prop: string) { print("Replaced set accessor") } 4254514f5e3Sopenharmony_ci }) 4264514f5e3Sopenharmony_ci print("Success replace accessor"); 4274514f5e3Sopenharmony_ci } catch (error) { 4284514f5e3Sopenharmony_ci print("Fail to replace accessor. err: " + error); 4294514f5e3Sopenharmony_ci } 4304514f5e3Sopenharmony_ci 4314514f5e3Sopenharmony_ci try { 4324514f5e3Sopenharmony_ci testObj.accessorPrivatePropString = "123" 4334514f5e3Sopenharmony_ci print("Success set prop through accessor with matched type"); 4344514f5e3Sopenharmony_ci } catch (error) { 4354514f5e3Sopenharmony_ci print("Fail to set prop through accessor with matched type. err: " + error); 4364514f5e3Sopenharmony_ci } 4374514f5e3Sopenharmony_ci 4384514f5e3Sopenharmony_ci try { 4394514f5e3Sopenharmony_ci testObj.accessorPrivatePropString = 123 4404514f5e3Sopenharmony_ci print("Success set prop through accessor with mismatched type"); 4414514f5e3Sopenharmony_ci } catch (error) { 4424514f5e3Sopenharmony_ci print("Fail to set prop through accessor with mismatched type. err: " + error); 4434514f5e3Sopenharmony_ci } 4444514f5e3Sopenharmony_ci} 4454514f5e3Sopenharmony_ci 4464514f5e3Sopenharmony_cifunction testUpdateConstructor() { 4474514f5e3Sopenharmony_ci print("Start testUpdateConstructor"); 4484514f5e3Sopenharmony_ci try { 4494514f5e3Sopenharmony_ci SubClass.staticFunc = function () { }; 4504514f5e3Sopenharmony_ci print("Success to modify constructor's method."); 4514514f5e3Sopenharmony_ci } catch (error) { 4524514f5e3Sopenharmony_ci print("Fail to modify constructor's method. err: " + error); 4534514f5e3Sopenharmony_ci } 4544514f5e3Sopenharmony_ci 4554514f5e3Sopenharmony_ci try { 4564514f5e3Sopenharmony_ci SubClass.staticSubClassPropString = "modify static"; 4574514f5e3Sopenharmony_ci print("Success to modify property to constructor's property."); 4584514f5e3Sopenharmony_ci } catch (error) { 4594514f5e3Sopenharmony_ci print("Fail to modify property to constructor's property. err: " + error); 4604514f5e3Sopenharmony_ci } 4614514f5e3Sopenharmony_ci} 4624514f5e3Sopenharmony_ci 4634514f5e3Sopenharmony_cifunction testObjectProtoFunc(testObj: SubClass) { 4644514f5e3Sopenharmony_ci print("Start testObjectProtoFunc"); 4654514f5e3Sopenharmony_ci testObjectAssign(testObj); 4664514f5e3Sopenharmony_ci testObjectCreate(testObj); 4674514f5e3Sopenharmony_ci testObjectSetPrototypeOf(testObj); 4684514f5e3Sopenharmony_ci testObjectAttributesAndExtensible(testObj); 4694514f5e3Sopenharmony_ci} 4704514f5e3Sopenharmony_ci 4714514f5e3Sopenharmony_cifunction testObjectCreate(testObj: SubClass) 4724514f5e3Sopenharmony_ci{ 4734514f5e3Sopenharmony_ci print("Start testObjectCreate"); 4744514f5e3Sopenharmony_ci try { 4754514f5e3Sopenharmony_ci let sendableSimple: SimpleStringSendable = Object.create(SimpleStringSendable); 4764514f5e3Sopenharmony_ci print("Success to call Object.create"); 4774514f5e3Sopenharmony_ci } catch (error) { 4784514f5e3Sopenharmony_ci print("Fail to call Object.create. err: " + error); 4794514f5e3Sopenharmony_ci } 4804514f5e3Sopenharmony_ci} 4814514f5e3Sopenharmony_ci 4824514f5e3Sopenharmony_cifunction testObjectSetPrototypeOf(testObj: SubClass) 4834514f5e3Sopenharmony_ci{ 4844514f5e3Sopenharmony_ci print("Start testObjectSetPrototypeOf"); 4854514f5e3Sopenharmony_ci try { 4864514f5e3Sopenharmony_ci Object.setPrototypeOf(testObj, new Object) 4874514f5e3Sopenharmony_ci print("Success to call Object.setPrototypeOf") 4884514f5e3Sopenharmony_ci } catch (error) { 4894514f5e3Sopenharmony_ci print("Fail to call Object.setPrototypeOf. err: " + error) 4904514f5e3Sopenharmony_ci } 4914514f5e3Sopenharmony_ci} 4924514f5e3Sopenharmony_ci 4934514f5e3Sopenharmony_cifunction testObjectAttributesAndExtensible(testObj: SubClass) 4944514f5e3Sopenharmony_ci{ 4954514f5e3Sopenharmony_ci print("Start testObjectAttributesAndExtensible"); 4964514f5e3Sopenharmony_ci try { 4974514f5e3Sopenharmony_ci Object.defineProperty(testObj, "propNumber", { configurable: true }); 4984514f5e3Sopenharmony_ci print("Success to update propNumber to configurable with defineProperty") 4994514f5e3Sopenharmony_ci } catch (error) { 5004514f5e3Sopenharmony_ci print("Fail to update propNumber to configurable with defineProperty. err: " + error) 5014514f5e3Sopenharmony_ci } 5024514f5e3Sopenharmony_ci print("isFrozen: " + Object.isFrozen(testObj)) 5034514f5e3Sopenharmony_ci try { 5044514f5e3Sopenharmony_ci Object.freeze(testObj); 5054514f5e3Sopenharmony_ci print("Success to call Object.freeze") 5064514f5e3Sopenharmony_ci } catch (error) { 5074514f5e3Sopenharmony_ci print("Fail to call Object.freeze. err: " + error) 5084514f5e3Sopenharmony_ci } 5094514f5e3Sopenharmony_ci print("isFrozen: " + Object.isFrozen(testObj)) 5104514f5e3Sopenharmony_ci print("isSealed: " + Object.isSealed(testObj)) 5114514f5e3Sopenharmony_ci try { 5124514f5e3Sopenharmony_ci Object.seal(testObj); 5134514f5e3Sopenharmony_ci print("Success to call Object.seal in sealed state") 5144514f5e3Sopenharmony_ci } catch (error) { 5154514f5e3Sopenharmony_ci print("Fail to call Object.seal in sealed state. err: " + error) 5164514f5e3Sopenharmony_ci } 5174514f5e3Sopenharmony_ci print("isExtensible: " + Object.isExtensible(testObj)) 5184514f5e3Sopenharmony_ci try { 5194514f5e3Sopenharmony_ci Object.preventExtensions(testObj); 5204514f5e3Sopenharmony_ci print("Success to call Object.preventExtensions in preventExtensions state.") 5214514f5e3Sopenharmony_ci } catch (error) { 5224514f5e3Sopenharmony_ci print("Fail to to call Object.preventExtensions in preventExtensions state. err: " + error) 5234514f5e3Sopenharmony_ci } 5244514f5e3Sopenharmony_ci} 5254514f5e3Sopenharmony_ci 5264514f5e3Sopenharmony_cifunction testObjectAssign(testObj: SubClass) 5274514f5e3Sopenharmony_ci{ 5284514f5e3Sopenharmony_ci print("Start testObjectAssign"); 5294514f5e3Sopenharmony_ci try { 5304514f5e3Sopenharmony_ci Object.assign(testObj, new Object({ a: 1, b: "abc" })); 5314514f5e3Sopenharmony_ci print("Success to call Object.assign to extend target"); 5324514f5e3Sopenharmony_ci } catch (error) { 5334514f5e3Sopenharmony_ci print("Fail to call Object.assign to extend target. err: " + error); 5344514f5e3Sopenharmony_ci } 5354514f5e3Sopenharmony_ci 5364514f5e3Sopenharmony_ci try { 5374514f5e3Sopenharmony_ci Object.assign(testObj, new Object({ propString: 0 })); 5384514f5e3Sopenharmony_ci print("Success to call Object.assign to update propString with mismatched type"); 5394514f5e3Sopenharmony_ci } catch (error) { 5404514f5e3Sopenharmony_ci print("Fail to call Object.assign to update propString with mismatched type. err: " + error); 5414514f5e3Sopenharmony_ci } 5424514f5e3Sopenharmony_ci 5434514f5e3Sopenharmony_ci try { 5444514f5e3Sopenharmony_ci Object.assign(testObj, new Object({ propString: "abc" })); 5454514f5e3Sopenharmony_ci print("Success to call Object.assign to update propString"); 5464514f5e3Sopenharmony_ci } catch (error) { 5474514f5e3Sopenharmony_ci print("Fail to call Object.assign to update propString. err: " + error); 5484514f5e3Sopenharmony_ci } 5494514f5e3Sopenharmony_ci} 5504514f5e3Sopenharmony_ci 5514514f5e3Sopenharmony_cifunction testKeywords(testObj: SubClass) 5524514f5e3Sopenharmony_ci{ 5534514f5e3Sopenharmony_ci print("Start testKeywords"); 5544514f5e3Sopenharmony_ci print("typeof sendable object: " + (typeof testObj)) 5554514f5e3Sopenharmony_ci print("typeof sendable function: " + (typeof testObj.func)) 5564514f5e3Sopenharmony_ci print("sendable instanceof Object: " + (testObj instanceof Object)) 5574514f5e3Sopenharmony_ci print("sendable instanceof SubClass: " + (testObj instanceof SubClass)) 5584514f5e3Sopenharmony_ci print("sendable instanceof SuperClass: " + (testObj instanceof SuperClass)) 5594514f5e3Sopenharmony_ci} 5604514f5e3Sopenharmony_ci 5614514f5e3Sopenharmony_cifunction testUpdate(testObj: SubClass) { 5624514f5e3Sopenharmony_ci testUpdateInstanceProps(testObj); 5634514f5e3Sopenharmony_ci testUpdateInstanceAccessor(testObj); 5644514f5e3Sopenharmony_ci testUpdateInstanceFunction(testObj); 5654514f5e3Sopenharmony_ci testUpdatePrototype(testObj); 5664514f5e3Sopenharmony_ci testUpdateConstructor(); 5674514f5e3Sopenharmony_ci} 5684514f5e3Sopenharmony_ci 5694514f5e3Sopenharmony_cifunction testUpdateWithType(testObj: SubClass) { 5704514f5e3Sopenharmony_ci print("Start testUpdateWithType"); 5714514f5e3Sopenharmony_ci try { 5724514f5e3Sopenharmony_ci testObj.propString = 1; 5734514f5e3Sopenharmony_ci print("Success update string to int with stobjbynamme.") 5744514f5e3Sopenharmony_ci } catch (error) { 5754514f5e3Sopenharmony_ci print("Fail to update string to int with stobjbynamme. err: " + error); 5764514f5e3Sopenharmony_ci } 5774514f5e3Sopenharmony_ci 5784514f5e3Sopenharmony_ci try { 5794514f5e3Sopenharmony_ci testObj.propBigInt1 = 1; 5804514f5e3Sopenharmony_ci print("Success update bigInt to int with stobjbynamme.") 5814514f5e3Sopenharmony_ci } catch (error) { 5824514f5e3Sopenharmony_ci print("Fail to update bigInt to int with stobjbynamme. err: " + error); 5834514f5e3Sopenharmony_ci } 5844514f5e3Sopenharmony_ci 5854514f5e3Sopenharmony_ci try { 5864514f5e3Sopenharmony_ci testObj.propBigInt2 = BigInt(123456789); 5874514f5e3Sopenharmony_ci print("Success update bigInt to bigInt with stobjbynamme.") 5884514f5e3Sopenharmony_ci } catch (error) { 5894514f5e3Sopenharmony_ci print("Fail to update bigInt to int with stobjbynamme. err: " + error); 5904514f5e3Sopenharmony_ci } 5914514f5e3Sopenharmony_ci 5924514f5e3Sopenharmony_ci try { 5934514f5e3Sopenharmony_ci Object.defineProperty(testObj, "subClassPropSendable", { value: 123, writable: true }); 5944514f5e3Sopenharmony_ci print("Success update subClassPropSendable to number with defineProperty.") 5954514f5e3Sopenharmony_ci } catch (error) { 5964514f5e3Sopenharmony_ci print("Fail to update subClassPropSendable to number with defineProperty. err: " + error); 5974514f5e3Sopenharmony_ci } 5984514f5e3Sopenharmony_ci 5994514f5e3Sopenharmony_ci try { 6004514f5e3Sopenharmony_ci Object.defineProperty(testObj, "subClassPropSendable", { value: new SimpleNumberSendable(), writable: true }); 6014514f5e3Sopenharmony_ci print("Success update subClassPropSendable to numberSendable with defineProperty.") 6024514f5e3Sopenharmony_ci } catch (error) { 6034514f5e3Sopenharmony_ci print("Fail to update subClassPropSendable to numberSendable with defineProperty. err: " + error); 6044514f5e3Sopenharmony_ci } 6054514f5e3Sopenharmony_ci} 6064514f5e3Sopenharmony_ci 6074514f5e3Sopenharmony_cifunction testNormInherit() { 6084514f5e3Sopenharmony_ci print("Start testNormInherit"); 6094514f5e3Sopenharmony_ci try { 6104514f5e3Sopenharmony_ci class NormalClass extends SimpleStringSendable { 6114514f5e3Sopenharmony_ci constructor() { 6124514f5e3Sopenharmony_ci super() 6134514f5e3Sopenharmony_ci } 6144514f5e3Sopenharmony_ci } 6154514f5e3Sopenharmony_ci print("Success to define normal class inherit from sendable class") 6164514f5e3Sopenharmony_ci } catch (error) { 6174514f5e3Sopenharmony_ci print("Fail to define normal class inherit from sendable class, err: " + error) 6184514f5e3Sopenharmony_ci } 6194514f5e3Sopenharmony_ci} 6204514f5e3Sopenharmony_ci 6214514f5e3Sopenharmony_cifunction testICCheckingForUpdateInstanceProps(testObj: SubClass) { 6224514f5e3Sopenharmony_ci let loopIndex: number = 0; 6234514f5e3Sopenharmony_ci try { 6244514f5e3Sopenharmony_ci for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 6254514f5e3Sopenharmony_ci testObj.subClassPropString = loopIndex < 1000 ? "hello" : 1; 6264514f5e3Sopenharmony_ci } 6274514f5e3Sopenharmony_ci print("[IC] Success update subClassPropString with mismatch type") 6284514f5e3Sopenharmony_ci } catch (error) { 6294514f5e3Sopenharmony_ci print("[IC] Fail to update subClassPropString with mismatch type. err: " + error + ", loopIndex: " + loopIndex) 6304514f5e3Sopenharmony_ci } 6314514f5e3Sopenharmony_ci 6324514f5e3Sopenharmony_ci try { 6334514f5e3Sopenharmony_ci for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 6344514f5e3Sopenharmony_ci testObj.propNumber = loopIndex < 1000 ? 100 : "Hi"; 6354514f5e3Sopenharmony_ci } 6364514f5e3Sopenharmony_ci print("[IC] Success update propNumber with mismatch type") 6374514f5e3Sopenharmony_ci } catch (error) { 6384514f5e3Sopenharmony_ci print("[IC] Fail to update propNumber with mismatch type. err: " + error + ", loopIndex: " + loopIndex); 6394514f5e3Sopenharmony_ci } 6404514f5e3Sopenharmony_ci 6414514f5e3Sopenharmony_ci try { 6424514f5e3Sopenharmony_ci for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 6434514f5e3Sopenharmony_ci testObj.subClassPropString = loopIndex < 1000 ? 33 : "Hi"; 6444514f5e3Sopenharmony_ci } 6454514f5e3Sopenharmony_ci print("[IC] Success update subClassPropString with mismatch type") 6464514f5e3Sopenharmony_ci } catch (error) { 6474514f5e3Sopenharmony_ci print("[IC] Fail to update subClassPropString with mismatch type. err: " + error + ", loopIndex: " + loopIndex); 6484514f5e3Sopenharmony_ci } 6494514f5e3Sopenharmony_ci 6504514f5e3Sopenharmony_ci try { 6514514f5e3Sopenharmony_ci let simpleSendable = new SimpleStringSendable(); 6524514f5e3Sopenharmony_ci for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 6534514f5e3Sopenharmony_ci testObj.subClassPropSendable = loopIndex < 1000 ? simpleSendable : 1; 6544514f5e3Sopenharmony_ci } 6554514f5e3Sopenharmony_ci print("[IC] Success to update subClassPropSendable with mismatch type."); 6564514f5e3Sopenharmony_ci } catch (error) { 6574514f5e3Sopenharmony_ci print("[IC] Fail to update subClassPropSendable with mismatch type. err: " + error + ", loopIndex: " + loopIndex); 6584514f5e3Sopenharmony_ci } 6594514f5e3Sopenharmony_ci 6604514f5e3Sopenharmony_ci try { 6614514f5e3Sopenharmony_ci for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 6624514f5e3Sopenharmony_ci SubClass.staticSubClassPropString = loopIndex < 1000 ? "modify static" : 1; 6634514f5e3Sopenharmony_ci } 6644514f5e3Sopenharmony_ci print("[IC] Success to modify constructor's property with mismatch type."); 6654514f5e3Sopenharmony_ci } catch (error) { 6664514f5e3Sopenharmony_ci print("[IC] Fail to modify constructor's property with mismatch type. err: " + error + ", loopIndex: " + loopIndex); 6674514f5e3Sopenharmony_ci } 6684514f5e3Sopenharmony_ci} 6694514f5e3Sopenharmony_ci 6704514f5e3Sopenharmony_cifunction testHotFunction(testObj: SubClass, loopIndex: number) { 6714514f5e3Sopenharmony_ci testObj.accessorPrivatePropString = loopIndex < 1000 ? "123" : 1; 6724514f5e3Sopenharmony_ci} 6734514f5e3Sopenharmony_ci 6744514f5e3Sopenharmony_cifunction testHotFunctionConvertWithAccessor(testObj: SubClass, loopIndex: number) { 6754514f5e3Sopenharmony_ci let array = new Array<number>(); 6764514f5e3Sopenharmony_ci array.push(loopIndex); 6774514f5e3Sopenharmony_ci testObj.accessorNumberToString = loopIndex; 6784514f5e3Sopenharmony_ci testObj.accessorGenerateSendable = array; 6794514f5e3Sopenharmony_ci} 6804514f5e3Sopenharmony_ci 6814514f5e3Sopenharmony_cifunction testICCheckingUpdateInstanceAccessor(testObj: SubClass) { 6824514f5e3Sopenharmony_ci let loopIndex: number = 0; 6834514f5e3Sopenharmony_ci try { 6844514f5e3Sopenharmony_ci for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 6854514f5e3Sopenharmony_ci testHotFunction(testObj, loopIndex); 6864514f5e3Sopenharmony_ci } 6874514f5e3Sopenharmony_ci print("[IC] Success set prop through accessor with matched type"); 6884514f5e3Sopenharmony_ci } catch (error) { 6894514f5e3Sopenharmony_ci print("[IC] Fail to set prop through accessor with matched type. err: " + error); 6904514f5e3Sopenharmony_ci } 6914514f5e3Sopenharmony_ci} 6924514f5e3Sopenharmony_ci 6934514f5e3Sopenharmony_cifunction testICCheckingConvertWithAccessor(testObj: SubClass) { 6944514f5e3Sopenharmony_ci let loopIndex: number = 0; 6954514f5e3Sopenharmony_ci try { 6964514f5e3Sopenharmony_ci for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 6974514f5e3Sopenharmony_ci testHotFunctionConvertWithAccessor(testObj, loopIndex); 6984514f5e3Sopenharmony_ci } 6994514f5e3Sopenharmony_ci print("[IC] Success set prop through accessor with matched type"); 7004514f5e3Sopenharmony_ci } catch (error) { 7014514f5e3Sopenharmony_ci print("[IC] Fail to set prop through accessor with matched type. err: " + error); 7024514f5e3Sopenharmony_ci } 7034514f5e3Sopenharmony_ci} 7044514f5e3Sopenharmony_ci 7054514f5e3Sopenharmony_cifunction testICChecking(testObj: SubClass) 7064514f5e3Sopenharmony_ci{ 7074514f5e3Sopenharmony_ci print("Start testICChecking"); 7084514f5e3Sopenharmony_ci testICCheckingForUpdateInstanceProps(testObj); 7094514f5e3Sopenharmony_ci testICCheckingUpdateInstanceAccessor(testObj); 7104514f5e3Sopenharmony_ci testICCheckingConvertWithAccessor(testObj); 7114514f5e3Sopenharmony_ci} 7124514f5e3Sopenharmony_ci 7134514f5e3Sopenharmony_cifunction testSetMismatchedType(testObj: SubClass) 7144514f5e3Sopenharmony_ci{ 7154514f5e3Sopenharmony_ci print("Start testSetMismatchedType"); 7164514f5e3Sopenharmony_ci try { 7174514f5e3Sopenharmony_ci testObj.propStringOrUndefined = 11; 7184514f5e3Sopenharmony_ci print("Success update propStringOrUndefined to number with stobjbyname"); 7194514f5e3Sopenharmony_ci } catch (error) { 7204514f5e3Sopenharmony_ci print("Fail to update propStringOrUndefined to number with stobjbyname. err: " + error); 7214514f5e3Sopenharmony_ci } 7224514f5e3Sopenharmony_ci 7234514f5e3Sopenharmony_ci try { 7244514f5e3Sopenharmony_ci testObj.propNumberOrUndefined = "l'm string"; 7254514f5e3Sopenharmony_ci print("Success update propNumberOrUndefined to string with stobjbyname"); 7264514f5e3Sopenharmony_ci } catch (error) { 7274514f5e3Sopenharmony_ci print("Fail to update propNumberOrUndefined to string with stobjbyname. err: " + error); 7284514f5e3Sopenharmony_ci } 7294514f5e3Sopenharmony_ci 7304514f5e3Sopenharmony_ci try { 7314514f5e3Sopenharmony_ci testObj.propBoolOrUndefined = 11; 7324514f5e3Sopenharmony_ci print("Success update propBoolOrUndefined to number with stobjbyname"); 7334514f5e3Sopenharmony_ci } catch (error) { 7344514f5e3Sopenharmony_ci print("Fail to update propBoolOrUndefined to number with stobjbyname. err: " + error); 7354514f5e3Sopenharmony_ci } 7364514f5e3Sopenharmony_ci 7374514f5e3Sopenharmony_ci try { 7384514f5e3Sopenharmony_ci testObj.propBigIntOrUndefined = "l'm string"; 7394514f5e3Sopenharmony_ci print("Success update propBigIntOrUndefined to string with stobjbyname"); 7404514f5e3Sopenharmony_ci } catch (error) { 7414514f5e3Sopenharmony_ci print("Fail to update propBigIntOrUndefined to string with stobjbyname. err: " + error); 7424514f5e3Sopenharmony_ci } 7434514f5e3Sopenharmony_ci 7444514f5e3Sopenharmony_ci try { 7454514f5e3Sopenharmony_ci testObj.propSenableOrUndefined = 11; 7464514f5e3Sopenharmony_ci print("Success update propSenableOrUndefined to number with stobjbyname"); 7474514f5e3Sopenharmony_ci } catch (error) { 7484514f5e3Sopenharmony_ci print("Fail to update propSenableOrUndefined to number with stobjbyname. err: " + error); 7494514f5e3Sopenharmony_ci } 7504514f5e3Sopenharmony_ci} 7514514f5e3Sopenharmony_ci 7524514f5e3Sopenharmony_cifunction testSharedObjectFreeze(testObj: SubClass) 7534514f5e3Sopenharmony_ci{ 7544514f5e3Sopenharmony_ci print("Start testSharedObjectFreeze"); 7554514f5e3Sopenharmony_ci print("isFrozen: " + Object.isFrozen(testObj)); 7564514f5e3Sopenharmony_ci Object.freeze(testObj); 7574514f5e3Sopenharmony_ci print("isFrozen: " + Object.isFrozen(testObj)); 7584514f5e3Sopenharmony_ci try { 7594514f5e3Sopenharmony_ci testObj.subClassPropString = "I'm string"; 7604514f5e3Sopenharmony_ci } catch (error) { 7614514f5e3Sopenharmony_ci print("Fail to set properties after frozen. err: " + error); 7624514f5e3Sopenharmony_ci } 7634514f5e3Sopenharmony_ci} 7644514f5e3Sopenharmony_ci 7654514f5e3Sopenharmony_cifunction testSharedFunctionFreeze(testClass) 7664514f5e3Sopenharmony_ci{ 7674514f5e3Sopenharmony_ci print("Start testSharedFunctionFreeze"); 7684514f5e3Sopenharmony_ci print("isFrozen: " + Object.isFrozen(testClass)); 7694514f5e3Sopenharmony_ci Object.freeze(testClass); 7704514f5e3Sopenharmony_ci print("isFrozen: " + Object.isFrozen(testClass)); 7714514f5e3Sopenharmony_ci try { 7724514f5e3Sopenharmony_ci testClass.staticSubClassPropString = "I'm string"; 7734514f5e3Sopenharmony_ci } catch (error) { 7744514f5e3Sopenharmony_ci print("Fail to set properties after frozen. err: " + error); 7754514f5e3Sopenharmony_ci } 7764514f5e3Sopenharmony_ci} 7774514f5e3Sopenharmony_ci 7784514f5e3Sopenharmony_cilet b = new SubClass(); 7794514f5e3Sopenharmony_cilet c = new SubClass(); 7804514f5e3Sopenharmony_cib.subClassPropSendable = new SimpleStringSendable(); 7814514f5e3Sopenharmony_cib.propSenableOrNull = new SimpleStringSendable(); 7824514f5e3Sopenharmony_cib.propSenableOrUndefined = new SimpleStringSendable(); 7834514f5e3Sopenharmony_citestUpdate(b); 7844514f5e3Sopenharmony_citestDelete(b); 7854514f5e3Sopenharmony_citestExtend(b); 7864514f5e3Sopenharmony_citestObjectProtoFunc(c); 7874514f5e3Sopenharmony_citestUpdateWithType(b); 7884514f5e3Sopenharmony_citestKeywords(b); 7894514f5e3Sopenharmony_citestNormInherit(); 7904514f5e3Sopenharmony_citestICChecking(b); 7914514f5e3Sopenharmony_citestSetMismatchedType(b); 7924514f5e3Sopenharmony_citestSharedObjectFreeze(b); 7934514f5e3Sopenharmony_citestSharedFunctionFreeze(SubClass);