• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2023 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 */
15import {describe, it, expect} from "@ohos/hypium"
16
17export default function dynamicImport() {
18  describe("DynamicImportTest", async () => {
19    it('importHar', 0, async () => {
20      let lib = await import('har')
21      expect(lib.add(2, 3)).assertEqual(5)
22    })
23    it('importRelative', 0, async () => {
24      let lib = await import('./test')
25      expect(lib.add(2, 3)).assertEqual(5)
26      expect(lib.default).assertEqual('test')
27    })
28    it('importOhpm', 0, async () => {
29      let lib = await import('leap-year')
30      expect(lib.default(2000)).assertEqual(true)
31    })
32    it('importSystemInternal', 0, async () => {
33      let lib = await import('@ohos.hilog')
34      lib.default.info(0x0000, "testTag", 'dexter log: call ohos.hilog')
35    })
36    it('importSystemBuiltin', 0, async () => {
37      let lib = await import('@system.app')
38      lib.default.getInfo()
39    })
40    it('importAppNapi', 0, async () => {
41      let lib = await import('libentry.so')
42      expect(lib.default.add(2,3)).assertEqual(5)
43    })
44  })
45}