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.
 
 
 
 
 
 

29 lines
795 B

'use strict';
require('../common');
// This tests that AsyncResource throws an error if bad parameters are passed
const assert = require('assert');
const async_hooks = require('async_hooks');
const { AsyncResource } = async_hooks;
// Setup init hook such parameters are validated
async_hooks.createHook({
init() {}
}).enable();
assert.throws(() => {
return new AsyncResource();
}, /^TypeError: type must be a string with length > 0$/);
assert.throws(() => {
new AsyncResource('');
}, /^TypeError: type must be a string with length > 0$/);
assert.throws(() => {
new AsyncResource('type', -4);
}, /^RangeError: triggerAsyncId must be an unsigned integer$/);
assert.throws(() => {
new AsyncResource('type', Math.PI);
}, /^RangeError: triggerAsyncId must be an unsigned integer$/);