mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
456 B
16 lines
456 B
8 years ago
|
'use strict';
|
||
|
require('../common');
|
||
|
|
||
|
// This tests that using falsy values in createHook throws an error.
|
||
|
|
||
|
const assert = require('assert');
|
||
|
const async_hooks = require('async_hooks');
|
||
|
|
||
|
for (const badArg of [0, 1, false, true, null, 'hello']) {
|
||
|
for (const field of ['init', 'before', 'after', 'destroy']) {
|
||
|
assert.throws(() => {
|
||
|
async_hooks.createHook({ [field]: badArg });
|
||
|
}, new RegExp(`^TypeError: ${field} must be a function$`));
|
||
|
}
|
||
|
}
|