node/test/node-api/test_callback_scope/test.js
legendecas 307c67be17
n-api: fix false assumption on napi_async_context structures
napi_async_context should be an opaque type and not be used as same as
node::async_context.

PR-URL: https://github.com/nodejs/node/pull/32928
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-04-28 01:03:05 +02:00

18 lines
448 B
JavaScript

'use strict';
const common = require('../../common');
const assert = require('assert');
const { runInCallbackScope } = require(`./build/${common.buildType}/binding`);
assert.strictEqual(runInCallbackScope({}, 'test-resource', () => 42), 42);
{
process.once('uncaughtException', common.mustCall((err) => {
assert.strictEqual(err.message, 'foo');
}));
runInCallbackScope({}, 'test-resource', () => {
throw new Error('foo');
});
}