mirror of
https://github.com/denoland/deno.git
synced 2025-09-23 19:02:31 +00:00

Some checks are pending
ci / build libs (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
Fixes: https://github.com/denoland/deno/issues/30512
30 lines
923 B
JavaScript
30 lines
923 B
JavaScript
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
|
|
import { assert, assertEquals, loadTestLibrary } from "./common.js";
|
|
import { Buffer } from "node:buffer";
|
|
|
|
const typedarray = loadTestLibrary();
|
|
|
|
Deno.test("napi arraybuffer detach", function () {
|
|
const buf = new ArrayBuffer(5);
|
|
assertEquals(buf.byteLength, 5);
|
|
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));
|
|
});
|
|
});
|
|
|
|
Deno.test("napi buffer finalizer may be null", () => {
|
|
const buf = typedarray.test_static_external_buffer();
|
|
assertEquals(buf, Buffer.from([1, 2, 3]));
|
|
});
|