• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development 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 #include "napi_error_test.h"
16 const size_t ERROR_BUF_SIZE_MAX = 128;
17 // CreateError interface
TestCreateErrorTest1(JSVM_Env env,JSVM_CallbackInfo info)18 [[maybe_unused]] JSVM_Value TestCreateErrorTest1(JSVM_Env env, JSVM_CallbackInfo info)
19 {
20     size_t argc = 1;
21     JSVM_Value argv[1] = {nullptr};
22     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
23 
24     JSVM_Value errorCode = nullptr;
25     OH_JSVM_CreateStringUtf8(env, "0", JSVM_AUTO_LENGTH, &errorCode);
26 
27     JSVM_Value errorMsg = nullptr;
28     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
29 
30     JSVM_Value rstValue = nullptr;
31     JSVM_Status creatStatus = OH_JSVM_CreateError(env, errorCode, errorMsg, &rstValue);
32     if (creatStatus != JSVM_OK) {
33         OH_JSVM_ThrowError(env, nullptr, "TestCreateErrortest1: OH_JSVM_CreateError Failed");
34         return nullptr;
35     }
36 
37     bool result = true;
38     JSVM_Value value = nullptr;
39     OH_JSVM_GetBoolean(env, result, &value);
40     return value;
41 }
42 // return not null
TestCreateErrorTest2(JSVM_Env env,JSVM_CallbackInfo info)43 [[maybe_unused]] JSVM_Value TestCreateErrorTest2(JSVM_Env env, JSVM_CallbackInfo info)
44 {
45     size_t argc = 1;
46     JSVM_Value argv[1] = {nullptr};
47     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
48 
49     JSVM_Value errorCode = nullptr;
50     OH_JSVM_CreateStringUtf8(env, "-3", JSVM_AUTO_LENGTH, &errorCode);
51 
52     JSVM_Value errorMsg = nullptr;
53     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
54 
55     JSVM_Value rstValue = nullptr;
56     JSVM_Status creatStatus = OH_JSVM_CreateError(env, errorCode, errorMsg, &rstValue);
57     if (creatStatus != JSVM_OK) {
58         OH_JSVM_ThrowError(env, nullptr, "TestCreateErrortest2: OH_JSVM_CreateError Failed");
59         return nullptr;
60     }
61 
62     bool result = true;
63     JSVM_Value value = nullptr;
64     OH_JSVM_GetBoolean(env, result, &value);
65     return value;
66 }
67 // msg is null, return not null
TestCreateErrorTest3(JSVM_Env env,JSVM_CallbackInfo info)68 [[maybe_unused]] JSVM_Value TestCreateErrorTest3(JSVM_Env env, JSVM_CallbackInfo info)
69 {
70     size_t argc = 1;
71     JSVM_Value argv[1] = {nullptr};
72     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
73 
74     JSVM_Value errorCode = nullptr;
75     OH_JSVM_CreateStringUtf8(env, "3", JSVM_AUTO_LENGTH, &errorCode);
76 
77     JSVM_Value errorMsg = nullptr;
78     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
79 
80     JSVM_Value rstValue = nullptr;
81     JSVM_Status creatStatus = OH_JSVM_CreateError(env, errorCode, errorMsg, &rstValue);
82     if (creatStatus != JSVM_OK) {
83         printf("OH_JSVM_CreateError Failed");
84         OH_JSVM_ThrowError(env, nullptr, "TestCreateErrortest3: OH_JSVM_CreateError Failed");
85         return nullptr;
86     }
87 
88     bool result = true;
89     JSVM_Value value = nullptr;
90     OH_JSVM_GetBoolean(env, result, &value);
91     return value;
92 }
93 // code is “0”, msg is not null,result is nullptr
TestCreateErrorTest4(JSVM_Env env,JSVM_CallbackInfo info)94 [[maybe_unused]] JSVM_Value TestCreateErrorTest4(JSVM_Env env, JSVM_CallbackInfo info)
95 {
96     size_t argc = 1;
97     JSVM_Value argv[1] = {nullptr};
98     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
99 
100     JSVM_Value errorCode = nullptr;
101     OH_JSVM_CreateStringUtf8(env, "0", JSVM_AUTO_LENGTH, &errorCode);
102 
103     JSVM_Value errorMsg = nullptr;
104     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
105 
106     JSVM_Status creatStatus = OH_JSVM_CreateError(env, errorCode, errorMsg, nullptr);
107     if (creatStatus == JSVM_OK) {
108         printf("OH_JSVM_CreateError Failed");
109         OH_JSVM_ThrowError(env, nullptr, "TestCreateErrortest4: OH_JSVM_CreateError Failed");
110         return nullptr;
111     }
112 
113     bool result = true;
114     JSVM_Value value = nullptr;
115     OH_JSVM_GetBoolean(env, result, &value);
116     return value;
117 }
118 //code is string,msg is not null,result is not null
TestCreateErrorTest5(JSVM_Env env,JSVM_CallbackInfo info)119 [[maybe_unused]] JSVM_Value TestCreateErrorTest5(JSVM_Env env, JSVM_CallbackInfo info)
120 {
121     size_t argc = 1;
122     JSVM_Value argv[1] = {nullptr};
123     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
124 
125     JSVM_Value errorCode = nullptr;
126     OH_JSVM_CreateStringUtf8(env, "error code", JSVM_AUTO_LENGTH, &errorCode);
127 
128     JSVM_Value errorMsg = nullptr;
129     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
130 
131     JSVM_Value rstValue = nullptr;
132     JSVM_Status creatStatus = OH_JSVM_CreateError(env, errorCode, errorMsg, &rstValue);
133     if (creatStatus != JSVM_OK) {
134         printf("OH_JSVM_CreateError Failed");
135         OH_JSVM_ThrowError(env, nullptr, "TestCreateErrortest5: OH_JSVM_CreateError Failed");
136         return nullptr;
137     }
138 
139     bool result = true;
140     JSVM_Value value = nullptr;
141     OH_JSVM_GetBoolean(env, result, &value);
142     return value;
143 }
144 ///CreateTypeError interface
145 //code is “0”, msg is not null,result is not null
TestCreateTypeErrorTest1(JSVM_Env env,JSVM_CallbackInfo info)146 [[maybe_unused]] JSVM_Value TestCreateTypeErrorTest1(JSVM_Env env, JSVM_CallbackInfo info)
147 {
148     size_t argc = 1;
149     JSVM_Value argv[1] = {nullptr};
150     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
151 
152     JSVM_Value errorCode = nullptr;
153     OH_JSVM_CreateStringUtf8(env, "0", JSVM_AUTO_LENGTH, &errorCode);
154 
155     JSVM_Value errorMsg = nullptr;
156     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
157 
158     JSVM_Value rstValue = nullptr;
159     JSVM_Status creatStatus = OH_JSVM_CreateTypeError(env, errorCode, errorMsg, &rstValue);
160     if (creatStatus != JSVM_OK) {
161         printf("OH_JSVM_CreateTypeError Failed");
162         OH_JSVM_ThrowError(env, nullptr, "TestCreateTypeErrortest1: OH_JSVM_CreateTypeError Failed");
163         return nullptr;
164     }
165 
166     bool result = true;
167     JSVM_Value value = nullptr;
168     OH_JSVM_GetBoolean(env, result, &value);
169     return value;
170 }
171 // code为 -3,msg is not null,result is not null
TestCreateTypeErrorTest2(JSVM_Env env,JSVM_CallbackInfo info)172 [[maybe_unused]] JSVM_Value TestCreateTypeErrorTest2(JSVM_Env env, JSVM_CallbackInfo info)
173 {
174     size_t argc = 1;
175     JSVM_Value argv[1] = {nullptr};
176     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
177 
178     JSVM_Value errorCode = nullptr;
179     OH_JSVM_CreateStringUtf8(env, "-3", JSVM_AUTO_LENGTH, &errorCode);
180 
181     JSVM_Value errorMsg = nullptr;
182     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
183 
184     JSVM_Value rstValue = nullptr;
185     JSVM_Status creatStatus = OH_JSVM_CreateTypeError(env, errorCode, errorMsg, &rstValue);
186     if (creatStatus != JSVM_OK) {
187         printf("OH_JSVM_CreateTypeError Failed");
188         OH_JSVM_ThrowError(env, nullptr, "TestCreateTypeErrortest2: OH_JSVM_CreateTypeError Failed");
189         return nullptr;
190     }
191 
192     bool result = true;
193     JSVM_Value value = nullptr;
194     OH_JSVM_GetBoolean(env, result, &value);
195     return value;
196 }
197 // code is 3,msg is not null,result is not null
TestCreateTypeErrorTest3(JSVM_Env env,JSVM_CallbackInfo info)198 [[maybe_unused]] JSVM_Value TestCreateTypeErrorTest3(JSVM_Env env, JSVM_CallbackInfo info)
199 {
200     size_t argc = 1;
201     JSVM_Value argv[1] = {nullptr};
202     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
203 
204     JSVM_Value errorCode = nullptr;
205     OH_JSVM_CreateStringUtf8(env, "3", JSVM_AUTO_LENGTH, &errorCode);
206 
207     JSVM_Value errorMsg = nullptr;
208     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
209 
210     JSVM_Value rstValue = nullptr;
211     JSVM_Status creatStatus = OH_JSVM_CreateTypeError(env, errorCode, errorMsg, &rstValue);
212     if (creatStatus != JSVM_OK) {
213         printf("OH_JSVM_CreateTypeError Failed");
214         OH_JSVM_ThrowError(env, nullptr, "TestCreateTypeErrortest3: OH_JSVM_CreateTypeError Failed");
215         return nullptr;
216     }
217 
218     bool result = true;
219     JSVM_Value value = nullptr;
220     OH_JSVM_GetBoolean(env, result, &value);
221     return value;
222 }
223 // code is “0”, msg is not null,result is nullptr
TestCreateTypeErrorTest4(JSVM_Env env,JSVM_CallbackInfo info)224 [[maybe_unused]] JSVM_Value TestCreateTypeErrorTest4(JSVM_Env env, JSVM_CallbackInfo info)
225 {
226     size_t argc = 1;
227     JSVM_Value argv[1] = {nullptr};
228     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
229 
230     JSVM_Value errorCode = nullptr;
231     OH_JSVM_CreateStringUtf8(env, "0", JSVM_AUTO_LENGTH, &errorCode);
232 
233     JSVM_Value errorMsg = nullptr;
234     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
235 
236     JSVM_Status creatStatus = OH_JSVM_CreateTypeError(env, errorCode, errorMsg, nullptr);
237     if (creatStatus == JSVM_OK) {
238         printf("OH_JSVM_CreateTypeError Failed");
239         OH_JSVM_ThrowError(env, nullptr, "TestCreateErrortest4: OH_JSVM_CreateTypeError Failed");
240         return nullptr;
241     }
242 
243     bool result = true;
244     JSVM_Value value = nullptr;
245     OH_JSVM_GetBoolean(env, result, &value);
246     return value;
247 }
248 //code is string,msg is not null,result is not null
TestCreateTypeErrorTest5(JSVM_Env env,JSVM_CallbackInfo info)249 [[maybe_unused]] JSVM_Value TestCreateTypeErrorTest5(JSVM_Env env, JSVM_CallbackInfo info)
250 {
251     size_t argc = 1;
252     JSVM_Value argv[1] = {nullptr};
253     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
254 
255     JSVM_Value errorCode = nullptr;
256     OH_JSVM_CreateStringUtf8(env, "error code", JSVM_AUTO_LENGTH, &errorCode);
257 
258     JSVM_Value errorMsg = nullptr;
259     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
260 
261     JSVM_Value rstValue = nullptr;
262     JSVM_Status creatStatus = OH_JSVM_CreateTypeError(env, errorCode, errorMsg, &rstValue);
263     if (creatStatus != JSVM_OK) {
264         printf("OH_JSVM_CreateTypeError Failed");
265         OH_JSVM_ThrowError(env, nullptr, "TestCreateErrortest5: OH_JSVM_CreateTypeError Failed");
266         return nullptr;
267     }
268 
269     bool result = true;
270     JSVM_Value value = nullptr;
271     OH_JSVM_GetBoolean(env, result, &value);
272     return value;
273 }
274 ///CreateRangeError interface
275 //code is "0", msg is not null,result is not null
TestCreateRangeErrorTest1(JSVM_Env env,JSVM_CallbackInfo info)276 [[maybe_unused]] JSVM_Value TestCreateRangeErrorTest1(JSVM_Env env, JSVM_CallbackInfo info)
277 {
278     size_t argc = 1;
279     JSVM_Value argv[1] = {nullptr};
280     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
281 
282     JSVM_Value errorCode = nullptr;
283     OH_JSVM_CreateStringUtf8(env, "0", JSVM_AUTO_LENGTH, &errorCode);
284 
285     JSVM_Value errorMsg = nullptr;
286     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
287 
288     JSVM_Value rstValue = nullptr;
289     JSVM_Status creatStatus = OH_JSVM_CreateRangeError(env, errorCode, errorMsg, &rstValue);
290     if (creatStatus != JSVM_OK) {
291         printf("OH_JSVM_CreateRangeError Failed");
292         OH_JSVM_ThrowError(env, nullptr, "TestCreateRangeErrortest1: OH_JSVM_CreateRangeError Failed");
293         return nullptr;
294     }
295 
296     bool result = true;
297     JSVM_Value value = nullptr;
298     OH_JSVM_GetBoolean(env, result, &value);
299     return value;
300 }
301 // code is "-3",msg is not null,result is not null
TestCreateRangeErrorTest2(JSVM_Env env,JSVM_CallbackInfo info)302 [[maybe_unused]] JSVM_Value TestCreateRangeErrorTest2(JSVM_Env env, JSVM_CallbackInfo info)
303 {
304     size_t argc = 1;
305     JSVM_Value argv[1] = {nullptr};
306     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
307 
308     JSVM_Value errorCode = nullptr;
309     OH_JSVM_CreateStringUtf8(env, "-3", JSVM_AUTO_LENGTH, &errorCode);
310 
311     JSVM_Value errorMsg = nullptr;
312     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
313 
314     JSVM_Value rstValue = nullptr;
315     JSVM_Status creatStatus = OH_JSVM_CreateRangeError(env, errorCode, errorMsg, &rstValue);
316     if (creatStatus != JSVM_OK) {
317         printf("OH_JSVM_CreateRangeError Failed");
318         OH_JSVM_ThrowError(env, nullptr, "TestCreateRangeErrortest2: OH_JSVM_CreateRangeError Failed");
319         return nullptr;
320     }
321 
322     bool result = true;
323     JSVM_Value value = nullptr;
324     OH_JSVM_GetBoolean(env, result, &value);
325     return value;
326 }
327 // code is null,msg is not null,result is not null
TestCreateRangeErrorTest3(JSVM_Env env,JSVM_CallbackInfo info)328 [[maybe_unused]] JSVM_Value TestCreateRangeErrorTest3(JSVM_Env env, JSVM_CallbackInfo info)
329 {
330     size_t argc = 1;
331     JSVM_Value argv[1] = {nullptr};
332     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
333 
334     JSVM_Value errorCode = nullptr;
335     OH_JSVM_CreateStringUtf8(env, "3", JSVM_AUTO_LENGTH, &errorCode);
336 
337     JSVM_Value errorMsg = nullptr;
338     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
339 
340     JSVM_Value rstValue = nullptr;
341     JSVM_Status creatStatus = OH_JSVM_CreateRangeError(env, errorCode, errorMsg, &rstValue);
342     if (creatStatus != JSVM_OK) {
343         printf("OH_JSVM_CreateRangeError Failed");
344         OH_JSVM_ThrowError(env, nullptr, "TestCreateRangeErrortest3: OH_JSVM_CreateRangeError Failed");
345         return nullptr;
346     }
347 
348     bool result = true;
349     JSVM_Value value = nullptr;
350     OH_JSVM_GetBoolean(env, result, &value);
351     return value;
352 }
353 // code is "0", msg is not null,result is nullptr
TestCreateRangeErrorTest4(JSVM_Env env,JSVM_CallbackInfo info)354 [[maybe_unused]] JSVM_Value TestCreateRangeErrorTest4(JSVM_Env env, JSVM_CallbackInfo info)
355 {
356     size_t argc = 1;
357     JSVM_Value argv[1] = {nullptr};
358     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
359 
360     JSVM_Value errorCode = nullptr;
361     OH_JSVM_CreateStringUtf8(env, "3", JSVM_AUTO_LENGTH, &errorCode);
362 
363     JSVM_Value errorMsg = nullptr;
364     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
365 
366     JSVM_Status creatStatus = OH_JSVM_CreateRangeError(env, errorCode, errorMsg, nullptr);
367     if (creatStatus == JSVM_OK) {
368         printf("OH_JSVM_CreateRangeError Failed");
369         OH_JSVM_ThrowError(env, nullptr, "TestCreateRangeErrortest4: OH_JSVM_CreateRangeError Failed");
370         return nullptr;
371     }
372 
373     bool result = true;
374     JSVM_Value value = nullptr;
375     OH_JSVM_GetBoolean(env, result, &value);
376     return value;
377 }
378 //code is string,msg is not null,result is not null
TestCreateRangeErrorTest5(JSVM_Env env,JSVM_CallbackInfo info)379 [[maybe_unused]] JSVM_Value TestCreateRangeErrorTest5(JSVM_Env env, JSVM_CallbackInfo info)
380 {
381     size_t argc = 1;
382     JSVM_Value argv[1] = {nullptr};
383     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
384 
385     JSVM_Value errorCode = nullptr;
386     OH_JSVM_CreateStringUtf8(env, "error code", JSVM_AUTO_LENGTH, &errorCode);
387 
388     JSVM_Value errorMsg = nullptr;
389     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
390 
391     JSVM_Value rstValue = nullptr;
392     JSVM_Status creatStatus = OH_JSVM_CreateRangeError(env, errorCode, errorMsg, &rstValue);
393     if (creatStatus != JSVM_OK) {
394         printf("OH_JSVM_CreateRangeError Failed");
395         OH_JSVM_ThrowError(env, nullptr, "TestCreateRangeErrortest5: OH_JSVM_CreateRangeError Failed");
396         return nullptr;
397     }
398 
399     bool result = true;
400     JSVM_Value value = nullptr;
401     OH_JSVM_GetBoolean(env, result, &value);
402     return value;
403 }
404 ///CreateSyntaxError interface
405 //code is "0", msg is not null,result is not null
TestCreateSyntaxErrorTest1(JSVM_Env env,JSVM_CallbackInfo info)406 [[maybe_unused]] JSVM_Value TestCreateSyntaxErrorTest1(JSVM_Env env, JSVM_CallbackInfo info)
407 {
408     size_t argc = 1;
409     JSVM_Value argv[1] = {nullptr};
410     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
411 
412     JSVM_Value errorCode = nullptr;
413     OH_JSVM_CreateStringUtf8(env, "0", JSVM_AUTO_LENGTH, &errorCode);
414 
415     JSVM_Value errorMsg = nullptr;
416     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
417 
418     JSVM_Value rstValue = nullptr;
419     JSVM_Status creatStatus = OH_JSVM_CreateSyntaxError(env, errorCode, errorMsg, &rstValue);
420     if (creatStatus != JSVM_OK) {
421         printf("OH_JSVM_CreateSyntaxError Failed");
422         OH_JSVM_ThrowError(env, nullptr, "TestCreateSyntaxErrortest1: OH_JSVM_CreateSyntaxError Failed");
423         return nullptr;
424     }
425 
426     bool result = true;
427     JSVM_Value value = nullptr;
428     OH_JSVM_GetBoolean(env, result, &value);
429     return value;
430 }
431 // code is "-3",msg is not null,result is not null
TestCreateSyntaxErrorTest2(JSVM_Env env,JSVM_CallbackInfo info)432 [[maybe_unused]] JSVM_Value TestCreateSyntaxErrorTest2(JSVM_Env env, JSVM_CallbackInfo info)
433 {
434     size_t argc = 1;
435     JSVM_Value argv[1] = {nullptr};
436     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
437 
438     JSVM_Value errorCode = nullptr;
439     OH_JSVM_CreateStringUtf8(env, "-3", JSVM_AUTO_LENGTH, &errorCode);
440 
441     JSVM_Value errorMsg = nullptr;
442     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
443 
444     JSVM_Value rstValue = nullptr;
445     JSVM_Status creatStatus = OH_JSVM_CreateSyntaxError(env, errorCode, errorMsg, &rstValue);
446     if (creatStatus != JSVM_OK) {
447         printf("OH_JSVM_CreateSyntaxError Failed");
448         OH_JSVM_ThrowError(env, nullptr, "TestCreateSyntaxErrortest2: OH_JSVM_CreateSyntaxError Failed");
449     }
450 
451     bool result = true;
452     JSVM_Value value = nullptr;
453     OH_JSVM_GetBoolean(env, result, &value);
454     return value;
455 }
456 // code is "3",msg is not null,result is not null
TestCreateSyntaxErrorTest3(JSVM_Env env,JSVM_CallbackInfo info)457 [[maybe_unused]] JSVM_Value TestCreateSyntaxErrorTest3(JSVM_Env env, JSVM_CallbackInfo info)
458 {
459     size_t argc = 1;
460     JSVM_Value argv[1] = {nullptr};
461     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
462 
463     JSVM_Value errorCode = nullptr;
464     OH_JSVM_CreateStringUtf8(env, "3", JSVM_AUTO_LENGTH, &errorCode);
465 
466     JSVM_Value errorMsg = nullptr;
467     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
468 
469     JSVM_Value rstValue = nullptr;
470     JSVM_Status creatStatus = OH_JSVM_CreateSyntaxError(env, errorCode, errorMsg, &rstValue);
471     if (creatStatus != JSVM_OK) {
472         printf("OH_JSVM_CreateSyntaxError Failed");
473         OH_JSVM_ThrowError(env, nullptr, "TestCreateSyntaxErrortest3: OH_JSVM_CreateSyntaxError Failed");
474         return nullptr;
475     }
476 
477     bool result = true;
478     JSVM_Value value = nullptr;
479     OH_JSVM_GetBoolean(env, result, &value);
480     return value;
481 }
482 // code is "0", msg is not null,result is nullptr
TestCreateSyntaxErrorTest4(JSVM_Env env,JSVM_CallbackInfo info)483 [[maybe_unused]] JSVM_Value TestCreateSyntaxErrorTest4(JSVM_Env env, JSVM_CallbackInfo info)
484 {
485     size_t argc = 1;
486     JSVM_Value argv[1] = {nullptr};
487     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
488 
489     JSVM_Value errorCode = nullptr;
490     OH_JSVM_CreateStringUtf8(env, "0", JSVM_AUTO_LENGTH, &errorCode);
491 
492     JSVM_Value errorMsg = nullptr;
493     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
494 
495     JSVM_Status creatStatus = OH_JSVM_CreateSyntaxError(env, errorCode, errorMsg, nullptr);
496     if (creatStatus == JSVM_OK) {
497         printf("OH_JSVM_CreateSyntaxError Failed");
498         OH_JSVM_ThrowError(env, nullptr, "TestCreateSyntaxErrortest4: OH_JSVM_CreateSyntaxError Failed");
499         return nullptr;
500     }
501 
502     bool result = true;
503     JSVM_Value value = nullptr;
504     OH_JSVM_GetBoolean(env, result, &value);
505     return value;
506 }
507 //code is string,msg is not null,result is not null
TestCreateSyntaxErrorTest5(JSVM_Env env,JSVM_CallbackInfo info)508 [[maybe_unused]] JSVM_Value TestCreateSyntaxErrorTest5(JSVM_Env env, JSVM_CallbackInfo info)
509 {
510     size_t argc = 1;
511     JSVM_Value argv[1] = {nullptr};
512     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
513 
514     JSVM_Value errorCode = nullptr;
515     OH_JSVM_CreateStringUtf8(env, "error code", JSVM_AUTO_LENGTH, &errorCode);
516 
517     JSVM_Value errorMsg = nullptr;
518     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
519 
520     JSVM_Value rstValue = nullptr;
521     JSVM_Status creatStatus = OH_JSVM_CreateSyntaxError(env, errorCode, errorMsg, &rstValue);
522     if (creatStatus != JSVM_OK) {
523         printf("OH_JSVM_CreateSyntaxError Failed");
524         OH_JSVM_ThrowError(env, nullptr, "TestCreateSyntaxErrortest5: OH_JSVM_CreateSyntaxError Failed");
525         return nullptr;
526     }
527 
528     bool result = true;
529     JSVM_Value value = nullptr;
530     OH_JSVM_GetBoolean(env, result, &value);
531     return value;
532 }
533 //Throw interface
534 //error is not javascript error
TestThrowTest1(JSVM_Env env,JSVM_CallbackInfo info)535 [[maybe_unused]] JSVM_Value TestThrowTest1(JSVM_Env env, JSVM_CallbackInfo info)
536 {
537     size_t argc = 1;
538     JSVM_Value argv[1] = {nullptr};
539     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
540 
541     int32_t iNum = 3;
542     JSVM_Value rstNumValue = nullptr;
543     JSVM_Status status = OH_JSVM_CreateInt32(env, iNum, &rstNumValue);
544     if (status != JSVM_OK) {
545         OH_JSVM_ThrowError(env, nullptr, "TestThrowtest1: OH_JSVM_CreateInt32 Failed");
546         return nullptr;
547     }
548 
549     JSVM_Status creatStatus = OH_JSVM_Throw(env, rstNumValue);
550     if (creatStatus != JSVM_OK) {
551         OH_JSVM_ThrowError(env, nullptr, "TestThrowtest1: OH_JSVM_Throw Failed");
552         return nullptr;
553     }
554     JSVM_Value getAndClearErr = nullptr;
555     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
556     if (getAndClearStatus != JSVM_OK) {
557         OH_JSVM_ThrowError(env, nullptr, "TestThrowtest1: OH_JSVM_GetAndClearLastException Failed");
558         return nullptr;
559     }
560 
561     bool result = true;
562     JSVM_Value value = nullptr;
563     OH_JSVM_GetBoolean(env, result, &value);
564     return value;
565 }
566 //error is CreateError js error
TestThrowTest2(JSVM_Env env,JSVM_CallbackInfo info)567 [[maybe_unused]] JSVM_Value TestThrowTest2(JSVM_Env env, JSVM_CallbackInfo info)
568 {
569     size_t argc = 1;
570     JSVM_Value argv[1] = {nullptr};
571     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
572 
573     const char* strErrCode = "error code";
574     JSVM_Value errCode = nullptr;
575     OH_JSVM_CreateStringUtf8(env, strErrCode, JSVM_AUTO_LENGTH, &errCode);
576 
577     const char* strErrMsg = "error msg";
578     JSVM_Value errorMsg = nullptr;
579     OH_JSVM_CreateStringUtf8(env, strErrMsg, JSVM_AUTO_LENGTH, &errorMsg);
580 
581     JSVM_Value errCreateInfo = nullptr;
582     JSVM_Status creatStatus = OH_JSVM_CreateError(env, errCode, errorMsg, &errCreateInfo);
583     if (creatStatus != JSVM_OK) {
584         OH_JSVM_ThrowError(env, nullptr, "TestThrowtest2: OH_JSVM_CreateError Failed");
585         return nullptr;
586     }
587 
588     JSVM_Status throwStatus = OH_JSVM_Throw(env, errCreateInfo);
589     if (throwStatus != JSVM_OK) {
590         OH_JSVM_ThrowError(env, nullptr, "TestThrowtest2: OH_JSVM_Throw Failed");
591         return nullptr;
592     }
593     JSVM_Value getAndClearErr = nullptr;
594     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
595     if (getAndClearStatus != JSVM_OK) {
596         OH_JSVM_ThrowError(env, nullptr, "TestThrowtest2: OH_JSVM_GetAndClearLastException Failed");
597         return nullptr;
598     }
599 
600     bool result = true;
601     JSVM_Value value = nullptr;
602     OH_JSVM_GetBoolean(env, result, &value);
603     return value;
604 }
605 //error is CreateTypeError js error
TestThrowTest3(JSVM_Env env,JSVM_CallbackInfo info)606 [[maybe_unused]] JSVM_Value TestThrowTest3(JSVM_Env env, JSVM_CallbackInfo info)
607 {
608     size_t argc = 1;
609     JSVM_Value argv[1] = {nullptr};
610     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
611 
612     const char* strErrCode = "error type code";
613     JSVM_Value errCode = nullptr;
614     OH_JSVM_CreateStringUtf8(env, strErrCode, JSVM_AUTO_LENGTH, &errCode);
615 
616     const char* strErrMsg = "error type msg";
617     JSVM_Value errorMsg = nullptr;
618     OH_JSVM_CreateStringUtf8(env, strErrMsg, JSVM_AUTO_LENGTH, &errorMsg);
619 
620     JSVM_Value errCreateInfo = nullptr;
621     JSVM_Status creatStatus = OH_JSVM_CreateTypeError(env, errCode, errorMsg, &errCreateInfo);
622     if (creatStatus != JSVM_OK) {
623         OH_JSVM_ThrowError(env, nullptr, "TestThrowTest3: OH_JSVM_CreateTypeError Failed");
624         return nullptr;
625     }
626 
627     JSVM_Status throwStatus = OH_JSVM_Throw(env, errCreateInfo);
628     if (throwStatus != JSVM_OK) {
629         OH_JSVM_ThrowError(env, nullptr, "TestThrowTest3: OH_JSVM_Throw Failed");
630         return nullptr;
631     }
632     JSVM_Value getAndClearErr = nullptr;
633     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
634     if (getAndClearStatus != JSVM_OK) {
635         OH_JSVM_ThrowError(env, nullptr, "TestThrowTest3: OH_JSVM_GetAndClearLastException Failed");
636         return nullptr;
637     }
638 
639     bool result = true;
640     JSVM_Value value = nullptr;
641     OH_JSVM_GetBoolean(env, result, &value);
642     return value;
643 }
644 //error is CreateRangeError js error
TestThrowTest4(JSVM_Env env,JSVM_CallbackInfo info)645 [[maybe_unused]] JSVM_Value TestThrowTest4(JSVM_Env env, JSVM_CallbackInfo info)
646 {
647     size_t argc = 1;
648     JSVM_Value argv[1] = {nullptr};
649     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
650 
651     const char* strRangeErrCode = "error Range code";
652     JSVM_Value errCode = nullptr;
653     OH_JSVM_CreateStringUtf8(env, strRangeErrCode, JSVM_AUTO_LENGTH, &errCode);
654 
655     const char* strRangeErrMsg = "error Range msg";
656     JSVM_Value errorMsg = nullptr;
657     OH_JSVM_CreateStringUtf8(env, strRangeErrMsg, JSVM_AUTO_LENGTH, &errorMsg);
658 
659     JSVM_Value errCreateInfo = nullptr;
660     JSVM_Status creatStatus = OH_JSVM_CreateRangeError(env, errCode, errorMsg, &errCreateInfo);
661     if (creatStatus != JSVM_OK) {
662         OH_JSVM_ThrowError(env, nullptr, "TestThrowTest4: OH_JSVM_CreateRangeError Failed");
663         return nullptr;
664     }
665 
666     JSVM_Status throwStatus = OH_JSVM_Throw(env, errCreateInfo);
667     if (throwStatus != JSVM_OK) {
668         OH_JSVM_ThrowError(env, nullptr, "TestThrowTest4: OH_JSVM_Throw Failed");
669         return nullptr;
670     }
671     JSVM_Value getAndClearErr = nullptr;
672     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
673     if (getAndClearStatus != JSVM_OK) {
674         OH_JSVM_ThrowError(env, nullptr, "TestThrowTest4: OH_JSVM_GetAndClearLastException Failed");
675         return nullptr;
676     }
677 
678     bool result = true;
679     JSVM_Value value = nullptr;
680     OH_JSVM_GetBoolean(env, result, &value);
681     return value;
682 }
683 //error is CreateSyntaxError js error
TestThrowTest5(JSVM_Env env,JSVM_CallbackInfo info)684 [[maybe_unused]] JSVM_Value TestThrowTest5(JSVM_Env env, JSVM_CallbackInfo info)
685 {
686     size_t argc = 1;
687     JSVM_Value argv[1] = {nullptr};
688     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
689 
690     const char* strRangeErrCode = "error Range code";
691     JSVM_Value errCode = nullptr;
692     OH_JSVM_CreateStringUtf8(env, strRangeErrCode, JSVM_AUTO_LENGTH, &errCode);
693     const char* strRangeErrMsg = "error Range msg";
694     JSVM_Value errorMsg = nullptr;
695     OH_JSVM_CreateStringUtf8(env, strRangeErrMsg, JSVM_AUTO_LENGTH, &errorMsg);
696 
697     JSVM_Value errCreateInfo = nullptr;
698     JSVM_Status creatStatus = OH_JSVM_CreateSyntaxError(env, errCode, errorMsg, &errCreateInfo);
699     if (creatStatus != JSVM_OK) {
700         OH_JSVM_ThrowError(env, nullptr, "TestThrowtest5: OH_JSVM_CreateSyntaxError Failed");
701         return nullptr;
702     }
703 
704     JSVM_Status throwStatus = OH_JSVM_Throw(env, errCreateInfo);
705     if (throwStatus != JSVM_OK) {
706         OH_JSVM_ThrowError(env, nullptr, "TestThrowtest5: OH_JSVM_Throw Failed");
707         return nullptr;
708     }
709     JSVM_Value getAndClearErr = nullptr;
710     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
711     if (getAndClearStatus != JSVM_OK) {
712         OH_JSVM_ThrowError(env, nullptr, "TestThrowtest5: OH_JSVM_GetAndClearLastException Failed");
713         return nullptr;
714     }
715 
716     bool result = true;
717     JSVM_Value value = nullptr;
718     OH_JSVM_GetBoolean(env, result, &value);
719     return value;
720 }
721 //error is javascript Error
TestThrowTest6(JSVM_Env env,JSVM_CallbackInfo info)722 [[maybe_unused]] JSVM_Value TestThrowTest6(JSVM_Env env, JSVM_CallbackInfo info)
723 {
724     size_t argc = 1;
725     JSVM_Value argv[1] = {nullptr};
726     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
727 
728     JSVM_Status throwStatus = OH_JSVM_Throw(env, argv[0]);
729     if (throwStatus != JSVM_OK) {
730         OH_JSVM_ThrowError(env, nullptr, "TestThrowtest6: OH_JSVM_Throw Failed");
731         return nullptr;
732     }
733     JSVM_Value getAndClearErr = nullptr;
734     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
735     if (getAndClearStatus != JSVM_OK) {
736         OH_JSVM_ThrowError(env, nullptr, "TestThrowtest6: OH_JSVM_GetAndClearLastException Failed");
737         return nullptr;
738     }
739 
740     bool result = true;
741     JSVM_Value value = nullptr;
742     OH_JSVM_GetBoolean(env, result, &value);
743     return value;
744 }
745 //ThrowError
746 //code is not null,msg is nullptr
TestThrowErrorTest1(JSVM_Env env,JSVM_CallbackInfo info)747 [[maybe_unused]] JSVM_Value TestThrowErrorTest1(JSVM_Env env, JSVM_CallbackInfo info)
748 {
749     size_t argc = 1;
750     JSVM_Value argv[1] = {nullptr};
751     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
752 
753     const char* errCode = "error code";
754     JSVM_Status throwStatus = OH_JSVM_ThrowError(env, errCode, nullptr);
755     if (throwStatus == JSVM_OK) {
756         OH_JSVM_ThrowError(env, nullptr, "TestThrowErrortest1: OH_JSVM_ThrowError Failed");
757         return nullptr;
758     }
759     JSVM_Value getAndClearErr = nullptr;
760     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
761     if (getAndClearStatus != JSVM_OK) {
762         OH_JSVM_ThrowError(env, nullptr, "TestThrowErrortest1: OH_JSVM_GetAndClearLastException Failed");
763         return nullptr;
764     }
765 
766     bool result = true;
767     JSVM_Value value = nullptr;
768     OH_JSVM_GetBoolean(env, result, &value);
769     return value;
770 }
771 //code is nullptr,msg is not null
TestThrowErrorTest2(JSVM_Env env,JSVM_CallbackInfo info)772 [[maybe_unused]] JSVM_Value TestThrowErrorTest2(JSVM_Env env, JSVM_CallbackInfo info)
773 {
774     size_t argc = 1;
775     JSVM_Value argv[1] = {nullptr};
776     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
777 
778     const char* errMsg = "error msg";
779     JSVM_Status throwStatus = OH_JSVM_ThrowError(env, nullptr, errMsg);
780     if (throwStatus != JSVM_OK) {
781         OH_JSVM_ThrowError(env, nullptr, "TestThrowErrortest2: OH_JSVM_ThrowError Failed");
782         return nullptr;
783     }
784     JSVM_Value getAndClearErr = nullptr;
785     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
786     if (getAndClearStatus != JSVM_OK) {
787         OH_JSVM_ThrowError(env, nullptr, "TestThrowErrortest2: OH_JSVM_GetAndClearLastException Failed");
788         return nullptr;
789     }
790 
791     bool result = true;
792     JSVM_Value value = nullptr;
793     OH_JSVM_GetBoolean(env, result, &value);
794     return value;
795 }
796 //code is not null,msg is not null
TestThrowErrorTest3(JSVM_Env env,JSVM_CallbackInfo info)797 [[maybe_unused]] JSVM_Value TestThrowErrorTest3(JSVM_Env env, JSVM_CallbackInfo info)
798 {
799     size_t argc = 1;
800     JSVM_Value argv[1] = {nullptr};
801     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
802 
803     const char* errCode = "error code";
804     const char* errMsg = "error msg";
805     JSVM_Status throwStatus = OH_JSVM_ThrowError(env, errCode, errMsg);
806     if (throwStatus != JSVM_OK) {
807         OH_JSVM_ThrowError(env, nullptr, "TestThrowErrortest3: OH_JSVM_ThrowError Failed");
808         return nullptr;
809     }
810     JSVM_Value getAndClearErr = nullptr;
811     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
812     if (getAndClearStatus != JSVM_OK) {
813         OH_JSVM_ThrowError(env, nullptr, "TestThrowErrortest3: OH_JSVM_GetAndClearLastException Failed");
814         return nullptr;
815     }
816 
817     bool result = true;
818     JSVM_Value value = nullptr;
819     OH_JSVM_GetBoolean(env, result, &value);
820     return value;
821 }
822 //ThrowTypeError
823 //code is not null,msg is nullptr
TestThrowTypeErrorTest1(JSVM_Env env,JSVM_CallbackInfo info)824 [[maybe_unused]] JSVM_Value TestThrowTypeErrorTest1(JSVM_Env env, JSVM_CallbackInfo info)
825 {
826     size_t argc = 1;
827     JSVM_Value argv[1] = {nullptr};
828     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
829 
830     const char* errCode = "error type code";
831     JSVM_Status throwStatus = OH_JSVM_ThrowTypeError(env, errCode, nullptr);
832     if (throwStatus == JSVM_OK) {
833         OH_JSVM_ThrowError(env, nullptr, "TestThrowTypeErrortest1: OH_JSVM_ThrowTypeError Failed");
834         return nullptr;
835     }
836     JSVM_Value getAndClearErr = nullptr;
837     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
838     if (getAndClearStatus != JSVM_OK) {
839         OH_JSVM_ThrowError(env, nullptr, "TestThrowTypeErrortest1: OH_JSVM_GetAndClearLastException Failed");
840         return nullptr;
841     }
842 
843     bool result = true;
844     JSVM_Value value = nullptr;
845     OH_JSVM_GetBoolean(env, result, &value);
846     return value;
847 }
848 //code is nullptr,msg is not null
TestThrowTypeErrorTest2(JSVM_Env env,JSVM_CallbackInfo info)849 [[maybe_unused]] JSVM_Value TestThrowTypeErrorTest2(JSVM_Env env, JSVM_CallbackInfo info)
850 {
851     size_t argc = 1;
852     JSVM_Value argv[1] = {nullptr};
853     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
854 
855     const char* errMsg = "error type msg";
856     JSVM_Status throwStatus = OH_JSVM_ThrowTypeError(env, nullptr, errMsg);
857     if (throwStatus != JSVM_OK) {
858         OH_JSVM_ThrowError(env, nullptr, "TestThrowTypeErrortest2: OH_JSVM_ThrowTypeError Failed");
859         return nullptr;
860     }
861     JSVM_Value getAndClearErr = nullptr;
862     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
863     if (getAndClearStatus != JSVM_OK) {
864         OH_JSVM_ThrowError(env, nullptr, "TestThrowTypeErrortest2: OH_JSVM_GetAndClearLastException Failed");
865         return nullptr;
866     }
867 
868     bool result = true;
869     JSVM_Value value = nullptr;
870     OH_JSVM_GetBoolean(env, result, &value);
871     return value;
872 }
873 //code is not null,msg is not null
TestThrowTypeErrorTest3(JSVM_Env env,JSVM_CallbackInfo info)874 [[maybe_unused]] JSVM_Value TestThrowTypeErrorTest3(JSVM_Env env, JSVM_CallbackInfo info)
875 {
876     size_t argc = 1;
877     JSVM_Value argv[1] = {nullptr};
878     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
879 
880     const char* errCode = "error type code";
881     const char* errMsg = "error type msg";
882     JSVM_Status throwStatus = OH_JSVM_ThrowTypeError(env, errCode, errMsg);
883     if (throwStatus != JSVM_OK) {
884         OH_JSVM_ThrowError(env, nullptr, "TestThrowTypeErrortest3: OH_JSVM_ThrowError Failed");
885         return nullptr;
886     }
887     JSVM_Value getAndClearErr = nullptr;
888     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
889     if (getAndClearStatus != JSVM_OK) {
890         OH_JSVM_ThrowError(env, nullptr, "TestThrowTypeErrortest3: OH_JSVM_GetAndClearLastException Failed");
891         return nullptr;
892     }
893 
894     bool result = true;
895     JSVM_Value value = nullptr;
896     OH_JSVM_GetBoolean(env, result, &value);
897     return value;
898 }
899 //ThrowRangeError
900 //code is not null,msg is nullptr
TestThrowRangeErrorTest1(JSVM_Env env,JSVM_CallbackInfo info)901 [[maybe_unused]] JSVM_Value TestThrowRangeErrorTest1(JSVM_Env env, JSVM_CallbackInfo info)
902 {
903     size_t argc = 1;
904     JSVM_Value argv[1] = {nullptr};
905     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
906 
907     const char* errCode = "error Range code";
908     JSVM_Status throwStatus = OH_JSVM_ThrowRangeError(env, errCode, nullptr);
909     if (throwStatus == JSVM_OK) {
910         OH_JSVM_ThrowError(env, nullptr, "TestThrowRangeErrortest1: OH_JSVM_ThrowRangeError Failed");
911         return nullptr;
912     }
913     JSVM_Value getAndClearErr = nullptr;
914     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
915     if (getAndClearStatus != JSVM_OK) {
916         OH_JSVM_ThrowError(env, nullptr, "TestThrowRangeErrortest1: OH_JSVM_GetAndClearLastException Failed");
917         return nullptr;
918     }
919 
920     bool result = true;
921     JSVM_Value value = nullptr;
922     OH_JSVM_GetBoolean(env, result, &value);
923     return value;
924 }
925 //code is nullptr,msg is not null
TestThrowRangeErrorTest2(JSVM_Env env,JSVM_CallbackInfo info)926 [[maybe_unused]] JSVM_Value TestThrowRangeErrorTest2(JSVM_Env env, JSVM_CallbackInfo info)
927 {
928     size_t argc = 1;
929     JSVM_Value argv[1] = {nullptr};
930     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
931 
932     const char* errMsg = "error Range msg";
933     JSVM_Status throwStatus = OH_JSVM_ThrowRangeError(env, nullptr, errMsg);
934     if (throwStatus != JSVM_OK) {
935         OH_JSVM_ThrowError(env, nullptr, "TestThrowRangeErrortest2: OH_JSVM_ThrowRangeError Failed");
936         return nullptr;
937     }
938     JSVM_Value getAndClearErr = nullptr;
939     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
940     if (getAndClearStatus != JSVM_OK) {
941         OH_JSVM_ThrowError(env, nullptr, "TestThrowRangeErrortest2: OH_JSVM_GetAndClearLastException Failed");
942         return nullptr;
943     }
944 
945     bool result = true;
946     JSVM_Value value = nullptr;
947     OH_JSVM_GetBoolean(env, result, &value);
948     return value;
949 }
950 //code is not null,msg is not null
TestThrowRangeErrorTest3(JSVM_Env env,JSVM_CallbackInfo info)951 [[maybe_unused]] JSVM_Value TestThrowRangeErrorTest3(JSVM_Env env, JSVM_CallbackInfo info)
952 {
953     size_t argc = 1;
954     JSVM_Value argv[1] = {nullptr};
955     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
956 
957     const char* errCode = "error Range code";
958     const char* errMsg = "error Range msg";
959     JSVM_Status throwStatus = OH_JSVM_ThrowRangeError(env, errCode, errMsg);
960     if (throwStatus != JSVM_OK) {
961         OH_JSVM_ThrowError(env, nullptr, "TestThrowRangeErrortest3: OH_JSVM_ThrowRangeError Failed");
962         return nullptr;
963     }
964     JSVM_Value getAndClearErr = nullptr;
965     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
966     if (getAndClearStatus != JSVM_OK) {
967         OH_JSVM_ThrowError(env, nullptr, "TestThrowRangeErrortest3: OH_JSVM_GetAndClearLastException Failed");
968         return nullptr;
969     }
970 
971     bool result = true;
972     JSVM_Value value = nullptr;
973     OH_JSVM_GetBoolean(env, result, &value);
974     return value;
975 }
976 //ThrowSyntaxError
977 //code is not null,msg is nullptr
TestThrowSyntaxErrorTest1(JSVM_Env env,JSVM_CallbackInfo info)978 [[maybe_unused]] JSVM_Value TestThrowSyntaxErrorTest1(JSVM_Env env, JSVM_CallbackInfo info)
979 {
980     size_t argc = 1;
981     JSVM_Value argv[1] = {nullptr};
982     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
983 
984     const char* errCode = "error Syntax code";
985     JSVM_Status throwStatus = OH_JSVM_ThrowSyntaxError(env, errCode, nullptr);
986     if (throwStatus == JSVM_OK) {
987         OH_JSVM_ThrowError(env, nullptr, "TestThrowSyntaxErrorTest1: OH_JSVM_ThrowSyntaxError Failed");
988         return nullptr;
989     }
990     JSVM_Value getAndClearErr = nullptr;
991     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
992     if (getAndClearStatus != JSVM_OK) {
993         OH_JSVM_ThrowError(env, nullptr, "TestThrowSyntaxErrorTest1: OH_JSVM_GetAndClearLastException Failed");
994         return nullptr;
995     }
996 
997     bool result = true;
998     JSVM_Value value = nullptr;
999     OH_JSVM_GetBoolean(env, result, &value);
1000     return value;
1001 }
1002 //code is nullptr,msg is not null
TestThrowSyntaxErrorTest2(JSVM_Env env,JSVM_CallbackInfo info)1003 [[maybe_unused]] JSVM_Value TestThrowSyntaxErrorTest2(JSVM_Env env, JSVM_CallbackInfo info)
1004 {
1005     size_t argc = 1;
1006     JSVM_Value argv[1] = {nullptr};
1007     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1008 
1009     const char* errMsg = "error Syntax msg";
1010     JSVM_Status throwStatus = OH_JSVM_ThrowSyntaxError(env, nullptr, errMsg);
1011     if (throwStatus != JSVM_OK) {
1012         OH_JSVM_ThrowError(env, nullptr, "TestThrowSyntaxErrorTest2: OH_JSVM_ThrowSyntaxError Failed");
1013         return nullptr;
1014     }
1015     JSVM_Value getAndClearErr = nullptr;
1016     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
1017     if (getAndClearStatus != JSVM_OK) {
1018         OH_JSVM_ThrowError(env, nullptr, "TestThrowSyntaxErrorTest2: OH_JSVM_GetAndClearLastException Failed");
1019         return nullptr;
1020     }
1021 
1022     bool result = true;
1023     JSVM_Value value = nullptr;
1024     OH_JSVM_GetBoolean(env, result, &value);
1025     return value;
1026 }
1027 //code is not null,msg is not null
TestThrowSyntaxErrorTest3(JSVM_Env env,JSVM_CallbackInfo info)1028 [[maybe_unused]] JSVM_Value TestThrowSyntaxErrorTest3(JSVM_Env env, JSVM_CallbackInfo info)
1029 {
1030     size_t argc = 1;
1031     JSVM_Value argv[1] = {nullptr};
1032     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1033 
1034     const char* errCode = "error Syntax code";
1035     const char* errMsg = "error Syntax msg";
1036     JSVM_Status throwStatus = OH_JSVM_ThrowSyntaxError(env, errCode, errMsg);
1037     if (throwStatus != JSVM_OK) {
1038         OH_JSVM_ThrowError(env, nullptr, "TestThrowSyntaxErrorTest3: OH_JSVM_ThrowSyntaxError Failed");
1039         return nullptr;
1040     }
1041     JSVM_Value getAndClearErr = nullptr;
1042     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
1043     if (getAndClearStatus != JSVM_OK) {
1044         OH_JSVM_ThrowError(env, nullptr, "TestThrowSyntaxErrorTest3: OH_JSVM_GetAndClearLastException Failed");
1045         return nullptr;
1046     }
1047 
1048     bool result = true;
1049     JSVM_Value value = nullptr;
1050     OH_JSVM_GetBoolean(env, result, &value);
1051     return value;
1052 }
1053 //IsError
1054 //value is error object,result is nullptr
TestIsErrorTest1(JSVM_Env env,JSVM_CallbackInfo info)1055 [[maybe_unused]] JSVM_Value TestIsErrorTest1(JSVM_Env env, JSVM_CallbackInfo info)
1056 {
1057     size_t argc = 1;
1058     JSVM_Value argv[1] = {nullptr};
1059     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1060 
1061     JSVM_Value errorCode = nullptr;
1062     OH_JSVM_CreateStringUtf8(env, "error code", JSVM_AUTO_LENGTH, &errorCode);
1063 
1064     JSVM_Value errorMsg = nullptr;
1065     OH_JSVM_CreateStringUtf8(env, "not null", JSVM_AUTO_LENGTH, &errorMsg);
1066 
1067     JSVM_Value rstValue = nullptr;
1068     JSVM_Status creatStatus = OH_JSVM_CreateError(env, errorCode, errorMsg, &rstValue);
1069     if (creatStatus != JSVM_OK) {
1070         OH_JSVM_ThrowError(env, nullptr, "TestIsErrorTest1: OH_JSVM_CreateError Failed");
1071         return nullptr;
1072     }
1073 
1074     JSVM_Status rstStatus = OH_JSVM_IsError(env, rstValue, nullptr);
1075     if (rstStatus == JSVM_OK) {
1076         OH_JSVM_ThrowError(env, nullptr, "TestIsErrorTest1: OH_JSVM_IsError Failed");
1077         return nullptr;
1078     }
1079 
1080     bool result = true;
1081     JSVM_Value value = nullptr;
1082     OH_JSVM_GetBoolean(env, result, &value);
1083     return value;
1084 }
1085 //vaule is not error object,result is not null
TestIsErrorTest2(JSVM_Env env,JSVM_CallbackInfo info)1086 [[maybe_unused]] JSVM_Value TestIsErrorTest2(JSVM_Env env, JSVM_CallbackInfo info)
1087 {
1088     size_t argc = 1;
1089     JSVM_Value argv[1] = {nullptr};
1090     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1091 
1092     bool bRst = false;
1093     JSVM_Status rstStatus = OH_JSVM_IsError(env, argv[0], &bRst);
1094     if (rstStatus != JSVM_OK) {
1095         OH_JSVM_ThrowError(env, nullptr, "TestIsErrorTest2: OH_JSVM_IsError status Failed");
1096     }
1097 
1098     if (bRst) {
1099         OH_JSVM_ThrowError(env, nullptr, "TestIsErrorTest2: OH_JSVM_IsError bool Failed");
1100     }
1101 
1102     bool result = true;
1103     JSVM_Value value = nullptr;
1104     OH_JSVM_GetBoolean(env, result, &value);
1105     return value;
1106 }
1107 //GetAndClearLastException
1108 //result is not null,exist error
TestGetAndClearLastExceptionTest1(JSVM_Env env,JSVM_CallbackInfo info)1109 [[maybe_unused]] JSVM_Value TestGetAndClearLastExceptionTest1(JSVM_Env env, JSVM_CallbackInfo info)
1110 {
1111     size_t argc = 1;
1112     JSVM_Value argv[1] = {nullptr};
1113     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1114     // throw error
1115     OH_JSVM_ThrowError(env, "create error code", "create error msg");
1116     JSVM_Value rstValue = nullptr;
1117     JSVM_Status rstStatus = OH_JSVM_GetAndClearLastException(env, &rstValue);
1118     if (rstStatus != JSVM_OK) {
1119         OH_JSVM_ThrowError(env, nullptr,
1120             "TestGetAndClearLastExceptionTest1: OH_JSVM_GetAndClearLastException status Failed");
1121         return nullptr;
1122     }
1123 
1124     bool result = true;
1125     JSVM_Value value = nullptr;
1126     OH_JSVM_GetBoolean(env, result, &value);
1127     return value;
1128 }
1129 //result is not null,not exist error
TestGetAndClearLastExceptionTest2(JSVM_Env env,JSVM_CallbackInfo info)1130 [[maybe_unused]] JSVM_Value TestGetAndClearLastExceptionTest2(JSVM_Env env, JSVM_CallbackInfo info)
1131 {
1132     size_t argc = 1;
1133     JSVM_Value argv[1] = {nullptr};
1134     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1135 
1136     JSVM_Value rstValue = nullptr;
1137     JSVM_Status rstStatus = OH_JSVM_GetAndClearLastException(env, &rstValue);
1138     if (rstStatus != JSVM_OK) {
1139         OH_JSVM_ThrowError(env, nullptr,
1140             "TestGetAndClearLastExceptionTest2: OH_JSVM_GetAndClearLastException status Failed");
1141         return nullptr;
1142     }
1143 
1144     bool result = true;
1145     JSVM_Value value = nullptr;
1146     OH_JSVM_GetBoolean(env, result, &value);
1147     return value;
1148 }
1149 //result is nullptr
TestGetAndClearLastExceptionTest3(JSVM_Env env,JSVM_CallbackInfo info)1150 [[maybe_unused]] JSVM_Value TestGetAndClearLastExceptionTest3(JSVM_Env env, JSVM_CallbackInfo info)
1151 {
1152     size_t argc = 1;
1153     JSVM_Value argv[1] = {nullptr};
1154     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1155 
1156     JSVM_Status rstStatus = OH_JSVM_GetAndClearLastException(env, nullptr);
1157     if (rstStatus == JSVM_OK) {
1158         OH_JSVM_ThrowError(env, nullptr,
1159             "TestGetAndClearLastExceptionTest3: OH_JSVM_GetAndClearLastException status Failed");
1160         return nullptr;
1161     }
1162 
1163     bool result = true;
1164     JSVM_Value value = nullptr;
1165     OH_JSVM_GetBoolean(env, result, &value);
1166     return value;
1167 }
1168 //IsExceptionPending
1169 //result is not null,
TestIsExceptionPendingTest1(JSVM_Env env,JSVM_CallbackInfo info)1170 [[maybe_unused]] JSVM_Value TestIsExceptionPendingTest1(JSVM_Env env, JSVM_CallbackInfo info)
1171 {
1172     size_t argc = 1;
1173     JSVM_Value argv[1] = {nullptr};
1174     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1175     // throw error
1176     OH_JSVM_ThrowError(env, "create error code", "create error msg");
1177     bool bRst = false;
1178     JSVM_Status rstStatus = OH_JSVM_IsExceptionPending(env, &bRst);
1179     if (rstStatus != JSVM_OK) {
1180         OH_JSVM_ThrowError(env, nullptr, "TestIsExceptionPendingTest1: OH_JSVM_IsExceptionPending status Failed");
1181         return nullptr;
1182     }
1183     if (!bRst) {
1184         OH_JSVM_ThrowError(env, nullptr, "TestIsExceptionPendingTest1: OH_JSVM_IsExceptionPending result Failed");
1185     }
1186     JSVM_Value getAndClearValue = nullptr;
1187     JSVM_Status getAndClearErr = OH_JSVM_GetAndClearLastException(env, &getAndClearValue);
1188     if (getAndClearErr != JSVM_OK) {
1189         OH_JSVM_ThrowError(env, nullptr,
1190             "TestIsExceptionPendingTest1: OH_JSVM_GetAndClearLastException status Failed");
1191         return nullptr;
1192     }
1193 
1194     bool result = true;
1195     JSVM_Value value = nullptr;
1196     OH_JSVM_GetBoolean(env, result, &value);
1197     return value;
1198 }
1199 //result is not null
TestIsExceptionPendingTest2(JSVM_Env env,JSVM_CallbackInfo info)1200 [[maybe_unused]] JSVM_Value TestIsExceptionPendingTest2(JSVM_Env env, JSVM_CallbackInfo info)
1201 {
1202     size_t argc = 1;
1203     JSVM_Value argv[1] = {nullptr};
1204     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1205     // throw error
1206     OH_JSVM_ThrowError(env, "create error code", "create error msg");
1207 
1208     JSVM_Value rstErrorValue = nullptr;
1209     JSVM_Status rstStatus = OH_JSVM_GetAndClearLastException(env, &rstErrorValue);
1210     if (rstStatus != JSVM_OK) {
1211         OH_JSVM_ThrowError(env, nullptr,
1212             "TestIsExceptionPendingTest2: OH_JSVM_GetAndClearLastException status Failed");
1213         return nullptr;
1214     }
1215 
1216     bool bRst = false;
1217     JSVM_Status rstPendingStatus = OH_JSVM_IsExceptionPending(env, &bRst);
1218     if (rstPendingStatus != JSVM_OK) {
1219         OH_JSVM_ThrowError(env, nullptr, "TestIsExceptionPendingTest2: OH_JSVM_IsExceptionPending status Failed");
1220         return nullptr;
1221     }
1222     if (bRst) {
1223         OH_JSVM_ThrowError(env, nullptr, "TestIsExceptionPendingTest2: OH_JSVM_IsExceptionPending result Failed");
1224     }
1225 
1226     bool result = true;
1227     JSVM_Value value = nullptr;
1228     OH_JSVM_GetBoolean(env, result, &value);
1229     return value;
1230 }
1231 //result is nullptr
TestIsExceptionPendingTest3(JSVM_Env env,JSVM_CallbackInfo info)1232 [[maybe_unused]] JSVM_Value TestIsExceptionPendingTest3(JSVM_Env env, JSVM_CallbackInfo info)
1233 {
1234     size_t argc = 1;
1235     JSVM_Value argv[1] = {nullptr};
1236     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1237 
1238     JSVM_Status rstStatus = OH_JSVM_IsExceptionPending(env, nullptr);
1239     if (rstStatus == JSVM_OK) {
1240         OH_JSVM_ThrowError(env, nullptr, "TestIsExceptionPendingTest3: OH_JSVM_IsExceptionPending status Failed");
1241         return nullptr;
1242     }
1243 
1244     bool result = true;
1245     JSVM_Value value = nullptr;
1246     OH_JSVM_GetBoolean(env, result, &value);
1247     return value;
1248 }
1249 //GetLastErrorInfo
1250 //result is not null
TestGetLastErrorInfoTest1(JSVM_Env env,JSVM_CallbackInfo info)1251 [[maybe_unused]] JSVM_Value TestGetLastErrorInfoTest1(JSVM_Env env, JSVM_CallbackInfo info)
1252 {
1253     size_t argc = 1;
1254     JSVM_Value argv[1] = {nullptr};
1255     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1256 
1257     int32_t rstInt = 0;
1258     JSVM_Status getErrStatus = OH_JSVM_GetValueInt32(env, argv[0], &rstInt);
1259     if (getErrStatus == JSVM_OK) {
1260         OH_JSVM_ThrowError(env, nullptr, "TestGetLastErrorInfoTest1: OH_JSVM_GetValueInt32 status Failed");
1261         return nullptr;
1262     }
1263 
1264     const JSVM_ExtendedErrorInfo* pError = nullptr;
1265     JSVM_Status rstStatus = OH_JSVM_GetLastErrorInfo(env, &pError);
1266     if (rstStatus != JSVM_OK) {
1267         OH_JSVM_ThrowError(env, nullptr, "TestGetLastErrorInfoTest1: OH_JSVM_GetLastErrorInfo status Failed");
1268         return nullptr;
1269     }
1270     if (pError->errorCode != getErrStatus) {
1271         OH_JSVM_ThrowError(env, nullptr, "TestGetLastErrorInfoTest1: OH_JSVM_GetLastErrorInfo errorCode Failed");
1272     }
1273 
1274     JSVM_Value getAndClearErr = nullptr;
1275     JSVM_Status getAndClearStatus = OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
1276     if (getAndClearStatus != JSVM_OK) {
1277         OH_JSVM_ThrowError(env, nullptr,
1278             "TestGetLastErrorInfoTest1: OH_JSVM_GetAndClearLastException status Failed");
1279         return nullptr;
1280     }
1281 
1282     bool result = true;
1283     JSVM_Value value = nullptr;
1284     OH_JSVM_GetBoolean(env, result, &value);
1285     return value;
1286 }
1287 //result is not null
TestGetLastErrorInfoTest2(JSVM_Env env,JSVM_CallbackInfo info)1288 [[maybe_unused]] JSVM_Value TestGetLastErrorInfoTest2(JSVM_Env env, JSVM_CallbackInfo info)
1289 {
1290     size_t argc = 1;
1291     JSVM_Value argv[1] = {nullptr};
1292     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1293 
1294     const JSVM_ExtendedErrorInfo* pError = nullptr;
1295     JSVM_Status rstStatus = OH_JSVM_GetLastErrorInfo(env, &pError);
1296     if (rstStatus != JSVM_OK) {
1297         OH_JSVM_ThrowError(env, nullptr, "TestGetLastErrorInfoTest2: OH_JSVM_GetLastErrorInfo status Failed");
1298         return nullptr;
1299     }
1300 
1301     bool result = true;
1302     JSVM_Value value = nullptr;
1303     OH_JSVM_GetBoolean(env, result, &value);
1304     return value;
1305 }
1306 //result is nullptr
TestGetLastErrorInfoTest3(JSVM_Env env,JSVM_CallbackInfo info)1307 [[maybe_unused]] JSVM_Value TestGetLastErrorInfoTest3(JSVM_Env env, JSVM_CallbackInfo info)
1308 {
1309     size_t argc = 1;
1310     JSVM_Value argv[1] = {nullptr};
1311     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1312 
1313     JSVM_Status rstStatus = OH_JSVM_GetLastErrorInfo(env, nullptr);
1314     if (rstStatus == JSVM_OK) {
1315         OH_JSVM_ThrowError(env, nullptr, "TestGetLastErrorInfoTest3: OH_JSVM_GetLastErrorInfo status Failed");
1316         return nullptr;
1317     }
1318 
1319     bool result = true;
1320     JSVM_Value value = nullptr;
1321     OH_JSVM_GetBoolean(env, result, &value);
1322     return value;
1323 }
1324 //CreateError-> isError->Throw
TestCombinationTest1(JSVM_Env env,JSVM_CallbackInfo info)1325 [[maybe_unused]] JSVM_Value TestCombinationTest1(JSVM_Env env, JSVM_CallbackInfo info)
1326 {
1327     const char* strErrCode = "create error code";
1328     JSVM_Value errorCode = nullptr;
1329     OH_JSVM_CreateStringUtf8(env, strErrCode, JSVM_AUTO_LENGTH, &errorCode);
1330 
1331     const char* strErrMsg = "create error Msg";
1332     JSVM_Value errorMsg = nullptr;
1333     OH_JSVM_CreateStringUtf8(env, strErrMsg, JSVM_AUTO_LENGTH, &errorMsg);
1334 
1335     JSVM_Value rstValue = nullptr;
1336     JSVM_Status creatStatus = OH_JSVM_CreateError(env, errorCode, errorMsg, &rstValue);
1337     if (creatStatus != JSVM_OK) {
1338         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest1: OH_JSVM_CreateError Failed");
1339         return nullptr;
1340     }
1341 
1342     bool bIsError = false;
1343     JSVM_Status rstStatus = OH_JSVM_IsError(env, rstValue, &bIsError);
1344     if (rstStatus != JSVM_OK) {
1345         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest1: OH_JSVM_IsError Failed");
1346         return nullptr;
1347     }
1348     if (!bIsError) {
1349         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest1: OH_JSVM_IsError Failed");
1350         return nullptr;
1351     }
1352 
1353     JSVM_Status rstThowStatus = OH_JSVM_Throw(env, rstValue);
1354     if (JSVM_OK != rstThowStatus) {
1355         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest1: OH_JSVM_Throw Failed");
1356         return nullptr;
1357     }
1358 
1359     const JSVM_ExtendedErrorInfo* pErrorInfo = nullptr;
1360     JSVM_Status rstExtendedStatus = OH_JSVM_GetLastErrorInfo(env, &pErrorInfo);
1361     if (JSVM_OK != rstExtendedStatus) {
1362         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest1: OH_JSVM_GetLastErrorInfo Failed");
1363         return nullptr;
1364     }
1365     if (pErrorInfo->errorCode != rstThowStatus) {
1366         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest1: OH_JSVM_GetLastErrorInfo errorCode Failed");
1367         return nullptr;
1368     }
1369     JSVM_Value getAndClearErr = nullptr;
1370     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
1371     if (getAndClearStatus != JSVM_OK) {
1372         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest1: OH_JSVM_GetAndClearLastException Failed");
1373         return nullptr;
1374     }
1375 
1376     bool result = true;
1377     JSVM_Value value = nullptr;
1378     OH_JSVM_GetBoolean(env, result, &value);
1379     return value;
1380 }
1381 //CreateTypeError-> isError->Throw
TestCombinationTest2(JSVM_Env env,JSVM_CallbackInfo info)1382 [[maybe_unused]] JSVM_Value TestCombinationTest2(JSVM_Env env, JSVM_CallbackInfo info)
1383 {
1384     const char* strErrCode = "create type error code";
1385     JSVM_Value errorCode = nullptr;
1386     OH_JSVM_CreateStringUtf8(env, strErrCode, JSVM_AUTO_LENGTH, &errorCode);
1387 
1388     const char* strErrMsg = "create type error message";
1389     JSVM_Value errorMsg = nullptr;
1390     OH_JSVM_CreateStringUtf8(env, strErrMsg, JSVM_AUTO_LENGTH, &errorMsg);
1391 
1392     JSVM_Value rstValue = nullptr;
1393     JSVM_Status creatStatus = OH_JSVM_CreateTypeError(env, errorCode, errorMsg, &rstValue);
1394     if (creatStatus != JSVM_OK) {
1395         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest2: OH_JSVM_CreateTypeError Failed");
1396         return nullptr;
1397     }
1398 
1399     bool bIsError = false;
1400     JSVM_Status rstStatus = OH_JSVM_IsError(env, rstValue, &bIsError);
1401     if (rstStatus != JSVM_OK) {
1402         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest2: OH_JSVM_IsError Failed");
1403         return nullptr;
1404     }
1405     if (!bIsError) {
1406         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest2: OH_JSVM_IsError Failed");
1407         return nullptr;
1408     }
1409 
1410     JSVM_Status rstThowStatus = OH_JSVM_Throw(env, rstValue);
1411     if (JSVM_OK != rstThowStatus) {
1412         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest2: OH_JSVM_Throw Failed");
1413         return nullptr;
1414     }
1415 
1416     const JSVM_ExtendedErrorInfo* pErrorInfo = nullptr;
1417     JSVM_Status rstExtendedStatus = OH_JSVM_GetLastErrorInfo(env, &pErrorInfo);
1418     if (JSVM_OK != rstExtendedStatus) {
1419         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest2: OH_JSVM_GetLastErrorInfo Failed");
1420         return nullptr;
1421     }
1422     if (pErrorInfo->errorCode != rstThowStatus) {
1423         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest2: OH_JSVM_GetLastErrorInfo errorCode Failed");
1424         return nullptr;
1425     }
1426     JSVM_Value getAndClearErr = nullptr;
1427     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
1428     if (getAndClearStatus != JSVM_OK) {
1429         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest2: OH_JSVM_GetAndClearLastException Failed");
1430         return nullptr;
1431     }
1432 
1433     bool result = true;
1434     JSVM_Value value = nullptr;
1435     OH_JSVM_GetBoolean(env, result, &value);
1436     return value;
1437 }
1438 //CreateRangeError-> isError->Throw
TestCombinationTest3(JSVM_Env env,JSVM_CallbackInfo info)1439 [[maybe_unused]] JSVM_Value TestCombinationTest3(JSVM_Env env, JSVM_CallbackInfo info)
1440 {
1441     const char* strErrRangeCode = "create Range error code";
1442     JSVM_Value errorRangeCode = nullptr;
1443     OH_JSVM_CreateStringUtf8(env, strErrRangeCode, JSVM_AUTO_LENGTH, &errorRangeCode);
1444     const char* strErrRangeMsg = "create Range error message";
1445     JSVM_Value errorRangeMsg = nullptr;
1446     OH_JSVM_CreateStringUtf8(env, strErrRangeMsg, JSVM_AUTO_LENGTH, &errorRangeMsg);
1447     JSVM_Value rstValue = nullptr;
1448     JSVM_Status creatStatus = OH_JSVM_CreateRangeError(env, errorRangeCode, errorRangeMsg, &rstValue);
1449     if (creatStatus != JSVM_OK) {
1450         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest3: OH_JSVM_CreateRangeError Failed");
1451         return nullptr;
1452     }
1453     bool bIsError = false;
1454     JSVM_Status rstStatus = OH_JSVM_IsError(env, rstValue, &bIsError);
1455     if (rstStatus != JSVM_OK) {
1456         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest3: OH_JSVM_IsError Failed");
1457         return nullptr;
1458     }
1459     if (!bIsError) {
1460         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest3: OH_JSVM_IsError Failed");
1461         return nullptr;
1462     }
1463     JSVM_Status rstThowStatus = OH_JSVM_Throw(env, rstValue);
1464     if (JSVM_OK != rstThowStatus) {
1465         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest3: OH_JSVM_Throw Failed");
1466         return nullptr;
1467     }
1468     const JSVM_ExtendedErrorInfo* pErrorInfo = nullptr;
1469     JSVM_Status rstExtendedStatus = OH_JSVM_GetLastErrorInfo(env, &pErrorInfo);
1470     if (JSVM_OK != rstExtendedStatus) {
1471         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest3: OH_JSVM_GetLastErrorInfo Failed");
1472         return nullptr;
1473     }
1474     if (pErrorInfo->errorCode != rstThowStatus) {
1475         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest3: OH_JSVM_GetLastErrorInfo errorCode Failed");
1476         return nullptr;
1477     }
1478     JSVM_Value getAndClearErr = nullptr;
1479     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
1480     if (getAndClearStatus != JSVM_OK) {
1481         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest3: OH_JSVM_GetAndClearLastException Failed");
1482         return nullptr;
1483     }
1484 
1485     bool result = true;
1486     JSVM_Value value = nullptr;
1487     OH_JSVM_GetBoolean(env, result, &value);
1488     return value;
1489 }
1490 //CreateSyntaxError-> isError->Throw
TestCombinationTest4(JSVM_Env env,JSVM_CallbackInfo info)1491 [[maybe_unused]] JSVM_Value TestCombinationTest4(JSVM_Env env, JSVM_CallbackInfo info)
1492 {
1493     const char* strErrSyntaxCode = "create Syntax error code";
1494     JSVM_Value errorSyntaxCode = nullptr;
1495     OH_JSVM_CreateStringUtf8(env, strErrSyntaxCode, JSVM_AUTO_LENGTH, &errorSyntaxCode);
1496 
1497     const char* strErrSyntaxMsg = "create Syntax error message";
1498     JSVM_Value errorSyntaxMsg = nullptr;
1499     OH_JSVM_CreateStringUtf8(env, strErrSyntaxMsg, JSVM_AUTO_LENGTH, &errorSyntaxMsg);
1500 
1501     JSVM_Value rstValue = nullptr;
1502     JSVM_Status creatStatus = OH_JSVM_CreateSyntaxError(env, errorSyntaxCode, errorSyntaxMsg, &rstValue);
1503     if (creatStatus != JSVM_OK) {
1504         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest4: OH_JSVM_CreateSyntaxError Failed");
1505         return nullptr;
1506     }
1507 
1508     bool bIsError = false;
1509     JSVM_Status rstStatus = OH_JSVM_IsError(env, rstValue, &bIsError);
1510     if (rstStatus != JSVM_OK) {
1511         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest4: OH_JSVM_IsError Failed");
1512         return nullptr;
1513     }
1514     if (!bIsError) {
1515         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest4: OH_JSVM_IsError Failed");
1516         return nullptr;
1517     }
1518 
1519     JSVM_Status rstThrowStatus = OH_JSVM_Throw(env, rstValue);
1520     if (JSVM_OK != rstThrowStatus) {
1521         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest4: OH_JSVM_Throw Failed");
1522         return nullptr;
1523     }
1524 
1525     const JSVM_ExtendedErrorInfo* pErrorInfo = nullptr;
1526     JSVM_Status rstExtendedStatus = OH_JSVM_GetLastErrorInfo(env, &pErrorInfo);
1527     if (JSVM_OK != rstExtendedStatus) {
1528         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest4: OH_JSVM_GetLastErrorInfo Failed");
1529         return nullptr;
1530     }
1531     if (pErrorInfo->errorCode != rstThrowStatus) {
1532         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest4: OH_JSVM_GetLastErrorInfo errorCode Failed");
1533         return nullptr;
1534     }
1535     JSVM_Value getAndClearErr = nullptr;
1536     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
1537     if (getAndClearStatus != JSVM_OK) {
1538         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest4: OH_JSVM_GetAndClearLastException Failed");
1539         return nullptr;
1540     }
1541 
1542     bool result = true;
1543     JSVM_Value value = nullptr;
1544     OH_JSVM_GetBoolean(env, result, &value);
1545     return value;
1546 }
1547 //ThrowError
TestCombinationTest5(JSVM_Env env,JSVM_CallbackInfo info)1548 [[maybe_unused]] JSVM_Value TestCombinationTest5(JSVM_Env env, JSVM_CallbackInfo info)
1549 {
1550     size_t argc = 1;
1551     JSVM_Value argv[1] = {nullptr};
1552     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1553 
1554     const char* strErrCode = "create error code";
1555     JSVM_Value errorCode = nullptr;
1556     OH_JSVM_CreateStringUtf8(env, strErrCode, JSVM_AUTO_LENGTH, &errorCode);
1557 
1558     const char* strErrMsg = "create error message";
1559     JSVM_Value errorMsg = nullptr;
1560     OH_JSVM_CreateStringUtf8(env, strErrMsg, JSVM_AUTO_LENGTH, &errorMsg);
1561 
1562     JSVM_Value rstValue = nullptr;
1563     JSVM_Status creatStatus = OH_JSVM_CreateError(env, errorCode, errorMsg, &rstValue);
1564     if (creatStatus != JSVM_OK) {
1565         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest5: OH_JSVM_CreateError Failed");
1566         return nullptr;
1567     }
1568 
1569     JSVM_Status rstThowStatus = OH_JSVM_ThrowError(env, "create error code", "create error message");
1570     if (JSVM_OK != rstThowStatus) {
1571         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest5: OH_JSVM_ThrowError Failed");
1572         return nullptr;
1573     }
1574 
1575     const JSVM_ExtendedErrorInfo* pErrorInfo = nullptr;
1576     JSVM_Status rstExtendedStatus = OH_JSVM_GetLastErrorInfo(env, &pErrorInfo);
1577     if (JSVM_OK != rstExtendedStatus) {
1578         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest5: OH_JSVM_GetLastErrorInfo Failed");
1579         return nullptr;
1580     }
1581     if (pErrorInfo->errorCode != rstThowStatus) {
1582         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest5: OH_JSVM_GetLastErrorInfo errorCode Failed");
1583         return nullptr;
1584     }
1585     JSVM_Value getAndClearErr = nullptr;
1586     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
1587     if (getAndClearStatus != JSVM_OK) {
1588         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest5: OH_JSVM_GetAndClearLastException Failed");
1589         return nullptr;
1590     }
1591 
1592     bool result = true;
1593     JSVM_Value value = nullptr;
1594     OH_JSVM_GetBoolean(env, result, &value);
1595     return value;
1596 }
1597 //ThrowTypeError
TestCombinationTest6(JSVM_Env env,JSVM_CallbackInfo info)1598 [[maybe_unused]] JSVM_Value TestCombinationTest6(JSVM_Env env, JSVM_CallbackInfo info)
1599 {
1600     size_t argc = 1;
1601     JSVM_Value argv[1] = {nullptr};
1602     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1603 
1604     const char* strErrTypeCode = "create type error code";
1605     JSVM_Value errorTypeCode = nullptr;
1606     OH_JSVM_CreateStringUtf8(env, strErrTypeCode, JSVM_AUTO_LENGTH, &errorTypeCode);
1607 
1608     const char* strErrTypeMsg = "create type error message";
1609     JSVM_Value errorTypeMsg = nullptr;
1610     OH_JSVM_CreateStringUtf8(env, strErrTypeMsg, JSVM_AUTO_LENGTH, &errorTypeMsg);
1611 
1612     JSVM_Value rstValue = nullptr;
1613     JSVM_Status creatStatus = OH_JSVM_CreateTypeError(env, errorTypeCode, errorTypeMsg, &rstValue);
1614     if (creatStatus != JSVM_OK) {
1615         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest6: OH_JSVM_CreateTypeError Failed");
1616         return nullptr;
1617     }
1618 
1619     JSVM_Status rstThowStatus = OH_JSVM_ThrowTypeError(env, "create type error code", "create type error message");
1620     if (JSVM_OK != rstThowStatus) {
1621         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest6: OH_JSVM_ThrowError Failed");
1622         return nullptr;
1623     }
1624 
1625     const JSVM_ExtendedErrorInfo* pErrorInfo = nullptr;
1626     JSVM_Status rstExtendedStatus = OH_JSVM_GetLastErrorInfo(env, &pErrorInfo);
1627     if (JSVM_OK != rstExtendedStatus) {
1628         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest6: OH_JSVM_GetLastErrorInfo Failed");
1629         return nullptr;
1630     }
1631     if (pErrorInfo->errorCode != rstThowStatus) {
1632         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest6: OH_JSVM_GetLastErrorInfo errorCode Failed");
1633         return nullptr;
1634     }
1635     JSVM_Value getAndClearErr = nullptr;
1636     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
1637     if (getAndClearStatus != JSVM_OK) {
1638         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest6: OH_JSVM_GetAndClearLastException Failed");
1639         return nullptr;
1640     }
1641 
1642     bool result = true;
1643     JSVM_Value value = nullptr;
1644     OH_JSVM_GetBoolean(env, result, &value);
1645     return value;
1646 }
1647 //ThrowRangeError
TestCombinationTest7(JSVM_Env env,JSVM_CallbackInfo info)1648 [[maybe_unused]] JSVM_Value TestCombinationTest7(JSVM_Env env, JSVM_CallbackInfo info)
1649 {
1650     size_t argc = 1;
1651     JSVM_Value argv[1] = {nullptr};
1652     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1653 
1654     const char* strErrRangCode = "create Range error code";
1655     JSVM_Value errorRangeCode = nullptr;
1656     OH_JSVM_CreateStringUtf8(env, strErrRangCode, JSVM_AUTO_LENGTH, &errorRangeCode);
1657 
1658     const char* strErrRangeMsg = "create Range error message";
1659     JSVM_Value errorRangeMsg = nullptr;
1660     OH_JSVM_CreateStringUtf8(env, strErrRangeMsg, JSVM_AUTO_LENGTH, &errorRangeMsg);
1661 
1662     JSVM_Value rstValue = nullptr;
1663     JSVM_Status creatStatus = OH_JSVM_CreateRangeError(env, errorRangeCode, errorRangeMsg, &rstValue);
1664     if (creatStatus != JSVM_OK) {
1665         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest7: OH_JSVM_CreateError Failed");
1666         return nullptr;
1667     }
1668 
1669     JSVM_Status rstThrowStatus = OH_JSVM_ThrowError(env, strErrRangCode, strErrRangeMsg);
1670     if (JSVM_OK != rstThrowStatus) {
1671         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest7: OH_JSVM_ThrowError Failed");
1672         return nullptr;
1673     }
1674 
1675     const JSVM_ExtendedErrorInfo* pErrorInfo = nullptr;
1676     JSVM_Status rstExtendedStatus = OH_JSVM_GetLastErrorInfo(env, &pErrorInfo);
1677     if (JSVM_OK != rstExtendedStatus) {
1678         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest7: OH_JSVM_GetLastErrorInfo Failed");
1679         return nullptr;
1680     }
1681     if (pErrorInfo->errorCode != rstThrowStatus) {
1682         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest7: OH_JSVM_GetLastErrorInfo errorCode Failed");
1683         return nullptr;
1684     }
1685     JSVM_Value getAndClearErr = nullptr;
1686     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
1687     if (getAndClearStatus != JSVM_OK) {
1688         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest7: OH_JSVM_GetAndClearLastException Failed");
1689         return nullptr;
1690     }
1691 
1692     bool result = true;
1693     JSVM_Value value = nullptr;
1694     OH_JSVM_GetBoolean(env, result, &value);
1695     return value;
1696 }
1697 //ThrowSyntaxError->
TestCombinationTest8(JSVM_Env env,JSVM_CallbackInfo info)1698 [[maybe_unused]] JSVM_Value TestCombinationTest8(JSVM_Env env, JSVM_CallbackInfo info)
1699 {
1700     size_t argc = 1;
1701     JSVM_Value argv[1] = {nullptr};
1702     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1703 
1704     const char* strErrSyntaxCode = "create Syntax error code";
1705     JSVM_Value errorSyntaxCode = nullptr;
1706     OH_JSVM_CreateStringUtf8(env, strErrSyntaxCode, JSVM_AUTO_LENGTH, &errorSyntaxCode);
1707 
1708     const char* strErrSyntaxMsg = "create Syntax error message";
1709     JSVM_Value errorSyntaxMsg = nullptr;
1710     OH_JSVM_CreateStringUtf8(env, strErrSyntaxMsg, JSVM_AUTO_LENGTH, &errorSyntaxMsg);
1711 
1712     JSVM_Value rstValue = nullptr;
1713     JSVM_Status creatStatus = OH_JSVM_CreateRangeError(env, errorSyntaxCode, errorSyntaxMsg, &rstValue);
1714     if (creatStatus != JSVM_OK) {
1715         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest8: OH_JSVM_CreateError Failed");
1716         return nullptr;
1717     }
1718 
1719     JSVM_Status rstThrowStatus = OH_JSVM_ThrowError(env, strErrSyntaxCode, strErrSyntaxMsg);
1720     if (JSVM_OK != rstThrowStatus) {
1721         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest8: OH_JSVM_ThrowError Failed");
1722         return nullptr;
1723     }
1724 
1725     const JSVM_ExtendedErrorInfo* pErrorInfo = nullptr;
1726     JSVM_Status rstExtendedStatus = OH_JSVM_GetLastErrorInfo(env, &pErrorInfo);
1727     if (JSVM_OK != rstExtendedStatus) {
1728         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest8: OH_JSVM_GetLastErrorInfo Failed");
1729         return nullptr;
1730     }
1731     if (pErrorInfo->errorCode != rstThrowStatus) {
1732         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest8: OH_JSVM_GetLastErrorInfo errorCode Failed");
1733         return nullptr;
1734     }
1735     JSVM_Value getAndClearErr = nullptr;
1736     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
1737     if (getAndClearStatus != JSVM_OK) {
1738         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest8: OH_JSVM_GetAndClearLastException Failed");
1739         return nullptr;
1740     }
1741 
1742     bool result = true;
1743     JSVM_Value value = nullptr;
1744     OH_JSVM_GetBoolean(env, result, &value);
1745     return value;
1746 }
1747 //CreateError-> isError->Throw->IsExceptionPending -> GetAndClearLastException
1748 //-> IsExceptionPending
TestCombinationTest9(JSVM_Env env,JSVM_CallbackInfo info)1749 [[maybe_unused]] JSVM_Value TestCombinationTest9(JSVM_Env env, JSVM_CallbackInfo info)
1750 {
1751     size_t argc = 1;
1752     JSVM_Value argv[1] = {nullptr};
1753     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1754 
1755     const char* strErrCode = "create error code";
1756     JSVM_Value errorCode = nullptr;
1757     OH_JSVM_CreateStringUtf8(env, strErrCode, JSVM_AUTO_LENGTH, &errorCode);
1758 
1759     const char* strErrMsg = "create error message";
1760     JSVM_Value errorMsg = nullptr;
1761     OH_JSVM_CreateStringUtf8(env, strErrMsg, JSVM_AUTO_LENGTH, &errorMsg);
1762 
1763     JSVM_Value rstValue = nullptr;
1764     JSVM_Status creatStatus = OH_JSVM_CreateError(env, errorCode, errorMsg, &rstValue);
1765     if (creatStatus != JSVM_OK) {
1766         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9: OH_JSVM_CreateError Failed");
1767         return nullptr;
1768     }
1769 
1770     bool bRstErr = false;
1771     JSVM_Status isErrStatus = OH_JSVM_IsError(env, rstValue, &bRstErr);
1772     if (JSVM_OK != isErrStatus) {
1773         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9: OH_JSVM_IsError Failed");
1774         return nullptr;
1775     }
1776 
1777     JSVM_Status rstThrowStatus = OH_JSVM_ThrowError(env, strErrCode, strErrMsg);
1778     if (JSVM_OK != rstThrowStatus) {
1779         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9: OH_JSVM_ThrowError Failed");
1780         return nullptr;
1781     }
1782 
1783     bool bRstPending = false;
1784     JSVM_Status rstPendingStatus = OH_JSVM_IsExceptionPending(env, &bRstPending);
1785     if (rstPendingStatus != JSVM_OK) {
1786         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9: OH_JSVM_IsExceptionPending status Failed");
1787         return nullptr;
1788     }
1789     if (!bRstPending) {
1790         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9: OH_JSVM_IsExceptionPending result Failed");
1791         return nullptr;
1792     }
1793 
1794     JSVM_Value rstGetValue = nullptr;
1795     JSVM_Status rstGetStatus = OH_JSVM_GetAndClearLastException(env, &rstGetValue);
1796     if (rstGetStatus != JSVM_OK) {
1797         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9: OH_JSVM_GetLastErrorInfo Failed");
1798         return nullptr;
1799     }
1800     JSVM_Value getErrorMsg = nullptr;
1801     JSVM_Status rstGetMsgStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "message", &getErrorMsg);
1802     if (rstGetMsgStatus != JSVM_OK) {
1803         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9: OH_JSVM_GetNamedProperty status Failed");
1804         return nullptr;
1805     }
1806     JSVM_Value getErrorCode = nullptr;
1807     JSVM_Status rstGetCodeStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "code", &getErrorCode);
1808     if (rstGetCodeStatus != JSVM_OK) {
1809         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9: OH_JSVM_GetNamedProperty status Failed");
1810         return nullptr;
1811     }
1812     char strGetErrMsg[ERROR_BUF_SIZE_MAX] = {0};
1813     JSVM_Status getStringMsgStatus = OH_JSVM_GetValueStringUtf8(env,
1814                                                                 getErrorMsg,
1815                                                                 strGetErrMsg,
1816                                                                 ERROR_BUF_SIZE_MAX,
1817                                                                 nullptr);
1818     if (getStringMsgStatus != JSVM_OK) {
1819         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9: OH_JSVM_GetValueStringUtf8 status Failed");
1820         return nullptr;
1821     }
1822     char strGetErrCode[ERROR_BUF_SIZE_MAX] = {0};
1823     JSVM_Status getStringCodeStatus = OH_JSVM_GetValueStringUtf8(env,
1824                                                                  getErrorCode,
1825                                                                  strGetErrCode,
1826                                                                  ERROR_BUF_SIZE_MAX,
1827                                                                  nullptr);
1828     if (getStringCodeStatus != JSVM_OK) {
1829         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9: OH_JSVM_GetValueStringUtf8 status Failed");
1830         return nullptr;
1831     }
1832     if (strcmp(strErrCode, strGetErrCode) != 0) {
1833         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9:  strcmp error code Failed");
1834         return nullptr;
1835     }
1836     if (strcmp(strErrMsg, strGetErrMsg) != 0) {
1837         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9:  strcmp error Msg Failed");
1838         return nullptr;
1839     }
1840 
1841     bool bRstPending2 = false;
1842     JSVM_Status rstPendingStatus2 = OH_JSVM_IsExceptionPending(env, &bRstPending2);
1843     if (rstPendingStatus2 != JSVM_OK) {
1844         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9: OH_JSVM_IsExceptionPending status Failed");
1845         return nullptr;
1846     }
1847     if (bRstPending2) {
1848         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest9: OH_JSVM_IsExceptionPending result Failed");
1849         return nullptr;
1850     }
1851 
1852     bool result = true;
1853     JSVM_Value value = nullptr;
1854     OH_JSVM_GetBoolean(env, result, &value);
1855     return value;
1856 }
1857 //CreateTypeError-> isError->Throw->IsExceptionPending-> GetAndClearLastException
1858 //-> IsExceptionPending
TestCombinationTest10(JSVM_Env env,JSVM_CallbackInfo info)1859 [[maybe_unused]] JSVM_Value TestCombinationTest10(JSVM_Env env, JSVM_CallbackInfo info)
1860 {
1861     size_t argc = 1;
1862     JSVM_Value argv[1] = {nullptr};
1863     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1864 
1865     const char* strErrTypeCode = "create error code";
1866     JSVM_Value errorTypeCode = nullptr;
1867     OH_JSVM_CreateStringUtf8(env, strErrTypeCode, JSVM_AUTO_LENGTH, &errorTypeCode);
1868 
1869     const char* strErrTypeMsg = "create error message";
1870     JSVM_Value errorTypeMsg = nullptr;
1871     OH_JSVM_CreateStringUtf8(env, strErrTypeMsg, JSVM_AUTO_LENGTH, &errorTypeMsg);
1872 
1873     JSVM_Value rstValue = nullptr;
1874     JSVM_Status creatStatus = OH_JSVM_CreateTypeError(env, errorTypeCode, errorTypeMsg, &rstValue);
1875     if (creatStatus != JSVM_OK) {
1876         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10: OH_JSVM_CreateTypeError Failed");
1877         return nullptr;
1878     }
1879 
1880     bool bRstErr = false;
1881     JSVM_Status isErrStatus = OH_JSVM_IsError(env, rstValue, &bRstErr);
1882     if (JSVM_OK != isErrStatus) {
1883         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10: OH_JSVM_IsError Failed");
1884         return nullptr;
1885     }
1886 
1887     JSVM_Status rstThrowStatus = OH_JSVM_ThrowTypeError(env, strErrTypeCode, strErrTypeMsg);
1888     if (JSVM_OK != rstThrowStatus) {
1889         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10: OH_JSVM_ThrowError Failed");
1890         return nullptr;
1891     }
1892 
1893     bool bRstPending = false;
1894     JSVM_Status rstPendingStatus = OH_JSVM_IsExceptionPending(env, &bRstPending);
1895     if (rstPendingStatus != JSVM_OK) {
1896         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10: OH_JSVM_IsExceptionPending status Failed");
1897         return nullptr;
1898     }
1899     if (!bRstPending) {
1900         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10: OH_JSVM_IsExceptionPending result Failed");
1901         return nullptr;
1902     }
1903 
1904     JSVM_Value rstGetValue = nullptr;
1905     JSVM_Status rstGetStatus = OH_JSVM_GetAndClearLastException(env, &rstGetValue);
1906     if (rstGetStatus != JSVM_OK) {
1907         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10: OH_JSVM_GetLastErrorInfo Failed");
1908         return nullptr;
1909     }
1910     JSVM_Value getErrorMsg = nullptr;
1911     JSVM_Status rstGetMsgStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "message", &getErrorMsg);
1912     if (rstGetMsgStatus != JSVM_OK) {
1913         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10: OH_JSVM_GetNamedProperty status Failed");
1914         return nullptr;
1915     }
1916     JSVM_Value getErrorCode = nullptr;
1917     JSVM_Status rstGetCodeStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "code", &getErrorCode);
1918     if (rstGetCodeStatus != JSVM_OK) {
1919         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10: OH_JSVM_GetNamedProperty status Failed");
1920         return nullptr;
1921     }
1922     char strGetErrMsg[ERROR_BUF_SIZE_MAX] = {0};
1923     JSVM_Status getStringMsgStatus = OH_JSVM_GetValueStringUtf8(env,
1924                                                                 getErrorMsg,
1925                                                                 strGetErrMsg,
1926                                                                 ERROR_BUF_SIZE_MAX,
1927                                                                 nullptr);
1928     if (getStringMsgStatus != JSVM_OK) {
1929         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10: OH_JSVM_GetValueStringUtf8 status Failed");
1930         return nullptr;
1931     }
1932     char strGetErrCode[ERROR_BUF_SIZE_MAX] = {0};
1933     JSVM_Status getStringCodeStatus = OH_JSVM_GetValueStringUtf8(env,
1934                                                                  getErrorCode,
1935                                                                  strGetErrCode,
1936                                                                  ERROR_BUF_SIZE_MAX,
1937                                                                  nullptr);
1938     if (getStringCodeStatus != JSVM_OK) {
1939         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10: OH_JSVM_GetValueStringUtf8 status Failed");
1940         return nullptr;
1941     }
1942     if (strcmp(strErrTypeCode, strGetErrCode) != 0) {
1943         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10:  strcmp error code Failed");
1944         return nullptr;
1945     }
1946     if (strcmp(strErrTypeMsg, strGetErrMsg) != 0) {
1947         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10:  strcmp error Msg Failed");
1948         return nullptr;
1949     }
1950 
1951     bool bRstPending2 = false;
1952     JSVM_Status rstPendingStatus2 = OH_JSVM_IsExceptionPending(env, &bRstPending2);
1953     if (rstPendingStatus2 != JSVM_OK) {
1954         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10: OH_JSVM_IsExceptionPending status Failed");
1955         return nullptr;
1956     }
1957     if (bRstPending2) {
1958         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest10: OH_JSVM_IsExceptionPending result Failed");
1959         return nullptr;
1960     }
1961 
1962     bool result = true;
1963     JSVM_Value value = nullptr;
1964     OH_JSVM_GetBoolean(env, result, &value);
1965     return value;
1966 }
1967 //CreateRangeError-> isError->Throw->IsExceptionPending -> GetAndClearLastException
1968 //-> IsExceptionPending
TestCombinationTest11(JSVM_Env env,JSVM_CallbackInfo info)1969 [[maybe_unused]] JSVM_Value TestCombinationTest11(JSVM_Env env, JSVM_CallbackInfo info)
1970 {
1971     size_t argc = 1;
1972     JSVM_Value argv[1] = {nullptr};
1973     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
1974 
1975     const char* strErrRangeCode = "create error code";
1976     JSVM_Value errorRangeCode = nullptr;
1977     OH_JSVM_CreateStringUtf8(env, strErrRangeCode, JSVM_AUTO_LENGTH, &errorRangeCode);
1978 
1979     const char* strErrRangeMsg = "create error message";
1980     JSVM_Value errorRangeMsg = nullptr;
1981     OH_JSVM_CreateStringUtf8(env, strErrRangeMsg, JSVM_AUTO_LENGTH, &errorRangeMsg);
1982 
1983     JSVM_Value rstValue = nullptr;
1984     JSVM_Status creatStatus = OH_JSVM_CreateTypeError(env, errorRangeCode, errorRangeMsg, &rstValue);
1985     if (creatStatus != JSVM_OK) {
1986         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11: OH_JSVM_CreateTypeError Failed");
1987         return nullptr;
1988     }
1989 
1990     bool bRstErr = false;
1991     JSVM_Status isErrStatus = OH_JSVM_IsError(env, rstValue, &bRstErr);
1992     if (JSVM_OK != isErrStatus) {
1993         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11: OH_JSVM_IsError Failed");
1994         return nullptr;
1995     }
1996 
1997     JSVM_Status rstThrowStatus = OH_JSVM_ThrowRangeError(env, strErrRangeCode, strErrRangeMsg);
1998     if (JSVM_OK != rstThrowStatus) {
1999         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11: OH_JSVM_ThrowRangeError Failed");
2000         return nullptr;
2001     }
2002 
2003     bool bRstPending = false;
2004     JSVM_Status rstPendingStatus = OH_JSVM_IsExceptionPending(env, &bRstPending);
2005     if (rstPendingStatus != JSVM_OK) {
2006         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11: OH_JSVM_IsExceptionPending status Failed");
2007         return nullptr;
2008     }
2009     if (!bRstPending) {
2010         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11: OH_JSVM_IsExceptionPending result Failed");
2011         return nullptr;
2012     }
2013 
2014     JSVM_Value rstGetValue = nullptr;
2015     JSVM_Status rstGetStatus = OH_JSVM_GetAndClearLastException(env, &rstGetValue);
2016     if (rstGetStatus != JSVM_OK) {
2017         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11: OH_JSVM_GetLastErrorInfo Failed");
2018         return nullptr;
2019     }
2020     JSVM_Value getErrorMsg = nullptr;
2021     JSVM_Status rstGetMsgStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "message", &getErrorMsg);
2022     if (rstGetMsgStatus != JSVM_OK) {
2023         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11: OH_JSVM_GetNamedProperty status Failed");
2024         return nullptr;
2025     }
2026     JSVM_Value getErrorCode = nullptr;
2027     JSVM_Status rstGetCodeStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "code", &getErrorCode);
2028     if (rstGetCodeStatus != JSVM_OK) {
2029         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11: OH_JSVM_GetNamedProperty status Failed");
2030         return nullptr;
2031     }
2032     char strGetErrMsg[ERROR_BUF_SIZE_MAX] = {0};
2033     JSVM_Status getStringMsgStatus = OH_JSVM_GetValueStringUtf8(env,
2034                                                                 getErrorMsg,
2035                                                                 strGetErrMsg,
2036                                                                 ERROR_BUF_SIZE_MAX,
2037                                                                 nullptr);
2038     if (getStringMsgStatus != JSVM_OK) {
2039         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11: OH_JSVM_GetValueStringUtf8 status Failed");
2040         return nullptr;
2041     }
2042     char strGetErrCode[ERROR_BUF_SIZE_MAX] = {0};
2043     JSVM_Status getStringCodeStatus = OH_JSVM_GetValueStringUtf8(env,
2044                                                                  getErrorCode,
2045                                                                  strGetErrCode,
2046                                                                  ERROR_BUF_SIZE_MAX,
2047                                                                  nullptr);
2048     if (getStringCodeStatus != JSVM_OK) {
2049         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11: OH_JSVM_GetValueStringUtf8 status Failed");
2050         return nullptr;
2051     }
2052     if (strcmp(strErrRangeCode, strGetErrCode) != 0) {
2053         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11:  strcmp error code Failed");
2054         return nullptr;
2055     }
2056     if (strcmp(strErrRangeMsg, strGetErrMsg) != 0) {
2057         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11:  strcmp error Msg Failed");
2058         return nullptr;
2059     }
2060 
2061     bool bRstPending2 = false;
2062     JSVM_Status rstPendingStatus2 = OH_JSVM_IsExceptionPending(env, &bRstPending2);
2063     if (rstPendingStatus2 != JSVM_OK) {
2064         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11: OH_JSVM_IsExceptionPending status Failed");
2065         return nullptr;
2066     }
2067     if (bRstPending2) {
2068         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest11: OH_JSVM_IsExceptionPending result Failed");
2069         return nullptr;
2070     }
2071 
2072     bool result = true;
2073     JSVM_Value value = nullptr;
2074     OH_JSVM_GetBoolean(env, result, &value);
2075     return value;
2076 }
2077 //ThrowSyntaxErrorr-> isError->Throw->IsExceptionPending -> GetAndClearLastException
2078 //-> IsExceptionPending
TestCombinationTest12(JSVM_Env env,JSVM_CallbackInfo info)2079 [[maybe_unused]] JSVM_Value TestCombinationTest12(JSVM_Env env, JSVM_CallbackInfo info)
2080 {
2081     size_t argc = 1;
2082     JSVM_Value argv[1] = {nullptr};
2083     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
2084 
2085     const char* strErrSyntaxCode = "create error code";
2086     JSVM_Value errorSyntaxCode = nullptr;
2087     OH_JSVM_CreateStringUtf8(env, strErrSyntaxCode, JSVM_AUTO_LENGTH, &errorSyntaxCode);
2088 
2089     const char* strErrSyntaxMsg = "create error message";
2090     JSVM_Value errorSyntaxMsg = nullptr;
2091     OH_JSVM_CreateStringUtf8(env, strErrSyntaxMsg, JSVM_AUTO_LENGTH, &errorSyntaxMsg);
2092 
2093     JSVM_Value rstValue = nullptr;
2094     JSVM_Status creatStatus = OH_JSVM_CreateSyntaxError(env, errorSyntaxCode, errorSyntaxMsg, &rstValue);
2095     if (creatStatus != JSVM_OK) {
2096         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12: OH_JSVM_CreateSyntaxError Failed");
2097         return nullptr;
2098     }
2099 
2100     bool bRstErr = false;
2101     JSVM_Status isErrStatus = OH_JSVM_IsError(env, rstValue, &bRstErr);
2102     if (JSVM_OK != isErrStatus) {
2103         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12: OH_JSVM_IsError Failed");
2104         return nullptr;
2105     }
2106 
2107     JSVM_Status rstThrowStatus = OH_JSVM_ThrowSyntaxError(env, strErrSyntaxCode, strErrSyntaxMsg);
2108     if (JSVM_OK != rstThrowStatus) {
2109         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12: OH_JSVM_ThrowSyntaxError Failed");
2110         return nullptr;
2111     }
2112 
2113     bool bRstPending = false;
2114     JSVM_Status rstPendingStatus = OH_JSVM_IsExceptionPending(env, &bRstPending);
2115     if (rstPendingStatus != JSVM_OK) {
2116         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12: OH_JSVM_IsExceptionPending status Failed");
2117         return nullptr;
2118     }
2119     if (!bRstPending) {
2120         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12: OH_JSVM_IsExceptionPending result Failed");
2121         return nullptr;
2122     }
2123 
2124     JSVM_Value rstGetValue = nullptr;
2125     JSVM_Status rstGetStatus = OH_JSVM_GetAndClearLastException(env, &rstGetValue);
2126     if (rstGetStatus != JSVM_OK) {
2127         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12: OH_JSVM_GetLastErrorInfo Failed");
2128         return nullptr;
2129     }
2130     JSVM_Value getErrorMsg = nullptr;
2131     JSVM_Status rstGetMsgStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "message", &getErrorMsg);
2132     if (rstGetMsgStatus != JSVM_OK) {
2133         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12: OH_JSVM_GetNamedProperty status Failed");
2134         return nullptr;
2135     }
2136     JSVM_Value getErrorCode = nullptr;
2137     JSVM_Status rstGetCodeStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "code", &getErrorCode);
2138     if (rstGetCodeStatus != JSVM_OK) {
2139         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12: OH_JSVM_GetNamedProperty status Failed");
2140         return nullptr;
2141     }
2142     char strGetErrMsg[ERROR_BUF_SIZE_MAX] = {0};
2143     JSVM_Status getStringMsgStatus = OH_JSVM_GetValueStringUtf8(env,
2144                                                                 getErrorMsg,
2145                                                                 strGetErrMsg,
2146                                                                 ERROR_BUF_SIZE_MAX,
2147                                                                 nullptr);
2148     if (getStringMsgStatus != JSVM_OK) {
2149         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12: OH_JSVM_GetValueStringUtf8 status Failed");
2150         return nullptr;
2151     }
2152     char strGetErrCode[ERROR_BUF_SIZE_MAX] = {0};
2153     JSVM_Status getStringCodeStatus = OH_JSVM_GetValueStringUtf8(env,
2154                                                                  getErrorCode,
2155                                                                  strGetErrCode,
2156                                                                  ERROR_BUF_SIZE_MAX,
2157                                                                  nullptr);
2158     if (getStringCodeStatus != JSVM_OK) {
2159         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12: OH_JSVM_GetValueStringUtf8 status Failed");
2160         return nullptr;
2161     }
2162     if (strcmp(strErrSyntaxCode, strGetErrCode) != 0) {
2163         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12:  strcmp error code Failed");
2164         return nullptr;
2165     }
2166     if (strcmp(strErrSyntaxMsg, strGetErrMsg) != 0) {
2167         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12:  strcmp error Msg Failed");
2168         return nullptr;
2169     }
2170 
2171     bool bRstPending2 = false;
2172     JSVM_Status rstPendingStatus2 = OH_JSVM_IsExceptionPending(env, &bRstPending2);
2173     if (rstPendingStatus2 != JSVM_OK) {
2174         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12: OH_JSVM_IsExceptionPending status Failed");
2175         return nullptr;
2176     }
2177     if (bRstPending2) {
2178         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest12: OH_JSVM_IsExceptionPending result Failed");
2179         return nullptr;
2180     }
2181 
2182     bool result = true;
2183     JSVM_Value value = nullptr;
2184     OH_JSVM_GetBoolean(env, result, &value);
2185     return value;
2186 }
2187 //ThrowError->IsExceptionPending -> GetAndClearLastException-> IsExceptionPending
TestCombinationTest13(JSVM_Env env,JSVM_CallbackInfo info)2188 [[maybe_unused]] JSVM_Value TestCombinationTest13(JSVM_Env env, JSVM_CallbackInfo info)
2189 {
2190     size_t argc = 1;
2191     JSVM_Value argv[1] = {nullptr};
2192     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
2193 
2194     const char* strErrCode = "create error code";
2195     JSVM_Value errorCode = nullptr;
2196     OH_JSVM_CreateStringUtf8(env, strErrCode, JSVM_AUTO_LENGTH, &errorCode);
2197 
2198     const char* strErrMsg = "create error message";
2199     JSVM_Value errorMsg = nullptr;
2200     OH_JSVM_CreateStringUtf8(env, strErrMsg, JSVM_AUTO_LENGTH, &errorMsg);
2201 
2202     JSVM_Value rstValue = nullptr;
2203     JSVM_Status creatStatus = OH_JSVM_CreateError(env, errorCode, errorMsg, &rstValue);
2204     if (creatStatus != JSVM_OK) {
2205         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest13: OH_JSVM_CreateError Failed");
2206         return nullptr;
2207     }
2208 
2209     JSVM_Status rstThrowStatus = OH_JSVM_ThrowError(env, strErrCode, strErrMsg);
2210     if (JSVM_OK != rstThrowStatus) {
2211         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest13: OH_JSVM_ThrowError Failed");
2212         return nullptr;
2213     }
2214 
2215     bool bRstPending = false;
2216     JSVM_Status rstPendingStatus = OH_JSVM_IsExceptionPending(env, &bRstPending);
2217     if (rstPendingStatus != JSVM_OK) {
2218         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest13: OH_JSVM_IsExceptionPending status Failed");
2219         return nullptr;
2220     }
2221     if (!bRstPending) {
2222         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest13: OH_JSVM_IsExceptionPending result Failed");
2223         return nullptr;
2224     }
2225 
2226     JSVM_Value rstGetValue = nullptr;
2227     JSVM_Status rstGetStatus = OH_JSVM_GetAndClearLastException(env, &rstGetValue);
2228     if (rstGetStatus != JSVM_OK) {
2229         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest13: OH_JSVM_GetLastErrorInfo Failed");
2230         return nullptr;
2231     }
2232     JSVM_Value getErrorMsg = nullptr;
2233     JSVM_Status rstGetMsgStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "message", &getErrorMsg);
2234     if (rstGetMsgStatus != JSVM_OK) {
2235         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest13: OH_JSVM_GetNamedProperty status Failed");
2236         return nullptr;
2237     }
2238     JSVM_Value getErrorCode = nullptr;
2239     JSVM_Status rstGetCodeStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "code", &getErrorCode);
2240     if (rstGetCodeStatus != JSVM_OK) {
2241         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest13: OH_JSVM_GetNamedProperty status Failed");
2242         return nullptr;
2243     }
2244     char strGetErrMsg[ERROR_BUF_SIZE_MAX] = {0};
2245     JSVM_Status getStringMsgStatus = OH_JSVM_GetValueStringUtf8(env,
2246                                                                 getErrorMsg,
2247                                                                 strGetErrMsg,
2248                                                                 ERROR_BUF_SIZE_MAX,
2249                                                                 nullptr);
2250     if (getStringMsgStatus != JSVM_OK) {
2251         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest13: OH_JSVM_GetValueStringUtf8 status Failed");
2252         return nullptr;
2253     }
2254     char strGetErrCode[ERROR_BUF_SIZE_MAX] = {0};
2255     JSVM_Status getStringCodeStatus = OH_JSVM_GetValueStringUtf8(env,
2256                                                                  getErrorCode,
2257                                                                  strGetErrCode,
2258                                                                  ERROR_BUF_SIZE_MAX,
2259                                                                  nullptr);
2260     if (getStringCodeStatus != JSVM_OK) {
2261         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest13: OH_JSVM_GetValueStringUtf8 status Failed");
2262         return nullptr;
2263     }
2264     if (strcmp(strErrCode, strGetErrCode) != 0) {
2265         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest13:  strcmp error code Failed");
2266         return nullptr;
2267     }
2268     if (strcmp(strErrMsg, strGetErrMsg) != 0) {
2269         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest13:  strcmp error Msg Failed");
2270         return nullptr;
2271     }
2272 
2273     bool bRstPending2 = false;
2274     JSVM_Status rstPendingStatus2 = OH_JSVM_IsExceptionPending(env, &bRstPending2);
2275     if (rstPendingStatus2 != JSVM_OK) {
2276         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest13: OH_JSVM_IsExceptionPending status Failed");
2277         return nullptr;
2278     }
2279     if (bRstPending2) {
2280         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest13: OH_JSVM_IsExceptionPending result Failed");
2281         return nullptr;
2282     }
2283 
2284     bool result = true;
2285     JSVM_Value value = nullptr;
2286     OH_JSVM_GetBoolean(env, result, &value);
2287     return value;
2288 }
2289 //ThrowTypeError->IsExceptionPending -> GetAndClearLastException-> IsExceptionPending
TestCombinationTest14(JSVM_Env env,JSVM_CallbackInfo info)2290 [[maybe_unused]] JSVM_Value TestCombinationTest14(JSVM_Env env, JSVM_CallbackInfo info)
2291 {
2292     size_t argc = 1;
2293     JSVM_Value argv[1] = {nullptr};
2294     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
2295 
2296     const char* strErrTypeCode = "create error code";
2297     JSVM_Value errorTypeCode = nullptr;
2298     OH_JSVM_CreateStringUtf8(env, strErrTypeCode, JSVM_AUTO_LENGTH, &errorTypeCode);
2299 
2300     const char* strErrTypeMsg = "create error message";
2301     JSVM_Value errorTypeMsg = nullptr;
2302     OH_JSVM_CreateStringUtf8(env, strErrTypeMsg, JSVM_AUTO_LENGTH, &errorTypeMsg);
2303 
2304     JSVM_Value rstValue = nullptr;
2305     JSVM_Status creatStatus = OH_JSVM_CreateTypeError(env, errorTypeCode, errorTypeMsg, &rstValue);
2306     if (creatStatus != JSVM_OK) {
2307         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest14: OH_JSVM_CreateTypeError Failed");
2308         return nullptr;
2309     }
2310 
2311     JSVM_Status rstThrowStatus = OH_JSVM_ThrowTypeError(env, strErrTypeCode, strErrTypeMsg);
2312     if (JSVM_OK != rstThrowStatus) {
2313         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest14: OH_JSVM_ThrowTypeError Failed");
2314         return nullptr;
2315     }
2316 
2317     bool bRstPending = false;
2318     JSVM_Status rstPendingStatus = OH_JSVM_IsExceptionPending(env, &bRstPending);
2319     if (rstPendingStatus != JSVM_OK) {
2320         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest14: OH_JSVM_IsExceptionPending status Failed");
2321         return nullptr;
2322     }
2323     if (!bRstPending) {
2324         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest14: OH_JSVM_IsExceptionPending result Failed");
2325         return nullptr;
2326     }
2327 
2328     JSVM_Value rstGetValue = nullptr;
2329     JSVM_Status rstGetStatus = OH_JSVM_GetAndClearLastException(env, &rstGetValue);
2330     if (rstGetStatus != JSVM_OK) {
2331         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest14: OH_JSVM_GetLastErrorInfo Failed");
2332         return nullptr;
2333     }
2334     JSVM_Value getErrorMsg = nullptr;
2335     JSVM_Status rstGetMsgStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "message", &getErrorMsg);
2336     if (rstGetMsgStatus != JSVM_OK) {
2337         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest14: OH_JSVM_GetNamedProperty status Failed");
2338         return nullptr;
2339     }
2340     JSVM_Value getErrorCode = nullptr;
2341     JSVM_Status rstGetCodeStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "code", &getErrorCode);
2342     if (rstGetCodeStatus != JSVM_OK) {
2343         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest14: OH_JSVM_GetNamedProperty status Failed");
2344         return nullptr;
2345     }
2346     char strGetErrMsg[ERROR_BUF_SIZE_MAX] = {0};
2347     JSVM_Status getStringMsgStatus = OH_JSVM_GetValueStringUtf8(env,
2348                                                                 getErrorMsg,
2349                                                                 strGetErrMsg,
2350                                                                 ERROR_BUF_SIZE_MAX,
2351                                                                 nullptr);
2352     if (getStringMsgStatus != JSVM_OK) {
2353         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest14: OH_JSVM_GetValueStringUtf8 status Failed");
2354         return nullptr;
2355     }
2356     char strGetErrCode[ERROR_BUF_SIZE_MAX] = {0};
2357     JSVM_Status getStringCodeStatus = OH_JSVM_GetValueStringUtf8(env,
2358                                                                  getErrorCode,
2359                                                                  strGetErrCode,
2360                                                                  ERROR_BUF_SIZE_MAX,
2361                                                                  nullptr);
2362     if (getStringCodeStatus != JSVM_OK) {
2363         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest14: OH_JSVM_GetValueStringUtf8 status Failed");
2364         return nullptr;
2365     }
2366     if (strcmp(strErrTypeCode, strGetErrCode) != 0) {
2367         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest14:  strcmp error code Failed");
2368         return nullptr;
2369     }
2370     if (strcmp(strErrTypeMsg, strGetErrMsg) != 0) {
2371         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest14:  strcmp error Msg Failed");
2372         return nullptr;
2373     }
2374 
2375     bool bRstPending2 = false;
2376     JSVM_Status rstPendingStatus2 = OH_JSVM_IsExceptionPending(env, &bRstPending2);
2377     if (rstPendingStatus2 != JSVM_OK) {
2378         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest14: OH_JSVM_IsExceptionPending status Failed");
2379         return nullptr;
2380     }
2381     if (bRstPending2) {
2382         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest14: OH_JSVM_IsExceptionPending result Failed");
2383         return nullptr;
2384     }
2385 
2386     bool result = true;
2387     JSVM_Value value = nullptr;
2388     OH_JSVM_GetBoolean(env, result, &value);
2389     return value;
2390 }
2391 //ThrowRangeError->IsExceptionPending-> GetAndClearLastException-> IsExceptionPending
TestCombinationTest15(JSVM_Env env,JSVM_CallbackInfo info)2392 [[maybe_unused]] JSVM_Value TestCombinationTest15(JSVM_Env env, JSVM_CallbackInfo info)
2393 {
2394     size_t argc = 1;
2395     JSVM_Value argv[1] = {nullptr};
2396     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
2397 
2398     const char* strErrRangeCode = "create error code";
2399     JSVM_Value errorRangeCode = nullptr;
2400     OH_JSVM_CreateStringUtf8(env, strErrRangeCode, JSVM_AUTO_LENGTH, &errorRangeCode);
2401 
2402     const char* strErrRangeMsg = "create error message";
2403     JSVM_Value errorRangeMsg = nullptr;
2404     OH_JSVM_CreateStringUtf8(env, strErrRangeMsg, JSVM_AUTO_LENGTH, &errorRangeMsg);
2405 
2406     JSVM_Value rstValue = nullptr;
2407     JSVM_Status creatStatus = OH_JSVM_CreateRangeError(env, errorRangeCode, errorRangeMsg, &rstValue);
2408     if (creatStatus != JSVM_OK) {
2409         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest15: OH_JSVM_CreateRangeError Failed");
2410         return nullptr;
2411     }
2412 
2413     JSVM_Status rstThrowStatus = OH_JSVM_ThrowRangeError(env, strErrRangeCode, strErrRangeMsg);
2414     if (JSVM_OK != rstThrowStatus) {
2415         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest15: OH_JSVM_ThrowRangeError Failed");
2416         return nullptr;
2417     }
2418 
2419     bool bRstPending = false;
2420     JSVM_Status rstPendingStatus = OH_JSVM_IsExceptionPending(env, &bRstPending);
2421     if (rstPendingStatus != JSVM_OK) {
2422         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest15: OH_JSVM_IsExceptionPending status Failed");
2423         return nullptr;
2424     }
2425     if (!bRstPending) {
2426         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest15: OH_JSVM_IsExceptionPending result Failed");
2427         return nullptr;
2428     }
2429 
2430     JSVM_Value rstGetValue = nullptr;
2431     JSVM_Status rstGetStatus = OH_JSVM_GetAndClearLastException(env, &rstGetValue);
2432     if (rstGetStatus != JSVM_OK) {
2433         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest15: OH_JSVM_GetLastErrorInfo Failed");
2434         return nullptr;
2435     }
2436     JSVM_Value getErrorMsg = nullptr;
2437     JSVM_Status rstGetMsgStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "message", &getErrorMsg);
2438     if (rstGetMsgStatus != JSVM_OK) {
2439         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest15: OH_JSVM_GetNamedProperty status Failed");
2440         return nullptr;
2441     }
2442     JSVM_Value getErrorCode = nullptr;
2443     JSVM_Status rstGetCodeStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "code", &getErrorCode);
2444     if (rstGetCodeStatus != JSVM_OK) {
2445         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest15: OH_JSVM_GetNamedProperty status Failed");
2446         return nullptr;
2447     }
2448     char strGetErrMsg[ERROR_BUF_SIZE_MAX] = {0};
2449     JSVM_Status getStringMsgStatus = OH_JSVM_GetValueStringUtf8(env,
2450                                                                 getErrorMsg,
2451                                                                 strGetErrMsg,
2452                                                                 ERROR_BUF_SIZE_MAX,
2453                                                                 nullptr);
2454     if (getStringMsgStatus != JSVM_OK) {
2455         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest15: OH_JSVM_GetValueStringUtf8 status Failed");
2456         return nullptr;
2457     }
2458     char strGetErrCode[ERROR_BUF_SIZE_MAX] = {0};
2459     JSVM_Status getStringCodeStatus = OH_JSVM_GetValueStringUtf8(env,
2460                                                                  getErrorCode,
2461                                                                  strGetErrCode,
2462                                                                  ERROR_BUF_SIZE_MAX,
2463                                                                  nullptr);
2464     if (getStringCodeStatus != JSVM_OK) {
2465         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest15: OH_JSVM_GetValueStringUtf8 status Failed");
2466         return nullptr;
2467     }
2468     if (strcmp(strErrRangeCode, strGetErrCode) != 0) {
2469         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest15:  strcmp error code Failed");
2470         return nullptr;
2471     }
2472     if (strcmp(strErrRangeMsg, strGetErrMsg) != 0) {
2473         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest15:  strcmp error Msg Failed");
2474         return nullptr;
2475     }
2476 
2477     bool bRstPending2 = false;
2478     JSVM_Status rstPendingStatus2 = OH_JSVM_IsExceptionPending(env, &bRstPending2);
2479     if (rstPendingStatus2 != JSVM_OK) {
2480         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest15: OH_JSVM_IsExceptionPending status Failed");
2481         return nullptr;
2482     }
2483     if (bRstPending2) {
2484         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest15: OH_JSVM_IsExceptionPending result Failed");
2485         return nullptr;
2486     }
2487 
2488     bool result = true;
2489     JSVM_Value value = nullptr;
2490     OH_JSVM_GetBoolean(env, result, &value);
2491     return value;
2492 }
2493 //ThrowSyntaxError->IsExceptionPending-> GetAndClearLastException-> IsExceptionPending
TestCombinationTest16(JSVM_Env env,JSVM_CallbackInfo info)2494 [[maybe_unused]] JSVM_Value TestCombinationTest16(JSVM_Env env, JSVM_CallbackInfo info)
2495 {
2496     size_t argc = 1;
2497     JSVM_Value argv[1] = {nullptr};
2498     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
2499 
2500     const char* strErrSyntaxCode = "create error code";
2501     JSVM_Value errorSyntaxCode = nullptr;
2502     OH_JSVM_CreateStringUtf8(env, strErrSyntaxCode, JSVM_AUTO_LENGTH, &errorSyntaxCode);
2503 
2504     const char* strErrSyntaxMsg = "create error message";
2505     JSVM_Value errorSyntaxMsg = nullptr;
2506     OH_JSVM_CreateStringUtf8(env, strErrSyntaxMsg, JSVM_AUTO_LENGTH, &errorSyntaxMsg);
2507 
2508     JSVM_Value rstValue = nullptr;
2509     JSVM_Status creatStatus = OH_JSVM_CreateSyntaxError(env, errorSyntaxCode, errorSyntaxMsg, &rstValue);
2510     if (creatStatus != JSVM_OK) {
2511         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest16: OH_JSVM_CreateSyntaxError Failed");
2512         return nullptr;
2513     }
2514 
2515     JSVM_Status rstThrowStatus = OH_JSVM_ThrowSyntaxError(env, strErrSyntaxCode, strErrSyntaxMsg);
2516     if (JSVM_OK != rstThrowStatus) {
2517         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest16: OH_JSVM_ThrowSyntaxError Failed");
2518         return nullptr;
2519     }
2520 
2521     bool bRstPending = false;
2522     JSVM_Status rstPendingStatus = OH_JSVM_IsExceptionPending(env, &bRstPending);
2523     if (rstPendingStatus != JSVM_OK) {
2524         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest16: OH_JSVM_IsExceptionPending status Failed");
2525         return nullptr;
2526     }
2527     if (!bRstPending) {
2528         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest16: OH_JSVM_IsExceptionPending result Failed");
2529         return nullptr;
2530     }
2531 
2532     JSVM_Value rstGetValue = nullptr;
2533     JSVM_Status rstGetStatus = OH_JSVM_GetAndClearLastException(env, &rstGetValue);
2534     if (rstGetStatus != JSVM_OK) {
2535         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest16: OH_JSVM_GetLastErrorInfo Failed");
2536         return nullptr;
2537     }
2538     JSVM_Value getErrorMsg = nullptr;
2539     JSVM_Status rstGetMsgStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "message", &getErrorMsg);
2540     if (rstGetMsgStatus != JSVM_OK) {
2541         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest16: OH_JSVM_GetNamedProperty status Failed");
2542         return nullptr;
2543     }
2544     JSVM_Value getErrorCode = nullptr;
2545     JSVM_Status rstGetCodeStatus = OH_JSVM_GetNamedProperty(env, rstGetValue, "code", &getErrorCode);
2546     if (rstGetCodeStatus != JSVM_OK) {
2547         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest16: OH_JSVM_GetNamedProperty status Failed");
2548         return nullptr;
2549     }
2550     char strGetErrMsg[ERROR_BUF_SIZE_MAX] = {0};
2551     JSVM_Status getStringMsgStatus = OH_JSVM_GetValueStringUtf8(env,
2552                                                                 getErrorMsg,
2553                                                                 strGetErrMsg,
2554                                                                 ERROR_BUF_SIZE_MAX,
2555                                                                 nullptr);
2556     if (getStringMsgStatus != JSVM_OK) {
2557         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest16: OH_JSVM_GetValueStringUtf8 status Failed");
2558         return nullptr;
2559     }
2560     char strGetErrCode[ERROR_BUF_SIZE_MAX] = {0};
2561     JSVM_Status getStringCodeStatus = OH_JSVM_GetValueStringUtf8(env,
2562                                                                  getErrorCode,
2563                                                                  strGetErrCode,
2564                                                                  ERROR_BUF_SIZE_MAX,
2565                                                                  nullptr);
2566     if (getStringCodeStatus != JSVM_OK) {
2567         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest16: OH_JSVM_GetValueStringUtf8 status Failed");
2568         return nullptr;
2569     }
2570     if (strcmp(strErrSyntaxCode, strGetErrCode) != 0) {
2571         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest16:  strcmp error code Failed");
2572         return nullptr;
2573     }
2574     if (strcmp(strErrSyntaxMsg, strGetErrMsg) != 0) {
2575         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest16:  strcmp error Msg Failed");
2576         return nullptr;
2577     }
2578 
2579     bool bRstPending2 = false;
2580     JSVM_Status rstPendingStatus2 = OH_JSVM_IsExceptionPending(env, &bRstPending2);
2581     if (rstPendingStatus2 != JSVM_OK) {
2582         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest16: OH_JSVM_IsExceptionPending status Failed");
2583         return nullptr;
2584     }
2585     if (bRstPending2) {
2586         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest16: OH_JSVM_IsExceptionPending result Failed");
2587         return nullptr;
2588     }
2589 
2590     bool result = true;
2591     JSVM_Value value = nullptr;
2592     OH_JSVM_GetBoolean(env, result, &value);
2593     return value;
2594 }
2595 //CreateError->GetAndClearLastException->isError
TestCombinationTest17(JSVM_Env env,JSVM_CallbackInfo info)2596 [[maybe_unused]] JSVM_Value TestCombinationTest17(JSVM_Env env, JSVM_CallbackInfo info)
2597 {
2598     size_t argc = 1;
2599     JSVM_Value argv[1] = {nullptr};
2600     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
2601 
2602     const char* strErrCode = "create error code";
2603     JSVM_Value errorCode = nullptr;
2604     OH_JSVM_CreateStringUtf8(env, strErrCode, JSVM_AUTO_LENGTH, &errorCode);
2605 
2606     const char* strErrMsg = "create error message";
2607     JSVM_Value errorMsg = nullptr;
2608     OH_JSVM_CreateStringUtf8(env, strErrMsg, JSVM_AUTO_LENGTH, &errorMsg);
2609 
2610     JSVM_Value rstValue = nullptr;
2611     JSVM_Status creatStatus = OH_JSVM_CreateError(env, errorCode, errorMsg, &rstValue);
2612     if (creatStatus != JSVM_OK) {
2613         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest17: OH_JSVM_CreateError Failed");
2614         return nullptr;
2615     }
2616 
2617     JSVM_Value rstErrorValue = nullptr;
2618     JSVM_Status rstStatus = OH_JSVM_GetAndClearLastException(env, &rstErrorValue);
2619     if (rstStatus != JSVM_OK) {
2620         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest17: OH_JSVM_GetAndClearLastException status Failed");
2621         return nullptr;
2622     }
2623 
2624     bool bRstErr = false;
2625     JSVM_Status isErrStatus = OH_JSVM_IsError(env, rstValue, &bRstErr);
2626     if (JSVM_OK != isErrStatus) {
2627         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest17: OH_JSVM_IsError status Failed");
2628         return nullptr;
2629     }
2630     if (!bRstErr) {
2631         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest17: OH_JSVM_IsError Failed");
2632         return nullptr;
2633     }
2634 
2635     bool result = true;
2636     JSVM_Value value = nullptr;
2637     OH_JSVM_GetBoolean(env, result, &value);
2638     return value;
2639 }
2640 //CreateTypeError->GetAndClearLastException->isError
TestCombinationTest18(JSVM_Env env,JSVM_CallbackInfo info)2641 [[maybe_unused]] JSVM_Value TestCombinationTest18(JSVM_Env env, JSVM_CallbackInfo info)
2642 {
2643     size_t argc = 1;
2644     JSVM_Value argv[1] = {nullptr};
2645     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
2646 
2647     const char* strErrTypeCode = "create error code";
2648     JSVM_Value errorTypeCode = nullptr;
2649     OH_JSVM_CreateStringUtf8(env, strErrTypeCode, JSVM_AUTO_LENGTH, &errorTypeCode);
2650 
2651     const char* strErrTypeMsg = "create error message";
2652     JSVM_Value errorTypeMsg = nullptr;
2653     OH_JSVM_CreateStringUtf8(env, strErrTypeMsg, JSVM_AUTO_LENGTH, &errorTypeMsg);
2654 
2655     JSVM_Value rstValue = nullptr;
2656     JSVM_Status creatStatus = OH_JSVM_CreateTypeError(env, errorTypeCode, errorTypeMsg, &rstValue);
2657     if (creatStatus != JSVM_OK) {
2658         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest18: OH_JSVM_CreateTypeError Failed");
2659         return nullptr;
2660     }
2661 
2662     JSVM_Value rstErrorValue = nullptr;
2663     JSVM_Status rstStatus = OH_JSVM_GetAndClearLastException(env, &rstErrorValue);
2664     if (rstStatus != JSVM_OK) {
2665         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest18: OH_JSVM_GetAndClearLastException status Failed");
2666         return nullptr;
2667     }
2668 
2669     bool bRstErr = false;
2670     JSVM_Status isErrStatus = OH_JSVM_IsError(env, rstValue, &bRstErr);
2671     if (JSVM_OK != isErrStatus) {
2672         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest18: OH_JSVM_IsError status Failed");
2673         return nullptr;
2674     }
2675     if (!bRstErr) {
2676         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest18: OH_JSVM_IsError Failed");
2677         return nullptr;
2678     }
2679 
2680     bool result = true;
2681     JSVM_Value value = nullptr;
2682     OH_JSVM_GetBoolean(env, result, &value);
2683     return value;
2684 }
2685 //CreateRangeError->GetAndClearLastException->isError
TestCombinationTest19(JSVM_Env env,JSVM_CallbackInfo info)2686 [[maybe_unused]] JSVM_Value TestCombinationTest19(JSVM_Env env, JSVM_CallbackInfo info)
2687 {
2688     size_t argc = 1;
2689     JSVM_Value argv[1] = {nullptr};
2690     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
2691 
2692     const char* strErrRangeCode = "create error code";
2693     JSVM_Value errorRangeCode = nullptr;
2694     OH_JSVM_CreateStringUtf8(env, strErrRangeCode, JSVM_AUTO_LENGTH, &errorRangeCode);
2695 
2696     const char* strErrRangeMsg = "create error message";
2697     JSVM_Value errorRangeMsg = nullptr;
2698     OH_JSVM_CreateStringUtf8(env, strErrRangeMsg, JSVM_AUTO_LENGTH, &errorRangeMsg);
2699 
2700     JSVM_Value rstValue = nullptr;
2701     JSVM_Status creatStatus = OH_JSVM_CreateRangeError(env, errorRangeCode, errorRangeMsg, &rstValue);
2702     if (creatStatus != JSVM_OK) {
2703         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest19: OH_JSVM_CreateRangeError Failed");
2704         return nullptr;
2705     }
2706 
2707     JSVM_Value rstErrorValue = nullptr;
2708     JSVM_Status rstStatus = OH_JSVM_GetAndClearLastException(env, &rstErrorValue);
2709     if (rstStatus != JSVM_OK) {
2710         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest19: OH_JSVM_GetAndClearLastException status Failed");
2711         return nullptr;
2712     }
2713 
2714     bool bRstErr = false;
2715     JSVM_Status isErrStatus = OH_JSVM_IsError(env, rstValue, &bRstErr);
2716     if (JSVM_OK != isErrStatus) {
2717         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest19: OH_JSVM_IsError status Failed");
2718         return nullptr;
2719     }
2720     if (!bRstErr) {
2721         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest19: OH_JSVM_IsError Failed");
2722         return nullptr;
2723     }
2724 
2725     bool result = true;
2726     JSVM_Value value = nullptr;
2727     OH_JSVM_GetBoolean(env, result, &value);
2728     return value;
2729 }
2730 //CreateSyntaxErrorr->GetAndClearLastException->isError
TestCombinationTest20(JSVM_Env env,JSVM_CallbackInfo info)2731 [[maybe_unused]] JSVM_Value TestCombinationTest20(JSVM_Env env, JSVM_CallbackInfo info)
2732 {
2733     size_t argc = 1;
2734     JSVM_Value argv[1] = {nullptr};
2735     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
2736 
2737     const char* strErrSyntaxCode = "create error code";
2738     JSVM_Value errorSyntaxCode = nullptr;
2739     OH_JSVM_CreateStringUtf8(env, strErrSyntaxCode, JSVM_AUTO_LENGTH, &errorSyntaxCode);
2740 
2741     const char* strErrSyntaxMsg = "create error message";
2742     JSVM_Value errorSyntaxMsg = nullptr;
2743     OH_JSVM_CreateStringUtf8(env, strErrSyntaxMsg, JSVM_AUTO_LENGTH, &errorSyntaxMsg);
2744 
2745     JSVM_Value rstValue = nullptr;
2746     JSVM_Status creatStatus = OH_JSVM_CreateSyntaxError(env, errorSyntaxCode, errorSyntaxMsg, &rstValue);
2747     if (creatStatus != JSVM_OK) {
2748         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest20: OH_JSVM_CreateSyntaxError Failed");
2749         return nullptr;
2750     }
2751 
2752     JSVM_Value rstErrorValue = nullptr;
2753     JSVM_Status rstStatus = OH_JSVM_GetAndClearLastException(env, &rstErrorValue);
2754     if (rstStatus != JSVM_OK) {
2755         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest20: OH_JSVM_GetAndClearLastException status Failed");
2756         return nullptr;
2757     }
2758 
2759     bool bRstErr = false;
2760     JSVM_Status isErrStatus = OH_JSVM_IsError(env, rstValue, &bRstErr);
2761     if (JSVM_OK != isErrStatus) {
2762         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest20: OH_JSVM_IsError status Failed");
2763         return nullptr;
2764     }
2765     if (!bRstErr) {
2766         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest20: OH_JSVM_IsError Failed");
2767         return nullptr;
2768     }
2769 
2770     bool result = true;
2771     JSVM_Value value = nullptr;
2772     OH_JSVM_GetBoolean(env, result, &value);
2773     return value;
2774 }
2775 //ThrowError->ThrowTypeError->IsExceptionPending-> GetAndClearLastException-> IsExceptionPending
TestCombinationTest21(JSVM_Env env,JSVM_CallbackInfo info)2776 [[maybe_unused]] JSVM_Value TestCombinationTest21(JSVM_Env env, JSVM_CallbackInfo info)
2777 {
2778     size_t argc = 1;
2779     JSVM_Value argv[1] = {nullptr};
2780     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
2781 
2782     // create Error
2783     const char* strErrCode = "create error code";
2784     JSVM_Value errorCode = nullptr;
2785     OH_JSVM_CreateStringUtf8(env, strErrCode, JSVM_AUTO_LENGTH, &errorCode);
2786 
2787     const char* strErrMsg = "create error message";
2788     JSVM_Value errorMsg = nullptr;
2789     OH_JSVM_CreateStringUtf8(env, strErrMsg, JSVM_AUTO_LENGTH, &errorMsg);
2790 
2791     JSVM_Value rstValue = nullptr;
2792     JSVM_Status creatStatus = OH_JSVM_CreateError(env, errorCode, errorMsg, &rstValue);
2793     if (creatStatus != JSVM_OK) {
2794         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest21: OH_JSVM_CreateError Failed");
2795         return nullptr;
2796     }
2797 
2798     // create type Error
2799     const char* strErrTypeCode = "create type error code";
2800     JSVM_Value errorTypeCode = nullptr;
2801     OH_JSVM_CreateStringUtf8(env, strErrTypeCode, JSVM_AUTO_LENGTH, &errorTypeCode);
2802 
2803     const char* strErrTypeMsg = "create type error message";
2804     JSVM_Value errorTypeMsg = nullptr;
2805     OH_JSVM_CreateStringUtf8(env, strErrTypeMsg, JSVM_AUTO_LENGTH, &errorTypeMsg);
2806 
2807     JSVM_Value rstTypeValue = nullptr;
2808     JSVM_Status creatTypeStatus = OH_JSVM_CreateTypeError(env, errorTypeCode, errorTypeMsg, &rstTypeValue);
2809     if (creatTypeStatus != JSVM_OK) {
2810         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest21: OH_JSVM_CreateError Failed");
2811         return nullptr;
2812     }
2813     // throwError
2814     JSVM_Status throwStatus = OH_JSVM_ThrowError(env, strErrCode, strErrMsg);
2815     if (throwStatus != JSVM_OK) {
2816         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest21: OH_JSVM_ThrowError Failed");
2817         return nullptr;
2818     }
2819     //clear throw error
2820     JSVM_Value getAndClearErr = nullptr;
2821     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
2822     if (getAndClearStatus != JSVM_OK) {
2823         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest21: OH_JSVM_GetAndClearLastException Failed");
2824         return nullptr;
2825     }
2826     // throwTypeError
2827     JSVM_Status throwTypeStatus = OH_JSVM_ThrowTypeError(env, strErrTypeCode, strErrTypeMsg);
2828     if (throwTypeStatus != JSVM_OK) {
2829         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest21: OH_JSVM_ThrowTypeError Failed");
2830         return nullptr;
2831     }
2832 
2833     bool bRstPending = false;
2834     JSVM_Status rstPendingStatus = OH_JSVM_IsExceptionPending(env, &bRstPending);
2835     if (rstPendingStatus != JSVM_OK) {
2836         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest21: OH_JSVM_IsExceptionPending status Failed");
2837         return nullptr;
2838     }
2839     if (!bRstPending) {
2840         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest21: OH_JSVM_IsExceptionPending result Failed");
2841         return nullptr;
2842     }
2843 
2844     JSVM_Value rstErrorValue = nullptr;
2845     JSVM_Status rstStatus = OH_JSVM_GetAndClearLastException(env, &rstErrorValue);
2846     if (rstStatus != JSVM_OK) {
2847         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest21: OH_JSVM_GetAndClearLastException status Failed");
2848         return nullptr;
2849     }
2850 
2851     bool bRstPending2 = false;
2852     JSVM_Status rstPendingStatus2 = OH_JSVM_IsExceptionPending(env, &bRstPending2);
2853     if (rstPendingStatus2 != JSVM_OK) {
2854         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest21: OH_JSVM_IsExceptionPending status2 Failed");
2855         return nullptr;
2856     }
2857     if (bRstPending2) {
2858         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest21: OH_JSVM_IsExceptionPending result2 Failed");
2859         return nullptr;
2860     }
2861 
2862     bool result = true;
2863     JSVM_Value value = nullptr;
2864     OH_JSVM_GetBoolean(env, result, &value);
2865     return value;
2866 }
2867 //ThrowRangeError->ThrowSyntaxError->IsExceptionPending-> GetAndClearLastException-> IsExceptionPending
TestCombinationTest22(JSVM_Env env,JSVM_CallbackInfo info)2868 [[maybe_unused]] JSVM_Value TestCombinationTest22(JSVM_Env env, JSVM_CallbackInfo info)
2869 {
2870     size_t argc = 1;
2871     JSVM_Value argv[1] = {nullptr};
2872     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
2873 
2874     // create Range Error
2875     const char* strErrRangeCode = "create Range error code";
2876     JSVM_Value errorRangeCode = nullptr;
2877     OH_JSVM_CreateStringUtf8(env, strErrRangeCode, JSVM_AUTO_LENGTH, &errorRangeCode);
2878 
2879     const char* strErrRangeMsg = "create Syntax error message";
2880     JSVM_Value errorRangeMsg = nullptr;
2881     OH_JSVM_CreateStringUtf8(env, strErrRangeMsg, JSVM_AUTO_LENGTH, &errorRangeMsg);
2882 
2883     JSVM_Value rstRangeValue = nullptr;
2884     JSVM_Status creatRangeStatus = OH_JSVM_CreateRangeError(env, errorRangeCode, errorRangeMsg, &rstRangeValue);
2885     if (creatRangeStatus != JSVM_OK) {
2886         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest22: OH_JSVM_CreateRangeError Failed");
2887         return nullptr;
2888     }
2889 
2890     // create Syntax Error
2891     const char* strErrSyntaxCode = "create Syntax error code";
2892     JSVM_Value errorSyntaxCode = nullptr;
2893     OH_JSVM_CreateStringUtf8(env, strErrSyntaxCode, JSVM_AUTO_LENGTH, &errorSyntaxCode);
2894 
2895     const char* strErrSyntaxMsg = "create Syntax error message";
2896     JSVM_Value errorSyntaxMsg = nullptr;
2897     OH_JSVM_CreateStringUtf8(env, strErrSyntaxMsg, JSVM_AUTO_LENGTH, &errorSyntaxMsg);
2898 
2899     JSVM_Value rstSyntaxValue = nullptr;
2900     JSVM_Status creatSyntaxStatus = OH_JSVM_CreateSyntaxError(env, errorSyntaxCode, errorSyntaxMsg, &rstSyntaxValue);
2901     if (creatSyntaxStatus != JSVM_OK) {
2902         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest22: OH_JSVM_CreateSyntaxError Failed");
2903         return nullptr;
2904     }
2905     // throwRangeError
2906     JSVM_Status throwRangeStatus = OH_JSVM_ThrowRangeError(env, strErrRangeCode, strErrRangeMsg);
2907     if (throwRangeStatus != JSVM_OK) {
2908         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest22: OH_JSVM_ThrowError Failed");
2909         return nullptr;
2910     }
2911     //clear throw error
2912     JSVM_Value getAndClearErr = nullptr;
2913     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
2914     if (getAndClearStatus != JSVM_OK) {
2915         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest22: OH_JSVM_GetAndClearLastException Failed");
2916         return nullptr;
2917     }
2918     // throwSyntaxError
2919     JSVM_Status throwSyntaxStatus = OH_JSVM_ThrowSyntaxError(env, strErrSyntaxCode, strErrSyntaxMsg);
2920     if (throwSyntaxStatus != JSVM_OK) {
2921         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest22: OH_JSVM_ThrowTypeError Failed");
2922         return nullptr;
2923     }
2924 
2925     bool bRstPending = false;
2926     JSVM_Status rstPendingStatus = OH_JSVM_IsExceptionPending(env, &bRstPending);
2927     if (rstPendingStatus != JSVM_OK) {
2928         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest22: OH_JSVM_IsExceptionPending status Failed");
2929         return nullptr;
2930     }
2931     if (!bRstPending) {
2932         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest22: OH_JSVM_IsExceptionPending result Failed");
2933         return nullptr;
2934     }
2935 
2936     JSVM_Value rstErrorValue = nullptr;
2937     JSVM_Status rstStatus = OH_JSVM_GetAndClearLastException(env, &rstErrorValue);
2938     if (rstStatus != JSVM_OK) {
2939         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest22: OH_JSVM_GetAndClearLastException status Failed");
2940         return nullptr;
2941     }
2942 
2943     bool bRstPending2 = false;
2944     JSVM_Status rstPendingStatus2 = OH_JSVM_IsExceptionPending(env, &bRstPending2);
2945     if (rstPendingStatus2 != JSVM_OK) {
2946         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest22: OH_JSVM_IsExceptionPending status2 Failed");
2947         return nullptr;
2948     }
2949     if (bRstPending2) {
2950         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest22: OH_JSVM_IsExceptionPending result2 Failed");
2951         return nullptr;
2952     }
2953 
2954     bool result = true;
2955     JSVM_Value value = nullptr;
2956     OH_JSVM_GetBoolean(env, result, &value);
2957     return value;
2958 }
2959 //ThrowTypeError->ThrowRangeError->ThrowError->ThrowSyntaxError->IsExceptionPending
2960 //->four GetAndClearLastException ->IsExceptionPending
TestCombinationTest23(JSVM_Env env,JSVM_CallbackInfo info)2961 [[maybe_unused]] JSVM_Value TestCombinationTest23(JSVM_Env env, JSVM_CallbackInfo info)
2962 {
2963     size_t argc = 1;
2964     JSVM_Value argv[1] = {nullptr};
2965     OH_JSVM_GetCbInfo(env, info, &argc, argv, nullptr, nullptr);
2966 
2967     // create Error
2968     const char* strErrCode = "create error code";
2969     JSVM_Value errorCode = nullptr;
2970     OH_JSVM_CreateStringUtf8(env, strErrCode, JSVM_AUTO_LENGTH, &errorCode);
2971 
2972     const char* strErrMsg = "create error message";
2973     JSVM_Value errorMsg = nullptr;
2974     OH_JSVM_CreateStringUtf8(env, strErrMsg, JSVM_AUTO_LENGTH, &errorMsg);
2975 
2976     JSVM_Value rstValue = nullptr;
2977     OH_JSVM_CreateError(env, errorCode, errorMsg, &rstValue);
2978 
2979     // create type Error
2980     const char* strErrTypeCode = "create type error code";
2981     JSVM_Value errorTypeCode = nullptr;
2982     OH_JSVM_CreateStringUtf8(env, strErrTypeCode, JSVM_AUTO_LENGTH, &errorTypeCode);
2983 
2984     const char* strErrTypeMsg = "create type error message";
2985     JSVM_Value errorTypeMsg = nullptr;
2986     OH_JSVM_CreateStringUtf8(env, strErrTypeMsg, JSVM_AUTO_LENGTH, &errorTypeMsg);
2987 
2988     JSVM_Value rstTypeValue = nullptr;
2989     JSVM_Status creatTypeStatus = OH_JSVM_CreateTypeError(env, errorTypeCode, errorTypeMsg, &rstTypeValue);
2990     if (creatTypeStatus != JSVM_OK) {
2991         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_CreateError Failed");
2992         return nullptr;
2993     }
2994 
2995     // create Range Error
2996     const char* strErrRangeCode = "create Range error code";
2997     JSVM_Value errorRangeCode = nullptr;
2998     OH_JSVM_CreateStringUtf8(env, strErrRangeCode, JSVM_AUTO_LENGTH, &errorRangeCode);
2999 
3000     const char* strErrRangeMsg = "create Syntax error message";
3001     JSVM_Value errorRangeMsg = nullptr;
3002     OH_JSVM_CreateStringUtf8(env, strErrRangeMsg, JSVM_AUTO_LENGTH, &errorRangeMsg);
3003 
3004     JSVM_Value rstRangeValue = nullptr;
3005     JSVM_Status creatRangeStatus = OH_JSVM_CreateRangeError(env, errorRangeCode, errorRangeMsg, &rstRangeValue);
3006     if (creatRangeStatus != JSVM_OK) {
3007         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_CreateRangeError Failed");
3008         return nullptr;
3009     }
3010 
3011     // create Syntax Error
3012     const char* strErrSyntaxCode = "create Syntax error code";
3013     JSVM_Value errorSyntaxCode = nullptr;
3014     OH_JSVM_CreateStringUtf8(env, strErrSyntaxCode, JSVM_AUTO_LENGTH, &errorSyntaxCode);
3015 
3016     const char* strErrSyntaxMsg = "create Syntax error message";
3017     JSVM_Value errorSyntaxMsg = nullptr;
3018     OH_JSVM_CreateStringUtf8(env, strErrSyntaxMsg, JSVM_AUTO_LENGTH, &errorSyntaxMsg);
3019 
3020     JSVM_Value rstSyntaxValue = nullptr;
3021     JSVM_Status creatSyntaxStatus = OH_JSVM_CreateSyntaxError(env, errorSyntaxCode, errorSyntaxMsg, &rstSyntaxValue);
3022     if (creatSyntaxStatus != JSVM_OK) {
3023         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_CreateSyntaxError Failed");
3024         return nullptr;
3025     }
3026 
3027     // throwTypeError
3028     JSVM_Status throwTypeStatus = OH_JSVM_ThrowTypeError(env, strErrTypeCode, strErrTypeMsg);
3029     if (throwTypeStatus != JSVM_OK) {
3030         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_ThrowTypeError Failed");
3031         return nullptr;
3032     }
3033     // clear throw type error
3034     JSVM_Value getAndClearTypeErr = nullptr;
3035     JSVM_Status getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearTypeErr);
3036     if (getAndClearStatus != JSVM_OK) {
3037         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_GetAndClearLastException Failed");
3038         return nullptr;
3039     }
3040     // throwRangeError
3041     JSVM_Status throwRangeStatus = OH_JSVM_ThrowRangeError(env, strErrRangeCode, strErrRangeMsg);
3042     if (throwRangeStatus != JSVM_OK) {
3043         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_ThrowError Failed");
3044         return nullptr;
3045     }
3046     //clear throw Range error
3047     JSVM_Value getAndClearRangeErr = nullptr;
3048     getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearRangeErr);
3049     if (getAndClearStatus != JSVM_OK) {
3050         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_GetAndClearLastException Failed");
3051         return nullptr;
3052     }
3053     // throwError
3054     JSVM_Status throwStatus = OH_JSVM_ThrowError(env, strErrCode, strErrMsg);
3055     if (throwStatus != JSVM_OK) {
3056         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_ThrowError Failed");
3057         return nullptr;
3058     }
3059     //clear throw Syntax error
3060     JSVM_Value getAndClearErr = nullptr;
3061     getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearErr);
3062     if (getAndClearStatus != JSVM_OK) {
3063         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_GetAndClearLastException Failed");
3064         return nullptr;
3065     }
3066     // throwSyntaxError
3067     JSVM_Status throwSyntaxStatus = OH_JSVM_ThrowSyntaxError(env, strErrSyntaxCode, strErrSyntaxMsg);
3068     if (throwSyntaxStatus != JSVM_OK) {
3069         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_ThrowTypeError Failed");
3070         return nullptr;
3071     }
3072     //clear throw Syntax error
3073     JSVM_Value getAndClearSyntaxErr = nullptr;
3074     getAndClearStatus =  OH_JSVM_GetAndClearLastException(env, &getAndClearSyntaxErr);
3075     if (getAndClearStatus != JSVM_OK) {
3076         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_GetAndClearLastException Failed");
3077         return nullptr;
3078     }
3079 
3080     bool bRstPending = false;
3081     JSVM_Status rstPendingStatus = OH_JSVM_IsExceptionPending(env, &bRstPending);
3082     if (rstPendingStatus != JSVM_OK) {
3083         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_IsExceptionPending status Failed");
3084         return nullptr;
3085     }
3086     if (bRstPending) {
3087         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_IsExceptionPending result Failed");
3088         return nullptr;
3089     }
3090 
3091     // first
3092     JSVM_Value rstErrorValue1 = nullptr;
3093     JSVM_Status rstStatus1 = OH_JSVM_GetAndClearLastException(env, &rstErrorValue1);
3094     if (rstStatus1 != JSVM_OK) {
3095         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_GetAndClearLastException status1 Failed");
3096         return nullptr;
3097     }
3098 
3099     // second
3100     JSVM_Value rstErrorValue2 = nullptr;
3101     JSVM_Status rstStatus2 = OH_JSVM_GetAndClearLastException(env, &rstErrorValue2);
3102     if (rstStatus2 != JSVM_OK) {
3103         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_GetAndClearLastException status2 Failed");
3104         return nullptr;
3105     }
3106 
3107     // third
3108     JSVM_Value rstErrorValue3 = nullptr;
3109     JSVM_Status rstStatus3 = OH_JSVM_GetAndClearLastException(env, &rstErrorValue3);
3110     if (rstStatus3 != JSVM_OK) {
3111         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_GetAndClearLastException status3 Failed");
3112         return nullptr;
3113     }
3114 
3115     // fourth
3116     JSVM_Value rstErrorValue4 = nullptr;
3117     JSVM_Status rstStatus4 = OH_JSVM_GetAndClearLastException(env, &rstErrorValue4);
3118     if (rstStatus4 != JSVM_OK) {
3119         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_GetAndClearLastException status4 Failed");
3120         return nullptr;
3121     }
3122 
3123     bool bRstPending2 = false;
3124     JSVM_Status rstPendingStatus2 = OH_JSVM_IsExceptionPending(env, &bRstPending2);
3125     if (rstPendingStatus2 != JSVM_OK) {
3126         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_IsExceptionPending status2 Failed");
3127         return nullptr;
3128     }
3129     if (bRstPending2) {
3130         OH_JSVM_ThrowError(env, nullptr, "TestCombinationTest23: OH_JSVM_IsExceptionPending result2 Failed");
3131         return nullptr;
3132     }
3133 
3134     bool result = true;
3135     JSVM_Value value = nullptr;
3136     OH_JSVM_GetBoolean(env, result, &value);
3137     return value;
3138 }