1/* 2 * Copyright (c) 2024-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 16 17class A { 18 foo () : int[] { 19 return [7] 20 } 21} 22 23function foo() : int[]{ 24 return [1, 2] 25} 26 27function getStringArr() { 28 return ["A"] 29} 30 31function main() { 32 let a = new A() 33 let arr1:Int[] = [...a.foo(), ...foo()] 34 assertEQ(arr1.length, 3) 35 assertEQ(arr1[0], 7) 36 assertEQ(arr1[1], 1) 37 assertEQ(arr1[2], 2) 38 39 let arr2 = [...getStringArr()] 40 assertEQ(arr2.length, 1) 41 assertEQ(arr2[0], "A") 42 43 let getArr = (): string[] => { 44 return ["a", "b"] 45 } 46 let arr3 : string[] = [...arr2, ...getArr(), "B"] 47 assertEQ(arr3.length, 4) 48 assertEQ(arr3[0], "A") 49 assertEQ(arr3[1], "a") 50 assertEQ(arr3[2], "b") 51 assertEQ(arr3[3], "B") 52 53} 54 55