aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/ffi.test.js
diff options
context:
space:
mode:
authorGravatar Zilin Zhu <zhuzilinallen@gmail.com> 2022-08-28 21:19:53 +0800
committerGravatar GitHub <noreply@github.com> 2022-08-28 06:19:53 -0700
commitce90e0c372f3e92b2a163d24018132aa2ce2ee6b (patch)
treec9c89bfed4f50838aa84361fe858afa79ca9259a /test/bun.js/ffi.test.js
parent296fb41e920736041c6c1dec38f1d8c355a402a1 (diff)
downloadbun-ce90e0c372f3e92b2a163d24018132aa2ce2ee6b.tar.gz
bun-ce90e0c372f3e92b2a163d24018132aa2ce2ee6b.tar.zst
bun-ce90e0c372f3e92b2a163d24018132aa2ce2ee6b.zip
support pass null as NULL ptr (#1160)
Diffstat (limited to 'test/bun.js/ffi.test.js')
-rw-r--r--test/bun.js/ffi.test.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/bun.js/ffi.test.js b/test/bun.js/ffi.test.js
index 424670b37..4e8ab42a7 100644
--- a/test/bun.js/ffi.test.js
+++ b/test/bun.js/ffi.test.js
@@ -206,6 +206,11 @@ function getTypes(fast) {
args: ["uint32_t", "uint32_t"],
},
+ is_null: {
+ returns: "bool",
+ args: ["ptr"],
+ },
+
does_pointer_equal_42_as_int32_t: {
returns: "bool",
args: ["ptr"],
@@ -339,6 +344,7 @@ function ffiRunner(fast) {
identity_ptr,
add_uint32_t,
add_uint64_t,
+ is_null,
does_pointer_equal_42_as_int32_t,
ptr_should_point_to_42_as_int32_t,
cb_identity_true,
@@ -460,6 +466,7 @@ function ffiRunner(fast) {
expect(add_uint16_t(1, 1)).toBe(2);
expect(add_uint32_t(1, 1)).toBe(2);
Bun.gc(true);
+ expect(is_null(null)).toBe(true);
const cptr = ptr_should_point_to_42_as_int32_t();
expect(cptr != 0).toBe(true);
expect(typeof cptr === "number").toBe(true);