aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/ffi.test.js
blob: bc3ac1f2ab2996d4564c9ca6aab6a54c720db971 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { describe, it, expect } from "bun:test";

it("ffi print", () => {
  Bun.dlprint({
    add: {
      params: ["int32_t", "int32_t"],
      return_type: "int32_t",
    },
  })[0];
});

it("ffi run", () => {
  const {
    symbols: { add },
    close,
  } = Bun.dlopen("/tmp/libffi-test.dylib", {
    add: {
      params: ["int32_t", "int32_t"],
      return_type: "int32_t",
    },
  });
  expect(add(1, 2)).toBe(3);
  close();
});
``;