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 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 assert(arr1.length == 5) 35 assert(arr1[0] == 7) 36 assert(arr1[1] == "a") 37 assert(arr1[2] == true) 38 assert(arr1[3] == "b") 39 assert(arr1[4] == 1) 40 41 let arr2 = [...getStringArr()] 42 assert(arr2.length == 3) 43 assert(arr2[0] == 5) 44 assert(arr2[1] == true) 45 assert(arr2[2] == "A") 46 47 let getArr = (): [string, int] => { 48 return ["a", 10] 49 } 50 let arr3 = [...arr2, ...getArr(), "B"] 51 assert(arr3.length == 6) 52 assert(arr3[0] == 5) 53 assert(arr3[1] == true) 54 assert(arr3[2] == "A") 55 assert(arr3[3] == "a") 56 assert(arr3[4] == 10) 57 assert(arr3[5] == "B") 58 59} 60 61