• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (C) 2025 HiHope Open Source Organization.
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*/
15export async function sleep(time) {
16    return new Promise((resolve) => {
17        setTimeout(() => {
18            resolve(1);
19        }, time);
20    });
21};
22
23export async function JSasyncTest1() {
24    const num = 66;
25    return num;
26};
27
28export let JSasyncTest2 = async () => {
29    const num = 66;
30    return num;
31};
32
33export const JSasyncTest3 = async function () {
34    const num = 66;
35    return num;
36};
37
38export async function JSasyncTest4() {
39    throw new Error('For test');
40};
41
42export async function JSasyncTest5() {
43    throw new Error('For test');
44};
45
46export async function JSasyncTest6(param) {
47    throw new Error('For test');
48};
49
50export async function JSasyncTest7() {
51    const num = '66';
52    return num;
53};
54
55export async function JSasyncTest8(name) {
56    const num = '66';
57    return num;
58};
59
60export async function JSasyncTest9(name) {
61    const num = 66;
62    return num;
63};
64
65export async function JSasyncTest10(name) {
66    const num = true;
67    return num;
68};
69
70export async function JSasyncTest11(name) {
71    const num = 66n;
72    return num;
73};
74
75
76export async function JSasyncTest12(name) {
77    return {
78        age: 30
79    };
80};
81
82export async function JSasyncTest13(name) {
83    return {
84        age: 30
85    };
86};
87
88export async function JSasyncTest14(name) {
89    const arr = [65, 66, 67];
90    return arr;
91};
92
93export async function JSasyncTest15(name) {
94    return () => 'Hello World!';
95};
96
97export async function JSasyncTest16(name) {
98    throw new Error('For test');
99    return;
100};
101
102export async function JSasyncTest17(name) {
103    throw new Error('For test');
104    return null;
105};
106
107export async function JSasyncTest18(name) {
108    throw new Error('For test');
109    return undefined;
110};
111
112export async function JSasyncTest19(name) {
113    return new Error('For test');
114};
115
116
117class Person {
118    name = '';
119
120    constructor(n) {
121        this.name = n;
122    };
123};
124
125export async function JSasyncTest20(name) {
126    let p = new Person('John');
127    return p;
128};
129
130export async function JSasyncTest21() {
131    throw new Error('For test');
132};
133
134async function for22JSasyncTest() {
135    return 66;
136};
137
138export async function JSasyncTest22() {
139    const result = for22JSasyncTest();
140    return result;
141};
142
143async function for23JSasyncTest() {
144    return 66;
145};
146
147export async function JSasyncTest23() {
148    const result = await for23JSasyncTest();
149    return result;
150};
151
152export async function JSasyncTest24() {
153    let num = 0;
154    setTimeout(() => {
155        num = 66;
156    }, 1000);
157    while (num !== 66) {
158        await sleep(300);
159    }
160    return num;
161};
162
163export async function JSasyncTest25() {
164    let num = 0;
165    await new Promise((resolve, reject) => {
166        num = 66;
167        resolve();
168    });
169    return num;
170};
171
172
173class For26JSasyncTest {
174    name = '';
175    age = 0;
176
177    constructor(n, age) {
178        this.name = n;
179        this.age = age;
180    }
181
182    fullName() {
183        return this.name;
184    };
185
186    getAge() {
187        return this.age;
188    };
189}
190;
191export async function JSasyncTest26() {
192    let p = new For26JSasyncTest('John', 66);
193    let result = p.getAge();
194    return result;
195};