1/* 2 * Copyright (c) 2021-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 16function foo(a: int = 3, b: int = 5): int { 17 return a * 10 + b; 18} 19 20class C { 21 x: int; 22 y: int; 23 24 constructor (a: int = 3, b: int = 5) { 25 this.x = a; 26 this.y = b; 27 } 28} 29 30function main(): void { 31 32 let res = foo(5, 7); 33 assert (res == 57); 34 35 res = foo(7); 36 assert (res == 75); 37 38 res = foo(); 39 assert (res == 35); 40 41 let c0 = new C(); 42 assert (c0.x == 3 && c0.y == 5); 43 44 let c1 = new C(7); 45 assert (c1.x == 7 && c1.y == 5); 46 47 let c2 = new C(5, 7); 48 assert (c2.x == 5 && c2.y == 7); 49} 50