mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
fix(napi): improve napi_is_detached_arraybuffer (#17498)
This commit is contained in:
parent
2e1df62380
commit
b96bbc32c8
3 changed files with 45 additions and 5 deletions
|
@ -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 typedarray = loadTestLibrary();
|
||||
|
||||
|
@ -10,3 +10,15 @@ Deno.test("napi arraybuffer detach", function () {
|
|||
typedarray.test_detached(buf);
|
||||
assertEquals(buf.byteLength, 0);
|
||||
});
|
||||
|
||||
Deno.test("napi arraybuffer is detached", function () {
|
||||
const buf = new ArrayBuffer(5);
|
||||
assertEquals(buf.byteLength, 5);
|
||||
assert(!typedarray.is_detached(buf));
|
||||
typedarray.test_detached(buf);
|
||||
assert(typedarray.is_detached(buf));
|
||||
|
||||
[2, {}, "foo", null, undefined, new Uint8Array(10)].forEach((value) => {
|
||||
assert(!typedarray.is_detached(value));
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue