summaryrefslogtreecommitdiff
path: root/tests/napi/callback_test.js
diff options
context:
space:
mode:
authorsnek <snek@deno.com>2024-10-16 12:30:19 +0200
committerGitHub <noreply@github.com>2024-10-16 10:30:19 +0000
commitea9c3ffaa240fc968832871000832eda1b92934a (patch)
treee646d5fb6ae7a84ff5889a2b5fad89e5bedcab59 /tests/napi/callback_test.js
parent2929d583d2f690b5a3d600296363a8ecd90440eb (diff)
fix: node-api function call should use preamble (#26297)
`napi_call_function` should use our equiv of NAPI_PREAMBLE (`&mut Env` instead of `*mut Env`) since it needs to set error codes based on whether the body of the function raised a JS exception. Fixes: https://github.com/denoland/deno/issues/26282
Diffstat (limited to 'tests/napi/callback_test.js')
-rw-r--r--tests/napi/callback_test.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/napi/callback_test.js b/tests/napi/callback_test.js
index 98622d48d..c132fefa1 100644
--- a/tests/napi/callback_test.js
+++ b/tests/napi/callback_test.js
@@ -1,6 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-import { assertEquals, loadTestLibrary } from "./common.js";
+import { assertEquals, assertThrows, loadTestLibrary } from "./common.js";
const callback = loadTestLibrary();
@@ -36,3 +36,12 @@ Deno.test("napi callback run with args & recv", function () {
);
assertEquals(result, 69);
});
+
+Deno.test("napi callback handles errors correctly", function () {
+ const e = new Error("hi!");
+ assertThrows(() => {
+ callback.test_callback_throws(() => {
+ throw e;
+ });
+ }, e);
+});