summaryrefslogtreecommitdiff
path: root/test_napi/arraybuffer_test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test_napi/arraybuffer_test.js')
-rw-r--r--test_napi/arraybuffer_test.js14
1 files changed, 13 insertions, 1 deletions
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));
+ });
+});