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 17function main() { 18 let x1: [int, string] = [1, "a"] 19 let y1: [int, string] = [...x1] 20 assert(y1.length == 2) 21 assert(y1[0] == 1 && y1[1] == "a") 22 23 let x2: [int, boolean] = [2, true] 24 let y2: [string, int, boolean, int, boolean, string] = ["a", ...x2, ...x2, "b"] 25 assert(y2.length == 6) 26 assert(y2[0] == "a" && y2[1] == 2 && y2[2] == true) 27 assert(y2[3] == 2 && y2[4] == true && y2[5] == "b") 28 29 let x3: [int, boolean] = [10, false] 30 let x4: [string] = ["e"] 31 let x5: [string, boolean] = ["f", true] 32 let y3: [int, boolean, string, string, int, string, boolean] = [...x3, "g", ...x4, 20, ...x5] 33 assert(y3.length == 7) 34 assert(y3[0] == 10 && y3[1] == false && y3[2] == "g") 35 assert(y3[3] == "e" && y3[4] == 20 && y3[5] == "f" && y3[6] == true) 36} 37 38