diff options
author | 2022-04-29 06:08:36 -0700 | |
---|---|---|
committer | 2022-04-29 06:08:36 -0700 | |
commit | 22f74756b4cf173749b2f72fdae438f8def24bd2 (patch) | |
tree | 7af47e7ee0ba1ab1bfc8a2ffd3672f9b5e6b58af /integration/bunjs-only-snippets/ffi.test.js | |
parent | f07463bdfdcdd312e0d2aaf2f73bb71646f5f8a3 (diff) | |
download | bun-22f74756b4cf173749b2f72fdae438f8def24bd2.tar.gz bun-22f74756b4cf173749b2f72fdae438f8def24bd2.tar.zst bun-22f74756b4cf173749b2f72fdae438f8def24bd2.zip |
[bun ffi] Support pointers
Diffstat (limited to 'integration/bunjs-only-snippets/ffi.test.js')
-rw-r--r-- | integration/bunjs-only-snippets/ffi.test.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/integration/bunjs-only-snippets/ffi.test.js b/integration/bunjs-only-snippets/ffi.test.js index 1a18ae2cd..cd51a4594 100644 --- a/integration/bunjs-only-snippets/ffi.test.js +++ b/integration/bunjs-only-snippets/ffi.test.js @@ -153,6 +153,16 @@ it("ffi run", () => { return_type: "uint32_t", params: ["uint32_t", "uint32_t"], }, + + does_pointer_equal_42_as_int32_t: { + return_type: "bool", + params: ["ptr"], + }, + + ptr_should_point_to_42_as_int32_t: { + return_type: "ptr", + params: [], + }, // add_uint64_t: { // return_type: "uint64_t", // params: ["uint64_t", "uint64_t"], @@ -197,6 +207,8 @@ it("ffi run", () => { add_uint16_t, add_uint32_t, add_uint64_t, + does_pointer_equal_42_as_int32_t, + ptr_should_point_to_42_as_int32_t, }, close, } = Bun.dlopen("/tmp/bun-ffi-test.dylib", types); @@ -236,6 +248,11 @@ it("ffi run", () => { expect(add_uint8_t(1, 1)).toBe(2); expect(add_uint16_t(1, 1)).toBe(2); expect(add_uint32_t(1, 1)).toBe(2); + + const ptr = ptr_should_point_to_42_as_int32_t(); + expect(ptr != 0).toBe(true); + expect(typeof ptr === "number").toBe(true); + expect(does_pointer_equal_42_as_int32_t(ptr)).toBe(true); // expect(add_uint64_t(1, 1)).toBe(2); close(); }); |