Add testcase that cleanup error throw from javascript properly. (#4581)

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
This commit is contained in:
Yonggang Luo
2024-11-13 04:24:35 +08:00
committed by GitHub
parent 3f314f387d
commit 43f5026eb2
2 changed files with 49 additions and 2 deletions
+29 -1
View File
@@ -19,10 +19,38 @@
#define MODULE_NAME my_custom_module
static void
jobject_set_property_jval (jerry_value_t jobj, const char *name, jerry_value_t value)
{
jerry_value_t prop_name = jerry_string_sz (name);
jerry_value_t ret_val = jerry_object_set (jobj, prop_name, value);
jerry_value_free (prop_name);
jerry_value_free (ret_val);
} /* jobject_set_property_jval */
static jerry_value_t
call_function_with_callback (const jerry_call_info_t *call_info_p,
const jerry_value_t jargv[],
const jerry_length_t jargc)
{
(void) jargc;
jerry_value_t jval_func = jargv[0];
return jerry_call (jval_func, call_info_p->this_value, NULL, 0);
} /* call_function_with_callback */
static jerry_value_t
my_custom_module_on_resolve (void)
{
return jerry_number (42);
jerry_value_t mymodule = jerry_object ();
jerry_value_t val = jerry_number (42);
jobject_set_property_jval (mymodule, "number_value", val);
jerry_value_free (val);
jerry_value_t jfunc = jerry_function_external (call_function_with_callback);
jobject_set_property_jval (mymodule, "call_function_with_callback", jfunc);
jerry_value_free (jfunc);
return mymodule;
} /* my_custom_module_on_resolve */
JERRYX_NATIVE_MODULE (MODULE_NAME, my_custom_module_on_resolve)