Skip to content

try-catch throw in eval function #182

Closed
@seanshpark

Description

@seanshpark

I'm not good at the spec. but seems that try-catch is not working correct.
test code added to test-api.cpp

diff --git a/tests/unit/test-api.cpp b/tests/unit/test-api.cpp
index 9636fd0..405aec5 100644
--- a/tests/unit/test-api.cpp
+++ b/tests/unit/test-api.cpp
@@ -456,6 +456,25 @@ main (void)

   jerry_api_release_value (&val_t);

+  // eval throw
+  const char *eval_code_err_p = "try{ throw new Error('error'); } catch(e) {print(e)}";
+  status = jerry_api_eval (eval_code_err_p,
+                           strlen (eval_code_err_p),
+                           false,
+                           true,
+                           &val_t);
+  JERRY_ASSERT (status == JERRY_COMPLETION_CODE_OK);
+
+  is_ok = jerry_api_call_function (val_t.v_object,
+                                   NULL,
+                                   &res,
+                                   NULL, 0);
+  JERRY_ASSERT (is_ok);
+  jerry_api_release_value (&res);
+
+  jerry_api_release_value (&val_t);
+
+
   // cleanup.
   jerry_api_release_object (global_obj_p);

expect is_ok to be true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions