diff options
Diffstat (limited to 'test_ffi/tests')
-rw-r--r-- | test_ffi/tests/bench.js | 41 | ||||
-rw-r--r-- | test_ffi/tests/ffi_types.ts | 27 | ||||
-rw-r--r-- | test_ffi/tests/integration_tests.rs | 34 | ||||
-rw-r--r-- | test_ffi/tests/test.js | 14 |
4 files changed, 93 insertions, 23 deletions
diff --git a/test_ffi/tests/bench.js b/test_ffi/tests/bench.js index 165b395e2..8885c7d7e 100644 --- a/test_ffi/tests/bench.js +++ b/test_ffi/tests/bench.js @@ -305,6 +305,11 @@ Deno.bench("nop_buffer()", () => { nop_buffer(buffer); }); +const buffer_ptr = Deno.UnsafePointer.of(buffer); +Deno.bench("nop_buffer() number", () => { + nop_buffer(buffer_ptr); +}); + const { return_u8 } = dylib.symbols; Deno.bench("return_u8()", () => { return_u8(); @@ -442,6 +447,10 @@ Deno.bench("nop_buffer_nonblocking()", async () => { await nop_buffer_nonblocking(buffer); }); +Deno.bench("nop_buffer_nonblocking() number", async () => { + await nop_buffer_nonblocking(buffer_ptr); +}); + const { return_u8_nonblocking } = dylib.symbols; Deno.bench("return_u8_nonblocking()", async () => { await return_u8_nonblocking(); @@ -540,6 +549,38 @@ Deno.bench("nop_many_parameters()", () => { ); }); +const buffer2_ptr = Deno.UnsafePointer.of(buffer2); +Deno.bench("nop_many_parameters() number", () => { + nop_many_parameters( + 135, + 47, + 356, + -236, + 7457, + -1356, + 16471468, + -1334748136, + 132658769535, + -42745856824, + 13567.26437, + 7.686234e-3, + buffer_ptr, + 64, + -42, + 83, + -136, + 3657, + -2376, + 3277918, + -474628146, + 344657895, + -2436732, + 135.26437e3, + 264.3576468623546834, + buffer2_ptr, + ); +}); + const { nop_many_parameters_nonblocking } = dylib.symbols; Deno.bench("nop_many_parameters_nonblocking()", () => { nop_many_parameters_nonblocking( diff --git a/test_ffi/tests/ffi_types.ts b/test_ffi/tests/ffi_types.ts index 172c429e8..d4a90552f 100644 --- a/test_ffi/tests/ffi_types.ts +++ b/test_ffi/tests/ffi_types.ts @@ -131,7 +131,7 @@ remote.symbols.method14(null); remote.symbols.method14(0); // @ts-expect-error: Invalid argument -remote.symbols.method15(0); +remote.symbols.method15("foo"); remote.symbols.method15(new Uint16Array(1)); remote.symbols.method15(0n); @@ -245,16 +245,16 @@ remote.symbols.method20(unsafe_callback_right1.pointer); // @ts-expect-error: Invalid member type const static1_wrong: null = remote.symbols.static1; -const static1_right: bigint = remote.symbols.static1; +const static1_right: Deno.PointerValue = remote.symbols.static1; // @ts-expect-error: Invalid member type const static2_wrong: null = remote.symbols.static2; const static2_right: Deno.UnsafePointer = remote.symbols.static2; // @ts-expect-error: Invalid member type const static3_wrong: null = remote.symbols.static3; -const static3_right: bigint = remote.symbols.static3; +const static3_right: Deno.PointerValue = remote.symbols.static3; // @ts-expect-error: Invalid member type const static4_wrong: null = remote.symbols.static4; -const static4_right: bigint = remote.symbols.static4; +const static4_right: Deno.PointerValue = remote.symbols.static4; // @ts-expect-error: Invalid member type const static5_wrong: null = remote.symbols.static5; const static5_right: number = remote.symbols.static5; @@ -266,7 +266,7 @@ const static7_wrong: null = remote.symbols.static7; const static7_right: number = remote.symbols.static7; // @ts-expect-error: Invalid member type const static8_wrong: null = remote.symbols.static8; -const static8_right: bigint = remote.symbols.static8; +const static8_right: Deno.PointerValue = remote.symbols.static8; // @ts-expect-error: Invalid member type const static9_wrong: null = remote.symbols.static9; const static9_right: number = remote.symbols.static9; @@ -278,7 +278,7 @@ const static11_wrong: null = remote.symbols.static11; const static11_right: number = remote.symbols.static11; // @ts-expect-error: Invalid member type const static12_wrong: null = remote.symbols.static12; -const static12_right: bigint = remote.symbols.static12; +const static12_right: Deno.PointerValue = remote.symbols.static12; // @ts-expect-error: Invalid member type const static13_wrong: null = remote.symbols.static13; const static13_right: number = remote.symbols.static13; @@ -331,7 +331,10 @@ type __Tests__ = [ higher_order_params: AssertEqual< { symbols: { - pushBuf: (ptr: bigint | TypedArray | null, func: bigint | null) => void; + pushBuf: ( + ptr: number | bigint | TypedArray | null, + func: number | bigint | null, + ) => void; }; close(): void; }, @@ -343,9 +346,9 @@ type __Tests__ = [ { symbols: { pushBuf: ( - ptr: bigint | TypedArray | null, - func: bigint | null, - ) => bigint; + ptr: number | bigint | TypedArray | null, + func: number | bigint | null, + ) => number | bigint; }; close(): void; }, @@ -356,7 +359,9 @@ type __Tests__ = [ non_exact_params: AssertEqual< { symbols: { - foo: (...args: (number | bigint | TypedArray | null)[]) => bigint; + foo: ( + ...args: (number | bigint | TypedArray | null)[] + ) => number | bigint; }; close(): void; }, diff --git a/test_ffi/tests/integration_tests.rs b/test_ffi/tests/integration_tests.rs index 4a910a836..079293550 100644 --- a/test_ffi/tests/integration_tests.rs +++ b/test_ffi/tests/integration_tests.rs @@ -66,17 +66,29 @@ fn basic() { 5\n\ 5\n\ 579\n\ - 8589934590n\n\ - -8589934590n\n\ - 8589934590n\n\ - -8589934590n\n\ + 8589934590\n\ + -8589934590\n\ + 8589934590\n\ + -8589934590\n\ + 9007199254740992n\n\ + 9007199254740992n\n\ + -9007199254740992n\n\ + 9007199254740992n\n\ + 9007199254740992n\n\ + -9007199254740992n\n\ 579.9119873046875\n\ 579.912\n\ 579\n\ - 8589934590n\n\ - -8589934590n\n\ - 8589934590n\n\ - -8589934590n\n\ + 8589934590\n\ + -8589934590\n\ + 8589934590\n\ + -8589934590\n\ + 9007199254740992n\n\ + 9007199254740992n\n\ + -9007199254740992n\n\ + 9007199254740992n\n\ + 9007199254740992n\n\ + -9007199254740992n\n\ 579.9119873046875\n\ 579.912\n\ After sleep_blocking\n\ @@ -86,7 +98,7 @@ fn basic() { After\n\ true\n\ logCallback\n\ - 1 -1 2 -2 3 -3 4n -4n 0.5 -0.5 1 2 3 4 5 6 7 8\n\ + 1 -1 2 -2 3 -3 4 -4 0.5 -0.5 1 2 3 4 5 6 7 8\n\ u8: 8\n\ buf: [1, 2, 3, 4, 5, 6, 7, 8]\n\ logCallback\n\ @@ -98,7 +110,7 @@ fn basic() { Thread safe call counter: 1\n\ u8: 8\n\ Static u32: 42\n\ - Static i64: -1242464576485n\n\ + Static i64: -1242464576485\n\ Static ptr: true\n\ Static ptr value: 42\n\ arrayBuffer.byteLength: 4\n\ @@ -116,7 +128,7 @@ fn symbol_types() { build(); let output = deno_cmd() - .arg("cache") + .arg("check") .arg("--unstable") .arg("--quiet") .arg("tests/ffi_types.ts") diff --git a/test_ffi/tests/test.js b/test_ffi/tests/test.js index 516182f6f..e27a09d4f 100644 --- a/test_ffi/tests/test.js +++ b/test_ffi/tests/test.js @@ -265,6 +265,12 @@ console.log(dylib.symbols.add_u64(0xffffffffn, 0xffffffffn)); console.log(dylib.symbols.add_i64(-0xffffffffn, -0xffffffffn)); console.log(dylib.symbols.add_usize(0xffffffffn, 0xffffffffn)); console.log(dylib.symbols.add_isize(-0xffffffffn, -0xffffffffn)); +console.log(dylib.symbols.add_u64(Number.MAX_SAFE_INTEGER, 1)); +console.log(dylib.symbols.add_i64(Number.MAX_SAFE_INTEGER, 1)); +console.log(dylib.symbols.add_i64(Number.MIN_SAFE_INTEGER, -1)); +console.log(dylib.symbols.add_usize(Number.MAX_SAFE_INTEGER, 1)); +console.log(dylib.symbols.add_isize(Number.MAX_SAFE_INTEGER, 1)); +console.log(dylib.symbols.add_isize(Number.MIN_SAFE_INTEGER, -1)); console.log(dylib.symbols.add_f32(123.123, 456.789)); console.log(dylib.symbols.add_f64(123.123, 456.789)); @@ -280,6 +286,12 @@ console.log( console.log( await dylib.symbols.add_isize_nonblocking(-0xffffffffn, -0xffffffffn), ); +console.log(await dylib.symbols.add_u64_nonblocking(Number.MAX_SAFE_INTEGER, 1)); +console.log(await dylib.symbols.add_i64_nonblocking(Number.MAX_SAFE_INTEGER, 1)); +console.log(await dylib.symbols.add_i64_nonblocking(Number.MIN_SAFE_INTEGER, -1)); +console.log(await dylib.symbols.add_usize_nonblocking(Number.MAX_SAFE_INTEGER, 1)); +console.log(await dylib.symbols.add_isize_nonblocking(Number.MAX_SAFE_INTEGER, 1)); +console.log(await dylib.symbols.add_isize_nonblocking(Number.MIN_SAFE_INTEGER, -1)); console.log(await dylib.symbols.add_f32_nonblocking(123.123, 456.789)); console.log(await dylib.symbols.add_f64_nonblocking(123.123, 456.789)); @@ -439,7 +451,7 @@ console.log("Static u32:", dylib.symbols.static_u32); console.log("Static i64:", dylib.symbols.static_i64); console.log( "Static ptr:", - typeof dylib.symbols.static_ptr === "bigint", + typeof dylib.symbols.static_ptr === "number", ); const view = new Deno.UnsafePointerView(dylib.symbols.static_ptr); console.log("Static ptr value:", view.getUint32()); |