2017-05-31 10:01:26 +02:00
|
|
|
'use strict';
|
|
|
|
require('../common');
|
|
|
|
|
|
|
|
// This tests that AsyncResource throws an error if bad parameters are passed
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const AsyncResource = require('async_hooks').AsyncResource;
|
|
|
|
|
|
|
|
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);
|
2017-06-14 12:39:53 +02:00
|
|
|
}, /^RangeError: triggerAsyncId must be an unsigned integer$/);
|
2017-05-31 10:01:26 +02:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
new AsyncResource('type', Math.PI);
|
2017-06-14 12:39:53 +02:00
|
|
|
}, /^RangeError: triggerAsyncId must be an unsigned integer$/);
|