• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 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 'use static'
16
17 import {foo, foo2, foo3, foo4, array_val, null_val, undefined_val} from "./interop_convert_import_js.js"
18
19 let a: number = foo.num as number
20 let a1: boolean = foo2.bool  as boolean
21 let a2: string = foo3.str  as string
22 let a3: bigint = foo4.big  as bigint
23
24test_helper.test(() => {
25return (array_val as Array).toString() === new Array(1, 2, 3).toString();// 扫描出 arkts-interop-js2s-convert-js-type - no pass
26}, "array_val as Array === [1, 2, 3]");
27
28// convert type - Array
29test_helper.test(() => {
30return (array_val as number[]).toString() === [1,2,3].toString();// 扫描出 arkts-interop-js2s-convert-js-type - no pass
31}, "array_val as Array === [1, 2, 3]");
32
33// convert type - null
34test_helper.test(() => {
35return null_val as null === null;// 扫描出 arkts-interop-js2s-convert-js-type - no pass
36}, "null_val as null === null");
37
38// convert type - undefined
39test_helper.test(() => {
40return undefined_val as undefined === undefined; // 扫描出 arkts-interop-js2s-convert-js-type - no pass
41}, "undefined_val as undefined === undefined");
42