• 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 let GeneratedImportVar_1 = ESValue.load('./interop_convert_import_js.js');
18let foo = GeneratedImportVar_1.getProperty('foo');
19let foo2 = GeneratedImportVar_1.getProperty('foo2');
20let foo3 = GeneratedImportVar_1.getProperty('foo3');
21let foo4 = GeneratedImportVar_1.getProperty('foo4');
22let array_val = GeneratedImportVar_1.getProperty('array_val');
23let null_val = GeneratedImportVar_1.getProperty('null_val');
24let undefined_val = GeneratedImportVar_1.getProperty('undefined_val');
25
26
27 let a: number = foo.getProperty("num").toNumber()
28 let a1: boolean = foo2.getProperty("bool").toBoolean()
29 let a2: string = foo3.getProperty("str").toString()
30 let a3: bigint = foo4.getProperty("big").toBigInt()
31
32test_helper.test(() => {
33return (array_val as Array).toString() === new Array(1.0, 2.0, 3.0).toString();// 扫描出 arkts-interop-js2s-convert-js-type - no pass
34}, "array_val as Array === [1, 2, 3]");
35
36// convert type - Array
37test_helper.test(() => {
38return (array_val as number[]).toString() === [1.0,2.0,3.0].toString();// 扫描出 arkts-interop-js2s-convert-js-type - no pass
39}, "array_val as Array === [1, 2, 3]");
40
41// convert type - null
42test_helper.test(() => {
43return null_val as null === null;// 扫描出 arkts-interop-js2s-convert-js-type - no pass
44}, "null_val as null === null");
45
46// convert type - undefined
47test_helper.test(() => {
48return undefined_val as undefined === undefined; // 扫描出 arkts-interop-js2s-convert-js-type - no pass
49}, "undefined_val as undefined === undefined");
50