1/* 2 * Copyright (c) 2023-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 16function main():void{ 17 assertEQ(foo2(), 5) 18 19 let bar = new Bar(); 20 assertEQ(bar.bar2(), 5) 21 22 assertEQ(goo1(), 15) 23 assertEQ(goo2(), 15) 24 assertEQ(goo2((a0:int):int=>{return 25;}), 25) 25 26 assertEQ(boo1(), 18) 27 assertEQ(boo2(1,2,3), 6) 28 29 assertEQ(doo1(), 8) 30 31 too1(); 32 too2(); 33 too3(); 34} 35 36function foo1(): int { 37 return 5; 38} 39 40function foo2(a : int = foo1() ): int { 41 return a; 42} 43 44class Bar { 45 bar1(): int { 46 return 5; 47 } 48 49 bar2(a : int = this.bar1() ): int { 50 return a; 51 } 52} 53 54function goo1(a : () => int = (): int => {return 15;}): int { 55 return a(); 56} 57 58function goo2(a:(a0:int) => int = (a0:int):int=>{return 15;} ): int { 59 return a(5); 60} 61 62function boo1(a0:int = boo1(1,2,3),a1:int = boo1(1,2,3),a2:int = boo1(1,2,3)):int{ 63 return a0+a1+a2; 64} 65 66function boo2(a0:int,a1:int,a2:int = boo2(1,2,3)):int{ 67 return a0+a1+a2; 68} 69 70function doo1(a0:int = 5+3):int{ 71 return a0; 72} 73 74function too1(a0:int = 5 /*comment*/):int{ 75 return a0; 76} 77 78function too2(a0:int = 5 //comment 79):int{ 80 return a0; 81} 82 83function too3(a0:int = 5 /*comment1*/, a1:int = 5 //comment2 84):int{ 85 return a0; 86} 87