1/* 2 * Copyright (c) 2025 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 16class A{} 17class B extends A{} 18class C extends B{} 19 20let cnt = 0; 21 22function F() 23{ 24 let c = new C(); 25 c.x = 1; 26 27 let c2 = new C(); 28 c2.x = 1; 29 30 c.y = 1; 31 32 33 assert_equal(ArkTools.isStableHClass(c2), false); 34 c2.z = 1; 35 assert_equal(ArkTools.isStableHClass(c2), true); 36 37 for (let i = 1; i <= 1021; i++) { 38 c2[`x${i}`] = 1; 39 assert_equal(ArkTools.isStableHClass(c2), true); 40 } 41 42 c2['x1023'] = 1; 43 assert_equal(ArkTools.isStableHClass(c2), false); 44 45 46 A.prototype.o = 1; 47 assert_equal(ArkTools.isStableHClass(B.prototype), true); 48 for (let i = 1; i <= 2000; i++) { 49 B.prototype[`y${i}`] = 1; 50 } 51 assert_equal(ArkTools.isStableHClass(B.prototype), false); 52} 53 54F(); 55 56test_end();