1/* 2 * Copyright (c) 2024 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:arraystablecheck1 18 * @tc.desc:test array stable or not 19 */ 20 21{ 22 let arr1 = new Array(1023); 23 let arr2 = new Array(1023); 24 print(ArkTools.isStableJsArray(arr1)); 25 print(ArkTools.isStableJsArray(arr2)); 26 print(ArkTools.isStableJsArray(arr2.__proto__)); 27} 28 29 30/* 31 * @tc.name:arraystablecheck2 32 * @tc.desc:test array stable or not 33 */ 34 35{ 36 let arr1 = new Array(1023); 37 let arr2 = new Array(1023); 38 arr1.__proto__ = arr2; 39 print(ArkTools.isStableJsArray(arr1)); 40 print(ArkTools.isStableJsArray(arr2)); 41} 42 43/* 44 * @tc.name:arraystablecheck3 45 * @tc.desc:test array stable or not 46 */ 47{ 48 let arr1 = new Array(1026); 49 let arr2 = new Array(1026); 50 print(ArkTools.isStableJsArray(arr1)); 51 print(ArkTools.isStableJsArray(arr2)); 52} 53 54/* 55 * @tc.name:arraystablecheck4 56 * @tc.desc:test array stable or not 57 */ 58{ 59 class MyArray extends Array { 60 61 }; 62 let arr1 = new MyArray(1023); 63 let arr2 = new MyArray(1023); 64 let arr3 = arr1.concat(arr2); 65 let arr4 = new Array(1023); 66 print(ArkTools.isStableJsArray(arr1)); 67 print(ArkTools.isStableJsArray(arr2)); 68 print(ArkTools.isStableJsArray(arr3)); 69 print(ArkTools.isStableJsArray(arr4)); 70} 71 72/* 73 * @tc.name:arraystablecheck5 74 * @tc.desc:test array stable or not 75 */ 76{ 77 class MyArray extends Array { 78 79 }; 80 let arr1 = new MyArray(); 81 let arr2 = new MyArray(); 82 let arr3 = arr1.concat(); 83 let arr4 = new Array(); 84 print(ArkTools.isStableJsArray(arr1)); 85 print(ArkTools.isStableJsArray(arr2)); 86 print(ArkTools.isStableJsArray(arr3)); 87 print(ArkTools.isStableJsArray(arr4)); 88} 89 90/* 91 * @tc.name:arraystablecheck6 92 * @tc.desc:test array stable or not 93 */ 94{ 95 class MyArray extends Array { 96 97 }; 98 let arr1 = new MyArray(1, 2, 3, 4, 5); 99 let arr2 = new MyArray(1, 2, 3, 4, 5); 100 let arr3 = arr1.concat(); 101 let arr4 = new Array(1, 2, 3, 4, 5); 102 print(ArkTools.isStableJsArray(arr1)); 103 print(ArkTools.isStableJsArray(arr2)); 104 print(ArkTools.isStableJsArray(arr3)); 105 print(ArkTools.isStableJsArray(arr4)); 106} 107 108/* 109 * @tc.name:arraystablecheck7 110 * @tc.desc:test array stable or not 111 */ 112{ 113 let arr1 = new Array(1023); 114 print(ArkTools.isStableJsArray(arr1)); 115 arr1.__proto__.fill(233, 0, 0); 116 print(ArkTools.isStableJsArray(arr1)); 117 arr1.__proto__.fill(); 118 print(ArkTools.isStableJsArray(arr1)); 119 arr1.__proto__.push(); 120 print(ArkTools.isStableJsArray(arr1)); 121 arr1.__proto__.unshift(); 122 print(ArkTools.isStableJsArray(arr1)); 123 arr1.__proto__.splice(); 124 print(ArkTools.isStableJsArray(arr1)); 125} 126 127/* 128 * @tc.name:arraystablecheck8 129 * @tc.desc:test array stable or not 130 */ 131{ 132 let arr1 = new Array(1023); 133 let arr2 = new Array(1023); 134 arr1.__proto__.push(1); 135 print(ArkTools.isStableJsArray(arr1.__proto__)); 136 print(ArkTools.isStableJsArray(arr1)); 137 print(ArkTools.isStableJsArray(arr2)); 138}