summaryrefslogtreecommitdiff
path: root/test_napi/object_wrap_test.js
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2023-05-18 19:15:47 +0530
committerGitHub <noreply@github.com>2023-05-18 19:15:47 +0530
commitc3f7e6ed6ea2da6b8be5c7b29619eb51e0c9a6e3 (patch)
treedee07dbadf9dfe69bbfac707dde344f9528ef05a /test_napi/object_wrap_test.js
parent695b5de6cb0cb4a10b95cbae99f2f19e5621a9eb (diff)
fix(cli/napi): handle finalizers (#19168)
Fixes https://github.com/denoland/deno/issues/17325
Diffstat (limited to 'test_napi/object_wrap_test.js')
-rw-r--r--test_napi/object_wrap_test.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/test_napi/object_wrap_test.js b/test_napi/object_wrap_test.js
index ae64821ea..3466c39e4 100644
--- a/test_napi/object_wrap_test.js
+++ b/test_napi/object_wrap_test.js
@@ -1,6 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-import { assertEquals, loadTestLibrary } from "./common.js";
+import { assert, assertEquals, loadTestLibrary } from "./common.js";
const objectWrap = loadTestLibrary();
@@ -16,3 +16,26 @@ Deno.test("napi object wrap new", function () {
assertEquals(obj.get_value(), 10);
assertEquals(objectWrap.NapiObject.factory(), 64);
});
+
+Deno.test("napi bind finalizer", function () {
+ const obj = {};
+ objectWrap.test_bind_finalizer(obj);
+});
+
+Deno.test("napi external finalizer", function () {
+ let obj = objectWrap.test_external_finalizer();
+ assert(obj);
+ obj = null;
+});
+
+Deno.test("napi external buffer", function () {
+ let buf = objectWrap.test_external_buffer();
+ assertEquals(buf, new Uint8Array([1, 2, 3]));
+ buf = null;
+});
+
+Deno.test("napi external arraybuffer", function () {
+ let buf = objectWrap.test_external_arraybuffer();
+ assertEquals(new Uint8Array(buf), new Uint8Array([1, 2, 3]));
+ buf = null;
+});