1/* 2 * Copyright (c) 2021 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:arraywith 18 * @tc.desc:test Array.with 19 * @tc.type: FUNC 20 * @tc.require: issueI5NO8G 21 */ 22 23const arr0 = [0, , undefined, 1]; 24print(arr0.indexOf(undefined)); 25const arr1 = arr0.with(0, 0); 26print(arr0.indexOf(undefined)); 27print(arr1.indexOf(undefined)); 28 29const arr2 = new Array(1025); 30for(let i = 0; i < 1025; i = i + 1) 31 arr2[i] = i; 32const arr3 = arr2.with(0, 0); 33 34var arr4 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; 35var arr5 = new Array(); 36for (let i = 0; i < 10; i++) arr5[i] = i; 37 38var result1 = arr4.with(4, 100); 39print(result1); 40var result2 = arr5.with(4, 100); 41print(result2); 42