MCPcopy Index your code
hub / github.com/nodejs/node / assertInvalidCallbackReturnAborts

Function assertInvalidCallbackReturnAborts

test/ffi/test-ffi-calls.js:306–327  ·  view source on GitHub ↗
(returnExpression)

Source from the content-addressed store, hash-verified

304});
305
306function assertInvalidCallbackReturnAborts(returnExpression) {
307 const { stderr, status, signal } = spawnSync(process.execPath, [
308 '--experimental-ffi',
309 '-e',
310 `'use strict';
311const ffi = require('node:ffi');
312const { fixtureSymbols, libraryPath } = require(${JSON.stringify(require.resolve('./ffi-test-common'))});
313const { lib, functions } = ffi.dlopen(libraryPath, fixtureSymbols);
314const callback = lib.registerCallback(
315 { arguments: ['i32'], return: 'i32' },
316 () => (${returnExpression}),
317);
318functions.call_int_callback(callback, 21);`,
319 ], {
320 encoding: 'utf8',
321 });
322
323 assert.ok(common.nodeProcessAborted(status, signal),
324 `status: ${status}, signal: ${signal}
325stderr: ${stderr}`);
326 assert.match(stderr, /Callback returned invalid value for declared FFI type/);
327}
328
329function assertInvalidCallbackBehaviorAborts(callbackBody, message) {
330 const { stderr, status, signal } = spawnSync(process.execPath, [

Callers 1

test-ffi-calls.jsFile · 0.85

Calls 4

matchMethod · 0.65
spawnSyncFunction · 0.50
resolveMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…