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 Float64Array, 18 Float32Array, 19 Int32Array, 20 Int16Array, 21 Int8Array, 22 Uint32Array, 23 Uint16Array, 24 Uint8Array, 25 Uint8ClampedArray 26].forEach(function (ctor) { 27 testTypeArraySet1(ctor) 28}); 29 30function testTypeArraySet1(ctor) { 31 const obj = new ctor(8); 32 obj.set(new ctor(6), 2); 33 print(obj); 34} 35 36var typedArray1 = new Int32Array([1,1,1,1,1,1,1,1]); 37var typedArrayIn1 = new Uint16Array([2, 2, 2]); 38typedArray1.set(typedArrayIn1, 2); 39print(typedArray1); 40 41var typedArray2 = new Int32Array([1,1,1,1,1,1,1,1]); 42typedArray2.set([2, 2, 2], 2); 43print(typedArray2); 44 45var typedArray3 = new Int32Array([1,1,1,1,1,1,1,1]); 46typedArray3.set([2, , 2], 2); 47print(typedArray3); 48 49var typedArray4 = new Int32Array([1,1,1,1,1,1,1,1]); 50typedArray4.set([2, undefined, 2], 2); 51print(typedArray4); 52