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:sharedcheck 18 * @tc.desc:test sharedcheck 19 * @tc.type: FUNC 20 * @tc.require: issueI8QUU0 21 */ 22 23// @ts-nocheck 24/* 25 * Copyright (c) 2023 Huawei Device Co., Ltd. 26 * Licensed under the Apache License, Version 2.0 (the "License"); 27 * you may not use this file except in compliance with the License. 28 * You may obtain a copy of the License at 29 * 30 * http://www.apache.org/licenses/LICENSE-2.0 31 * 32 * Unless required by applicable law or agreed to in writing, software 33 * distributed under the License is distributed on an "AS IS" BASIS, 34 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 35 * See the License for the specific language governing permissions and 36 * limitations under the License. 37 */ 38 39/* 40 * @tc.name:sharedcheck 41 * @tc.desc:test sharedcheck 42 * @tc.type: FUNC 43 * @tc.require: issueI8QUU0 44 */ 45 46// @ts-nocheck 47declare function print(str: any): string; 48 49class SimpleStringSendable { 50 propString: string = "I'm simple sendable's propString"; 51 constructor() { 52 "use sendable" 53 print(this.propString) 54 } 55} 56 57class SimpleNumberSendable { 58 propNumber: number = 2023; 59 constructor() { 60 "use sendable" 61 print("I'm constructor for SimpleNumberSendable") 62 } 63} 64 65class SimpleSendableClass { 66 propNumber: number = 2023; 67 constructor() { 68 "use sendable" 69 } 70} 71 72class SuperClass { 73 propString: string = "I'm propString" 74 propNumber: number = 5 75 propBool: boolean = false 76 propBigInt1: bigint = BigInt(12345678910) 77 propBigInt2: bigint = BigInt(987654321) 78 propStringOrNull: string | null = "I'm propStringOrNull" 79 propStringOrUndefined: string | undefined = "I'm propStringOrUndefined" 80 propNumberOrNull: number | null = 1 81 propNumberOrUndefined: number | undefined = 1 82 propBoolOrNull: boolean | null = true 83 propBoolOrUndefined: boolean | undefined = true 84 propBigIntOrNull: bigint | null = BigInt(12345678910) 85 propBigIntOrUndefined: bigint | undefined = BigInt(12345678910) 86 propSenableOrNull: SimpleStringSendable | null 87 propSenableOrUndefined: SimpleStringSendable | undefined 88 static staticPropString: string = "I'm staticPropString"; 89 publicPropString: string = "I'm privatePropString"; 90 propNumberToString: string = "I'm prop NumberToString"; 91 propSendableObj: SimpleSendableClass | null; 92 93 get accessorPrivatePropString() { 94 return this.publicPropString; 95 } 96 97 set accessorPrivatePropString(prop: string) { 98 this.publicPropString = prop; 99 } 100 101 set accessorNumberToString(prop: string) { 102 this.propNumberToString = String(prop); 103 } 104 105 set accessorGenerateSendable(prop: Array<number>) { 106 let obj = new SimpleSendableClass(); 107 obj.propNumber = prop.pop(); 108 this.propSendableObj = obj; 109 } 110 111 constructor() { 112 "use sendable" 113 print(this.propString) 114 } 115} 116 117class SubClass extends SuperClass { 118 static staticSubClassPropString: string = "I'm staticSubClassPropString"; 119 static staticFunc() { 120 print("Hi static func"); 121 } 122 static staticFunc1() { 123 print("Hi static func1"); 124 } 125 126 func() { 127 print("Hi func"); 128 this.publicFunc(); 129 } 130 131 publicFunc() { 132 print("Hi public func"); 133 } 134 135 subClassPropString: string = "I'm subClassPropString" 136 subClassPropSendable: SimpleStringSendable 137 constructor() { 138 "use sendable" 139 super() 140 } 141} 142 143function testDelete(testObj: SubClass) { 144 print("Start testDelete"); 145 try { 146 delete testObj.propNumber; 147 print("Success delete propNumber") 148 } catch (error) { 149 print("Fail to delete propNumber. err: " + error) 150 } 151} 152 153function testExtend(testObj: SubClass) { 154 print("Start testExtend"); 155 try { 156 Object.defineProperty(testObj, "tmpProp", {value: 321, writable: true }); 157 print("Success to extend prop with defineProperty") 158 } catch (error) { 159 print("Fail to extend prop with defineProperty. err: " + error); 160 } 161 162 try { 163 Object.defineProperty(testObj, "prop1", { writable: true }); 164 print("Success extend prop1 with defineProperty") 165 } catch (error) { 166 print("Fail to extend prop1 with defineProperty. err: " + error) 167 } 168 169 try { 170 Object.defineProperties(testObj, { prop2: { writable: true } }); 171 print("Success extend prop2 with defineProperties") 172 } catch (error) { 173 print("Fail to extend prop2 with defineProperties. err: " + error) 174 } 175 176 try { 177 testObj.prop3 = {}; 178 print("Success extend prop3 with stobjbyname") 179 } catch (error) { 180 print("Fail to extend prop3 with stobjbyname. err: " + error) 181 } 182} 183 184function testUpdateInstanceFunction(testObj: SubClass) { 185 print("Start testUpdateInstanceFunction"); 186 try { 187 testObj.func = function () { } 188 print("Success replace instance's func"); 189 } catch (error) { 190 print("Fail to replace instance's func. err: " + error); 191 } 192} 193 194function testUpdatePrototype(testObj: SubClass) { 195 print("Start testUpdatePrototype"); 196 try { 197 SuperClass.prototype.staticSubClassPropString = 1; 198 print("Success update prototype") 199 } catch (error) { 200 print("Fail to update prototype. err: " + error) 201 } 202 203 try { 204 SubClass.prototype.tmpProp = 123; 205 print("Success to extend prop to constructor's prototype."); 206 } catch (error) { 207 print("Fail to extend prop to constructor's prototype. err: " + error); 208 } 209 210 let superClass = new SuperClass() 211 try { 212 testObj.__proto__.constructor = superClass.__proto__.constructor; 213 print("Success to change constructor of instance's prototype."); 214 } catch (error) { 215 print("Fail to change constructor of instance's prototype. err: " + error); 216 } 217 218 try { 219 testObj.__proto__ = superClass.__proto__; 220 print("Success to replace instance's prototype."); 221 } catch (error) { 222 print("Fail to replace instance's prototype. err: " + error); 223 } 224 225 try { 226 Object.defineProperty(testObj.__proto__, "abc", { value: 123 }); 227 print("Success to extend instance's prototype."); 228 } catch (error) { 229 print("Fail to extend instance's prototype. err: " + error); 230 } 231} 232 233function testUpdateInstancePropsToNull(testObj: SubClass) { 234 print("Start testUpdateInstancePropsToNull"); 235 try { 236 testObj.propString = null 237 print("Success update propString to null with stobjbyname") 238 } catch (error) { 239 print("Fail to update propString to null with stobjbyname. err: " + error) 240 } 241 242 try { 243 testObj.subClassPropSendable = null 244 print("Success update subClassPropSendable to null with stobjbyname") 245 } catch (error) { 246 print("Fail to update subClassPropSendable to null with stobjbyname. err: " + error) 247 } 248 249 try { 250 testObj.propNumber = null 251 print("Success update propNumber to null with stobjbyname") 252 } catch (error) { 253 print("Fail to update propNumber to null with stobjbyname. err: " + error) 254 } 255 256 try { 257 testObj.propBool = null 258 print("Success update propBool to null with stobjbyname") 259 } catch (error) { 260 print("Fail to update propBool to null with stobjbyname. err: " + error) 261 } 262 263 try { 264 testObj.propBigInt1 = null 265 print("Success update propBigInt1 to null with stobjbyname") 266 } catch (error) { 267 print("Fail to update propBigInt1 to null with stobjbyname. err: " + error) 268 } 269 270 try { 271 testObj.propBigInt2 = null 272 print("Success update propBigInt2 to null with stobjbyname") 273 } catch (error) { 274 print("Fail to update propBigInt2 to null with stobjbyname. err: " + error) 275 } 276 277 try { 278 testObj.propStringOrNull = null 279 print("Success update propStringOrNull to null with stobjbyname") 280 } catch (error) { 281 print("Fail to update propStringOrNull to null with stobjbyname. err: " + error) 282 } 283 284 try { 285 testObj.propNumberOrNull = null 286 print("Success update propNumberOrNull to null with stobjbyname") 287 } catch (error) { 288 print("Fail to update propNumberOrNull to null with stobjbyname. err: " + error) 289 } 290 291 try { 292 testObj.propBoolOrNull = null 293 print("Success update propBoolOrNull to null with stobjbyname") 294 } catch (error) { 295 print("Fail to update propBoolOrNull to null with stobjbyname. err: " + error) 296 } 297 298 try { 299 testObj.propBigIntOrNull = null 300 print("Success update propBigIntOrNull to null with stobjbyname") 301 } catch (error) { 302 print("Fail to update propBigIntOrNull to null with stobjbyname. err: " + error) 303 } 304 305 try { 306 testObj.propSenableOrNull = null 307 print("Success update propSenableOrNull to null with stobjbyname") 308 } catch (error) { 309 print("Fail to update propSenableOrNull to null with stobjbyname. err: " + error) 310 } 311} 312 313function testUpdateInstancePropsToUndefined(testObj: SubClass) { 314 print("Start testUpdateInstancePropsToUndefined"); 315 try { 316 testObj.propString = undefined 317 print("Success update propString to undefined with stobjbyname") 318 } catch (error) { 319 print("Fail to update propString to undefined with stobjbyname. err: " + error) 320 } 321 322 try { 323 testObj.subClassPropSendable = undefined 324 print("Success update subClassPropSendable to undefined with stobjbyname") 325 } catch (error) { 326 print("Fail to update subClassPropSendable to undefined with stobjbyname. err: " + error) 327 } 328 329 try { 330 testObj.propNumber = undefined 331 print("Success update propNumber to undefined with stobjbyname") 332 } catch (error) { 333 print("Fail to update propNumber to undefined with stobjbyname. err: " + error) 334 } 335 336 try { 337 testObj.propBool = undefined 338 print("Success update propBool to undefined with stobjbyname") 339 } catch (error) { 340 print("Fail to update propBool to undefined with stobjbyname. err: " + error) 341 } 342 343 try { 344 testObj.propBigInt1 = undefined 345 print("Success update propBigInt1 to undefined with stobjbyname") 346 } catch (error) { 347 print("Fail to update propBigInt1 to undefined with stobjbyname. err: " + error) 348 } 349 350 try { 351 testObj.propBigInt2 = undefined 352 print("Success update propBigInt2 to undefined with stobjbyname") 353 } catch (error) { 354 print("Fail to update propBigInt2 to undefined with stobjbyname. err: " + error) 355 } 356 357 try { 358 testObj.propStringOrUndefined = undefined 359 print("Success update propStringOrUndefined to undefined with stobjbyname") 360 } catch (error) { 361 print("Fail to update propStringOrUndefined to undefined with stobjbyname. err: " + error) 362 } 363 364 try { 365 testObj.propNumberOrUndefined = undefined 366 print("Success update propNumberOrUndefined to undefined with stobjbyname") 367 } catch (error) { 368 print("Fail to update propNumberOrUndefined to undefined with stobjbyname. err: " + error) 369 } 370 371 try { 372 testObj.propBoolOrUndefined = undefined 373 print("Success update propBoolOrUndefined to undefined with stobjbyname") 374 } catch (error) { 375 print("Fail to update propBoolOrUndefined to undefined with stobjbyname. err: " + error) 376 } 377 378 try { 379 testObj.propBigIntOrUndefined = undefined 380 print("Success update propBigIntOrUndefined to undefined with stobjbyname") 381 } catch (error) { 382 print("Fail to update propBigIntOrUndefined to undefined with stobjbyname. err: " + error) 383 } 384 385 try { 386 testObj.propSenableOrUndefined = undefined 387 print("Success update propSenableOrUndefined to undefined with stobjbyname") 388 } catch (error) { 389 print("Fail to update propSenableOrUndefined to undefined with stobjbyname. err: " + error) 390 } 391} 392 393function testUpdateInstanceProps(testObj: SubClass) { 394 testUpdateInstancePropsToNull(testObj); 395 testUpdateInstancePropsToUndefined(testObj); 396 try { 397 Object.defineProperties(testObj, { subClassPropString: { value: "hello", writable: true } }); 398 print("Success update subClassPropString with defineProperties") 399 } catch (error) { 400 print("Fail to update subClassPropString with defineProperties. err: " + error) 401 } 402 403 try { 404 Object.defineProperty(testObj, "propNumber", { value: 100, configurable: false }); 405 print("Success update propNumber with defineProperty") 406 } catch (error) { 407 print("Fail to update propNumber with defineProperty. err: " + error) 408 } 409 410 try { 411 testObj.subClassPropString = 33; 412 print("Success update subClassPropString with stobjbyname") 413 } catch (error) { 414 print("Fail to update subClassPropString with stobjbyname. err: " + error) 415 } 416} 417 418function testUpdateInstanceAccessor(testObj: SubClass) { 419 print("Start testUpdateInstanceAccessor"); 420 try { 421 Object.defineProperty(testObj, "accessorPrivatePropString", 422 { 423 get accessorPrivatePropString() { print("Replaced get accessor") }, 424 set accessorPrivatePropString(prop: string) { print("Replaced set accessor") } 425 }) 426 print("Success replace accessor"); 427 } catch (error) { 428 print("Fail to replace accessor. err: " + error); 429 } 430 431 try { 432 testObj.accessorPrivatePropString = "123" 433 print("Success set prop through accessor with matched type"); 434 } catch (error) { 435 print("Fail to set prop through accessor with matched type. err: " + error); 436 } 437 438 try { 439 testObj.accessorPrivatePropString = 123 440 print("Success set prop through accessor with mismatched type"); 441 } catch (error) { 442 print("Fail to set prop through accessor with mismatched type. err: " + error); 443 } 444} 445 446function testUpdateConstructor() { 447 print("Start testUpdateConstructor"); 448 try { 449 SubClass.staticFunc = function () { }; 450 print("Success to modify constructor's method."); 451 } catch (error) { 452 print("Fail to modify constructor's method. err: " + error); 453 } 454 455 try { 456 SubClass.staticSubClassPropString = "modify static"; 457 print("Success to modify property to constructor's property."); 458 } catch (error) { 459 print("Fail to modify property to constructor's property. err: " + error); 460 } 461} 462 463function testObjectProtoFunc(testObj: SubClass) { 464 print("Start testObjectProtoFunc"); 465 testObjectAssign(testObj); 466 testObjectCreate(testObj); 467 testObjectSetPrototypeOf(testObj); 468 testObjectAttributesAndExtensible(testObj); 469} 470 471function testObjectCreate(testObj: SubClass) 472{ 473 print("Start testObjectCreate"); 474 try { 475 let sendableSimple: SimpleStringSendable = Object.create(SimpleStringSendable); 476 print("Success to call Object.create"); 477 } catch (error) { 478 print("Fail to call Object.create. err: " + error); 479 } 480} 481 482function testObjectSetPrototypeOf(testObj: SubClass) 483{ 484 print("Start testObjectSetPrototypeOf"); 485 try { 486 Object.setPrototypeOf(testObj, new Object) 487 print("Success to call Object.setPrototypeOf") 488 } catch (error) { 489 print("Fail to call Object.setPrototypeOf. err: " + error) 490 } 491} 492 493function testObjectAttributesAndExtensible(testObj: SubClass) 494{ 495 print("Start testObjectAttributesAndExtensible"); 496 try { 497 Object.defineProperty(testObj, "propNumber", { configurable: true }); 498 print("Success to update propNumber to configurable with defineProperty") 499 } catch (error) { 500 print("Fail to update propNumber to configurable with defineProperty. err: " + error) 501 } 502 print("isFrozen: " + Object.isFrozen(testObj)) 503 try { 504 Object.freeze(testObj); 505 print("Success to call Object.freeze") 506 } catch (error) { 507 print("Fail to call Object.freeze. err: " + error) 508 } 509 print("isFrozen: " + Object.isFrozen(testObj)) 510 print("isSealed: " + Object.isSealed(testObj)) 511 try { 512 Object.seal(testObj); 513 print("Success to call Object.seal in sealed state") 514 } catch (error) { 515 print("Fail to call Object.seal in sealed state. err: " + error) 516 } 517 print("isExtensible: " + Object.isExtensible(testObj)) 518 try { 519 Object.preventExtensions(testObj); 520 print("Success to call Object.preventExtensions in preventExtensions state.") 521 } catch (error) { 522 print("Fail to to call Object.preventExtensions in preventExtensions state. err: " + error) 523 } 524} 525 526function testObjectAssign(testObj: SubClass) 527{ 528 print("Start testObjectAssign"); 529 try { 530 Object.assign(testObj, new Object({ a: 1, b: "abc" })); 531 print("Success to call Object.assign to extend target"); 532 } catch (error) { 533 print("Fail to call Object.assign to extend target. err: " + error); 534 } 535 536 try { 537 Object.assign(testObj, new Object({ propString: 0 })); 538 print("Success to call Object.assign to update propString with mismatched type"); 539 } catch (error) { 540 print("Fail to call Object.assign to update propString with mismatched type. err: " + error); 541 } 542 543 try { 544 Object.assign(testObj, new Object({ propString: "abc" })); 545 print("Success to call Object.assign to update propString"); 546 } catch (error) { 547 print("Fail to call Object.assign to update propString. err: " + error); 548 } 549} 550 551function testKeywords(testObj: SubClass) 552{ 553 print("Start testKeywords"); 554 print("typeof sendable object: " + (typeof testObj)) 555 print("typeof sendable function: " + (typeof testObj.func)) 556 print("sendable instanceof Object: " + (testObj instanceof Object)) 557 print("sendable instanceof SubClass: " + (testObj instanceof SubClass)) 558 print("sendable instanceof SuperClass: " + (testObj instanceof SuperClass)) 559} 560 561function testUpdate(testObj: SubClass) { 562 testUpdateInstanceProps(testObj); 563 testUpdateInstanceAccessor(testObj); 564 testUpdateInstanceFunction(testObj); 565 testUpdatePrototype(testObj); 566 testUpdateConstructor(); 567} 568 569function testUpdateWithType(testObj: SubClass) { 570 print("Start testUpdateWithType"); 571 try { 572 testObj.propString = 1; 573 print("Success update string to int with stobjbynamme.") 574 } catch (error) { 575 print("Fail to update string to int with stobjbynamme. err: " + error); 576 } 577 578 try { 579 testObj.propBigInt1 = 1; 580 print("Success update bigInt to int with stobjbynamme.") 581 } catch (error) { 582 print("Fail to update bigInt to int with stobjbynamme. err: " + error); 583 } 584 585 try { 586 testObj.propBigInt2 = BigInt(123456789); 587 print("Success update bigInt to bigInt with stobjbynamme.") 588 } catch (error) { 589 print("Fail to update bigInt to int with stobjbynamme. err: " + error); 590 } 591 592 try { 593 Object.defineProperty(testObj, "subClassPropSendable", { value: 123, writable: true }); 594 print("Success update subClassPropSendable to number with defineProperty.") 595 } catch (error) { 596 print("Fail to update subClassPropSendable to number with defineProperty. err: " + error); 597 } 598 599 try { 600 Object.defineProperty(testObj, "subClassPropSendable", { value: new SimpleNumberSendable(), writable: true }); 601 print("Success update subClassPropSendable to numberSendable with defineProperty.") 602 } catch (error) { 603 print("Fail to update subClassPropSendable to numberSendable with defineProperty. err: " + error); 604 } 605} 606 607function testNormInherit() { 608 print("Start testNormInherit"); 609 try { 610 class NormalClass extends SimpleStringSendable { 611 constructor() { 612 super() 613 } 614 } 615 print("Success to define normal class inherit from sendable class") 616 } catch (error) { 617 print("Fail to define normal class inherit from sendable class, err: " + error) 618 } 619} 620 621function testICCheckingForUpdateInstanceProps(testObj: SubClass) { 622 let loopIndex: number = 0; 623 try { 624 for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 625 testObj.subClassPropString = loopIndex < 1000 ? "hello" : 1; 626 } 627 print("[IC] Success update subClassPropString with mismatch type") 628 } catch (error) { 629 print("[IC] Fail to update subClassPropString with mismatch type. err: " + error + ", loopIndex: " + loopIndex) 630 } 631 632 try { 633 for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 634 testObj.propNumber = loopIndex < 1000 ? 100 : "Hi"; 635 } 636 print("[IC] Success update propNumber with mismatch type") 637 } catch (error) { 638 print("[IC] Fail to update propNumber with mismatch type. err: " + error + ", loopIndex: " + loopIndex); 639 } 640 641 try { 642 for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 643 testObj.subClassPropString = loopIndex < 1000 ? 33 : "Hi"; 644 } 645 print("[IC] Success update subClassPropString with mismatch type") 646 } catch (error) { 647 print("[IC] Fail to update subClassPropString with mismatch type. err: " + error + ", loopIndex: " + loopIndex); 648 } 649 650 try { 651 let simpleSendable = new SimpleStringSendable(); 652 for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 653 testObj.subClassPropSendable = loopIndex < 1000 ? simpleSendable : 1; 654 } 655 print("[IC] Success to update subClassPropSendable with mismatch type."); 656 } catch (error) { 657 print("[IC] Fail to update subClassPropSendable with mismatch type. err: " + error + ", loopIndex: " + loopIndex); 658 } 659 660 try { 661 for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 662 SubClass.staticSubClassPropString = loopIndex < 1000 ? "modify static" : 1; 663 } 664 print("[IC] Success to modify constructor's property with mismatch type."); 665 } catch (error) { 666 print("[IC] Fail to modify constructor's property with mismatch type. err: " + error + ", loopIndex: " + loopIndex); 667 } 668} 669 670function testHotFunction(testObj: SubClass, loopIndex: number) { 671 testObj.accessorPrivatePropString = loopIndex < 1000 ? "123" : 1; 672} 673 674function testHotFunctionConvertWithAccessor(testObj: SubClass, loopIndex: number) { 675 let array = new Array<number>(); 676 array.push(loopIndex); 677 testObj.accessorNumberToString = loopIndex; 678 testObj.accessorGenerateSendable = array; 679} 680 681function testICCheckingUpdateInstanceAccessor(testObj: SubClass) { 682 let loopIndex: number = 0; 683 try { 684 for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 685 testHotFunction(testObj, loopIndex); 686 } 687 print("[IC] Success set prop through accessor with matched type"); 688 } catch (error) { 689 print("[IC] Fail to set prop through accessor with matched type. err: " + error); 690 } 691} 692 693function testICCheckingConvertWithAccessor(testObj: SubClass) { 694 let loopIndex: number = 0; 695 try { 696 for (loopIndex = 0; loopIndex < 2000; loopIndex++) { 697 testHotFunctionConvertWithAccessor(testObj, loopIndex); 698 } 699 print("[IC] Success set prop through accessor with matched type"); 700 } catch (error) { 701 print("[IC] Fail to set prop through accessor with matched type. err: " + error); 702 } 703} 704 705function testICChecking(testObj: SubClass) 706{ 707 print("Start testICChecking"); 708 testICCheckingForUpdateInstanceProps(testObj); 709 testICCheckingUpdateInstanceAccessor(testObj); 710 testICCheckingConvertWithAccessor(testObj); 711} 712 713function testSetMismatchedType(testObj: SubClass) 714{ 715 print("Start testSetMismatchedType"); 716 try { 717 testObj.propStringOrUndefined = 11; 718 print("Success update propStringOrUndefined to number with stobjbyname"); 719 } catch (error) { 720 print("Fail to update propStringOrUndefined to number with stobjbyname. err: " + error); 721 } 722 723 try { 724 testObj.propNumberOrUndefined = "l'm string"; 725 print("Success update propNumberOrUndefined to string with stobjbyname"); 726 } catch (error) { 727 print("Fail to update propNumberOrUndefined to string with stobjbyname. err: " + error); 728 } 729 730 try { 731 testObj.propBoolOrUndefined = 11; 732 print("Success update propBoolOrUndefined to number with stobjbyname"); 733 } catch (error) { 734 print("Fail to update propBoolOrUndefined to number with stobjbyname. err: " + error); 735 } 736 737 try { 738 testObj.propBigIntOrUndefined = "l'm string"; 739 print("Success update propBigIntOrUndefined to string with stobjbyname"); 740 } catch (error) { 741 print("Fail to update propBigIntOrUndefined to string with stobjbyname. err: " + error); 742 } 743 744 try { 745 testObj.propSenableOrUndefined = 11; 746 print("Success update propSenableOrUndefined to number with stobjbyname"); 747 } catch (error) { 748 print("Fail to update propSenableOrUndefined to number with stobjbyname. err: " + error); 749 } 750} 751 752function testSharedObjectFreeze(testObj: SubClass) 753{ 754 print("Start testSharedObjectFreeze"); 755 print("isFrozen: " + Object.isFrozen(testObj)); 756 Object.freeze(testObj); 757 print("isFrozen: " + Object.isFrozen(testObj)); 758 try { 759 testObj.subClassPropString = "I'm string"; 760 } catch (error) { 761 print("Fail to set properties after frozen. err: " + error); 762 } 763} 764 765function testSharedFunctionFreeze(testClass) 766{ 767 print("Start testSharedFunctionFreeze"); 768 print("isFrozen: " + Object.isFrozen(testClass)); 769 Object.freeze(testClass); 770 print("isFrozen: " + Object.isFrozen(testClass)); 771 try { 772 testClass.staticSubClassPropString = "I'm string"; 773 } catch (error) { 774 print("Fail to set properties after frozen. err: " + error); 775 } 776} 777 778let b = new SubClass(); 779let c = new SubClass(); 780b.subClassPropSendable = new SimpleStringSendable(); 781b.propSenableOrNull = new SimpleStringSendable(); 782b.propSenableOrUndefined = new SimpleStringSendable(); 783testUpdate(b); 784testDelete(b); 785testExtend(b); 786testObjectProtoFunc(c); 787testUpdateWithType(b); 788testKeywords(b); 789testNormInherit(); 790testICChecking(b); 791testSetMismatchedType(b); 792testSharedObjectFreeze(b); 793testSharedFunctionFreeze(SubClass);