diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-01-23 00:52:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-23 14:22:18 +0530 |
commit | b96bbc32c8a0828f997f6148111a31ec27ec08b1 (patch) | |
tree | 0dfa87d40f79cd6e70da1efc9ea21c34ca0e670a /test_napi/arraybuffer_test.js | |
parent | 2e1df623804fd580d236d89d7277a28d66d7dddb (diff) |
fix(napi): improve napi_is_detached_arraybuffer (#17498)
Diffstat (limited to 'test_napi/arraybuffer_test.js')
-rw-r--r-- | test_napi/arraybuffer_test.js | 14 |
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)); + }); +}); |