aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/ffi.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js/ffi.test.js')
-rw-r--r--test/bun.js/ffi.test.js37
1 files changed, 26 insertions, 11 deletions
diff --git a/test/bun.js/ffi.test.js b/test/bun.js/ffi.test.js
index 6433f0161..65b29b788 100644
--- a/test/bun.js/ffi.test.js
+++ b/test/bun.js/ffi.test.js
@@ -509,12 +509,12 @@ function ffiRunner(fast) {
for (let [returnName, returnValue] of Object.entries(typeMap)) {
var roundtripFunction = new CFunction({
ptr: new JSCallback(
+ (input) => {
+ return input;
+ },
{
returns: returnName,
args: [returnName],
- },
- (input) => {
- return input;
}
).ptr,
returns: returnName,
@@ -525,12 +525,12 @@ function ffiRunner(fast) {
{
var toClose = new JSCallback(
+ (input) => {
+ return input;
+ },
{
returns: "bool",
args: ["bool"],
- },
- (input) => {
- return input;
}
);
expect(toClose.ptr > 0).toBe(true);
@@ -541,15 +541,30 @@ function ffiRunner(fast) {
// Return types, no args
for (let [name, value] of Object.entries(typeMap)) {
var roundtripFunction = new CFunction({
+ ptr: new JSCallback(() => value, {
+ returns: name,
+ }).ptr,
+ returns: name,
+ });
+ expect(roundtripFunction()).toBe(value);
+ }
+
+ // 1 arg, threadsafe
+ for (let [name, value] of Object.entries(typeMap)) {
+ var roundtripFunction = new CFunction({
ptr: new JSCallback(
- {
- returns: name,
+ (arg1) => {
+ expect(arg1).toBe(value);
},
- () => value
+ {
+ args: [name],
+ threadsafe: true,
+ }
).ptr,
- returns: name,
+ returns: "void",
+ args: [name],
});
- expect(roundtripFunction()).toBe(value);
+ roundtripFunction(value);
}
}