aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-08-16 22:10:01 -0700
committerGravatar GitHub <noreply@github.com> 2023-08-16 22:10:01 -0700
commit6c3dabd84e98f6bbb3ce8d4885d1b2d0421df52b (patch)
treedd13e91707acb50160781bc6d77110cc30d27a83 /test
parentd4438e94964fb006b2939e269945f0e5825ced7d (diff)
downloadbun-6c3dabd84e98f6bbb3ce8d4885d1b2d0421df52b.tar.gz
bun-6c3dabd84e98f6bbb3ce8d4885d1b2d0421df52b.tar.zst
bun-6c3dabd84e98f6bbb3ce8d4885d1b2d0421df52b.zip
Fix leaking .ptr (#4181)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test')
-rw-r--r--test/js/bun/ffi/ffi.test.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/js/bun/ffi/ffi.test.js b/test/js/bun/ffi/ffi.test.js
index 5cefafaf8..80367e555 100644
--- a/test/js/bun/ffi/ffi.test.js
+++ b/test/js/bun/ffi/ffi.test.js
@@ -580,7 +580,8 @@ function ffiRunner(fast) {
}
it("read", () => {
- const buffer = new BigInt64Array(16);
+ // The usage of globalThis is a GC thing we should really fix
+ globalThis.buffer = new BigInt64Array(16);
const dataView = new DataView(buffer.buffer);
const addr = ptr(buffer);
@@ -607,6 +608,8 @@ it("read", () => {
expect(read.u32(addr, i)).toBe(dataView.getUint32(i, true));
expect(read.f32(addr, i)).toBe(dataView.getFloat32(i, true));
}
+
+ delete globalThis.buffer;
});
if (ok) {
@@ -631,3 +634,10 @@ it("dlopen throws an error instead of returning it", () => {
it('suffix does not start with a "."', () => {
expect(suffix).not.toMatch(/^\./);
});
+
+it(".ptr is not leaked", () => {
+ for (let fn of [Bun.password.hash, Bun.password.verify, it]) {
+ expect(fn).not.toHaveProperty("ptr");
+ expect(fn.ptr).toBeUndefined();
+ }
+});