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