1'use strict'; 2 3const common = require('../../common'); 4const assert = require('assert'); 5 6function testUncaughtException(binding) { 7 const callbackCheck = common.mustCall((err) => { 8 assert.throws(() => { throw err; }, /callback error/); 9 process.removeListener('uncaughtException', callbackCheck); 10 process.on('uncaughtException', finalizerCheck); 11 }); 12 const finalizerCheck = common.mustCall((err) => { 13 assert.throws(() => { throw err; }, /finalizer error/); 14 }); 15 process.on('uncaughtException', callbackCheck); 16 17 binding.CallIntoModule( 18 common.mustCall(() => { 19 throw new Error('callback error'); 20 }), 21 {}, 22 'resource_name', 23 common.mustCall(function finalizer() { 24 throw new Error('finalizer error'); 25 }), 26 ); 27} 28 29module.exports = { 30 testUncaughtException, 31}; 32