mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
cf46746b8a
PR-URL: https://github.com/nodejs/node/pull/45549 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
35 lines
843 B
JavaScript
35 lines
843 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const async_hooks = require('async_hooks');
|
|
const { AsyncResource } = async_hooks;
|
|
const { spawn } = require('child_process');
|
|
|
|
const initHooks = require('./init-hooks');
|
|
|
|
if (process.argv[2] === 'child') {
|
|
initHooks().enable();
|
|
|
|
class Foo extends AsyncResource {
|
|
constructor(type) {
|
|
super(type, async_hooks.executionAsyncId());
|
|
}
|
|
}
|
|
|
|
[null, undefined, 1, Date, {}, []].forEach((i) => {
|
|
assert.throws(() => new Foo(i), {
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError',
|
|
});
|
|
});
|
|
|
|
} else {
|
|
const args = process.argv.slice(1).concat('child');
|
|
spawn(process.execPath, args)
|
|
.on('close', common.mustCall((code) => {
|
|
// No error because the type was defaulted
|
|
assert.strictEqual(code, 0);
|
|
}));
|
|
}
|