1/* 2 * Copyright (c) 2023-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 16let lambda1: () => void = (): void => { 17 let obj: Object | null = null; 18} 19 20let lambda2: (value: int) => Int = (value: int): Int => { 21 let a = 42; 22 let num: Int = new Int(a + value); 23 return num; 24} 25 26function main() { 27 let local_int = 100; 28 lambda1(); 29 30 assert lambda2(local_int) == 142; 31 local_int = 0; 32 assert lambda2(local_int) == 42; 33 34 const const_int = 100; 35 const const_local_int = local_int; 36 let lambda3: (b: byte) => int = (b: byte): int => { 37 let num: Int = new Int(const_int + const_local_int); 38 let num_int: int = num; 39 let result: int = num_int + b + lambda2(const_local_int); 40 return result; 41 } 42 assert lambda3(42 as byte) == 100 + 42 + 42; 43} 44