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:dynamicimportsharedmodule 18 * @tc.desc:test dynamicimportsharedmodule 19 * @tc.type: FUNC 20 * @tc.require: issue#I9IFCJ 21 */ 22 23// @ts-nocheck 24declare function print(str: any): string; 25import {strA, strB} from "./string" 26 27class SendableClassA { 28 static staticField: string = strA; 29 constructor() { 30 "use sendable"; 31 } 32 33 testZeroLevelContext() { 34 print(SendableClassA.staticField); 35 } 36 37 testOneLevelContext() { 38 let x: number = 0; 39 (()=>{ 40 print("testOneLevelContext"); 41 print(SendableClassA.staticField + strB); 42 })(); 43 } 44 testImportFunction() { 45 let x: number = 0; 46 (()=>{ 47 print("testImportFunction"); 48 })(); 49 } 50} 51 52let sObj = new SendableClassA; 53sObj.testZeroLevelContext(); 54sObj.testOneLevelContext(); 55sObj.testImportFunction(); 56 57import("./shared").then(m=>{ 58 const instance = m.SingleCase.getInstance(); 59 for(let i = 0; i < 5; i++) { 60 print(instance.incrementCount()); 61 }}).catch(e=>{print(e);})