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:sharedmodule
18 * @tc.desc:test sharedmodule
19 * @tc.type: FUNC
20 * @tc.require: issue#I9BIE5
21 */
22
23// @ts-nocheck
24declare function print(str: any): string;
25
26import {Test1} from "./func"
27import {strA, strB, foo} from "./string"
28
29"shared module"
30class SendableClassA {
31    static staticField: string = strA;
32    constructor() {
33        "use sendable";
34    }
35
36    testZeroLevelContext() {
37        print(SendableClassA.staticField);
38    }
39
40    testOneLevelContext() {
41        let x: number = 0;
42        (()=>{
43            print("testOneLevelContext");
44            print(SendableClassA.staticField + strB);
45        })();
46    }
47    testImportFunction() {
48        let x: number = 0;
49        (()=>{
50            print("testImportFunction");
51            let tA = new Test1(strA);
52            print(tA.foo());
53        })();
54    }
55}
56
57let sObj = new SendableClassA;
58sObj.testZeroLevelContext();
59sObj.testOneLevelContext();
60sObj.testImportFunction();
61
62class SendableClassB extends SendableClassA {
63    classBStr:string;
64    constructor(classBStr:string) {
65        "use sendable";
66        super();
67        this.classBStr = classBStr;
68    }
69
70    testImportFunction() {
71        print("testImportFunction");
72        print(this.classBStr);
73    }
74}
75
76let sObjb = new SendableClassB("ClassB:");
77sObjb.testImportFunction()
78foo();
79