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/* 17 * @tc.name:asyncUseLazyImport 18 * @tc.desc:test asyncUseLazyImport 19 * @tc.type: FUNC 20 * @tc.require: issue#IB2HNC 21 */ 22 23// @ts-nocheck 24import lazy { TestLazy } from './lazyExport'; 25export class Test { 26 async start() { 27 try { 28 this.log(` Test start`) 29 let a = await this.mapAsync([1, 2], async (t) => { 30 await this.bindRawData(t) 31 }) 32 this.log(` Test end ${new Error().stack}`) 33 throw new Error(); 34 } catch (e) { 35 this.log(` Test catch`) 36 } finally { 37 this.log(` Test finally`) 38 } 39 } 40 private async bindRawData(t: number) { 41 await this.mapAsync([1, 2], async (k, b) => { 42 this.onBindRawData(t, k) 43 }) 44 await this.mapAsync([4, 5], async (k, b) => { 45 this.onBindRawData(t, k) 46 }) 47 await this.mapAsync([7, 8], async (k, b) => { 48 this.onBindRawData(t, k) 49 }) 50 } 51 async mapAsync<T, U>(array: T[], map: (t: T, index: number) => Promise<U>) { 52 return await Promise.all(array.map(map)) 53 } 54 private async onBindRawData(t: number, k: number) { 55 this.log(` onBindRawData start ${t} ${k}`) 56 await this.isSelf() 57 this.log(` onBindRawData end ${t} ${k}`) 58 } 59 private async isSelf(): Promise<boolean> { 60 return "1" == "1" 61 } 62 log(msg: string) { 63 TestLazy 64 print(msg) 65 } 66}