1/* 2 * Copyright (c) 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// Test scenarios with multiple lambda parameters 17class B { 18 // Mix required and optional parameters (non-lambda first) 19 bar(requiredFn: () => void, optionalNum?: number, optionalFn?: () => string) { 20 requiredFn(); 21 assertEQ(optionalNum, 42); 22 if (optionalFn) assertEQ(optionalFn(), "optional"); 23 } 24 25 // Multiple optional lambda parameters 26 baz(a: number, f1?: () => string, f2?: () => number) { 27 assertEQ(a, 10); 28 if (f1) assertEQ(f1(), "first"); 29 if (f2) assertEQ(f2(), 42); 30 } 31} 32 33function main() { 34 const b = new B(); 35 36 b.bar(() => { }, 42, () => "optional"); 37 38 b.bar(() => { }, 42) { 39 return "optional"; 40 }; 41 42 b.baz(10, () => "first", () => 42); 43 44 b.baz(10, () => "first"){ 45 return 42 46 } 47}