blob: f6f5c45607fc483a7b11ea5529450b61d372ab52 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
'use strict';
// This tests that AsyncHooks throws an error if bad parameters are passed.
require('../common');
const assert = require('assert');
const async_hooks = require('async_hooks');
const non_function = 10;
typeErrorForFunction('init');
typeErrorForFunction('before');
typeErrorForFunction('after');
typeErrorForFunction('destroy');
typeErrorForFunction('promiseResolve');
function typeErrorForFunction(functionName) {
assert.throws(() => {
async_hooks.createHook({ [functionName]: non_function });
}, {
code: 'ERR_ASYNC_CALLBACK',
name: 'TypeError',
message: `hook.${functionName} must be a function`
});
}
|