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.
30 lines
795 B
30 lines
795 B
8 years ago
|
'use strict';
|
||
|
require('../common');
|
||
|
|
||
|
// This tests that AsyncResource throws an error if bad parameters are passed
|
||
|
|
||
|
const assert = require('assert');
|
||
8 years ago
|
const async_hooks = require('async_hooks');
|
||
|
const { AsyncResource } = async_hooks;
|
||
|
|
||
|
// Setup init hook such parameters are validated
|
||
|
async_hooks.createHook({
|
||
|
init() {}
|
||
|
}).enable();
|
||
8 years ago
|
|
||
|
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);
|
||
8 years ago
|
}, /^RangeError: triggerAsyncId must be an unsigned integer$/);
|
||
8 years ago
|
|
||
|
assert.throws(() => {
|
||
|
new AsyncResource('type', Math.PI);
|
||
8 years ago
|
}, /^RangeError: triggerAsyncId must be an unsigned integer$/);
|