From b96bbc32c8a0828f997f6148111a31ec27ec08b1 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Mon, 23 Jan 2023 00:52:18 -0800 Subject: fix(napi): improve napi_is_detached_arraybuffer (#17498) --- test_napi/arraybuffer_test.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'test_napi/arraybuffer_test.js') diff --git a/test_napi/arraybuffer_test.js b/test_napi/arraybuffer_test.js index c08ffc7d6..3e4e3c6c1 100644 --- a/test_napi/arraybuffer_test.js +++ b/test_napi/arraybuffer_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 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)); + }); +}); -- cgit v1.2.3