diff options
author | snek <the@snek.dev> | 2024-06-10 09:20:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-10 16:20:44 +0000 |
commit | e3b2ee183bc7497ec0432bc764678f5eda6495a7 (patch) | |
tree | 7a5fa0208ef56cb83fa6bae9bad0bc89334ed533 /tests/napi | |
parent | 7c5dbd5d54770dba5e56442b633e9597403ef5da (diff) |
fix: Rewrite Node-API (#24101)
Phase 1 node-api rewrite
Diffstat (limited to 'tests/napi')
-rw-r--r-- | tests/napi/init_test.js | 3 | ||||
-rw-r--r-- | tests/napi/object_wrap_test.js | 3 | ||||
-rw-r--r-- | tests/napi/src/object_wrap.rs | 9 |
3 files changed, 6 insertions, 9 deletions
diff --git a/tests/napi/init_test.js b/tests/napi/init_test.js index 5f2507876..9db99d8a0 100644 --- a/tests/napi/init_test.js +++ b/tests/napi/init_test.js @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +import { Buffer } from "node:buffer"; import { assert, libSuffix } from "./common.js"; const ops = Deno[Deno.internal].core.ops; @@ -8,7 +9,7 @@ Deno.test("ctr initialization (napi_module_register)", { ignore: Deno.build.os == "windows", }, function () { const path = new URL(`./module.${libSuffix}`, import.meta.url).pathname; - const obj = ops.op_napi_open(path, {}); + const obj = ops.op_napi_open(path, {}, Buffer, reportError); assert(obj != null); assert(typeof obj === "object"); }); diff --git a/tests/napi/object_wrap_test.js b/tests/napi/object_wrap_test.js index f79fd08f8..de6391fb1 100644 --- a/tests/napi/object_wrap_test.js +++ b/tests/napi/object_wrap_test.js @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +import { Buffer } from "node:buffer"; import { assert, assertEquals, loadTestLibrary } from "./common.js"; const objectWrap = loadTestLibrary(); @@ -30,7 +31,7 @@ Deno.test("napi external finalizer", function () { Deno.test("napi external buffer", function () { let buf = objectWrap.test_external_buffer(); - assertEquals(buf, new Uint8Array([1, 2, 3])); + assertEquals(buf, new Buffer([1, 2, 3])); buf = null; }); diff --git a/tests/napi/src/object_wrap.rs b/tests/napi/src/object_wrap.rs index d04107cf0..8c29caec5 100644 --- a/tests/napi/src/object_wrap.rs +++ b/tests/napi/src/object_wrap.rs @@ -11,7 +11,6 @@ use std::ptr; pub struct NapiObject { counter: i32, - _wrapper: napi_ref, } impl NapiObject { @@ -33,18 +32,14 @@ impl NapiObject { assert_napi_ok!(napi_get_value_int32(env, args[0], &mut value)); - let mut wrapper: napi_ref = ptr::null_mut(); - let obj = Box::new(Self { - counter: value, - _wrapper: wrapper, - }); + let obj = Box::new(Self { counter: value }); assert_napi_ok!(napi_wrap( env, this, Box::into_raw(obj) as *mut c_void, None, ptr::null_mut(), - &mut wrapper, + ptr::null_mut(), )); return this; |