nodejs/test/parallel/test-async-wrap-asyncresource-constructor.js
Andreas Madsen de762b71f2
async_hooks: rename currentId and triggerId
currentId is renamed to executionAsyncId
triggerId is renamed to triggerAsyncId
AsyncResource.triggerId is renamed to AsyncResource.triggerAsyncId
AsyncHooksGetCurrentId is renamed to AsyncHooksGetExecutionAsyncId
AsyncHooksGetTriggerId is renamed to AsyncHooksGetTriggerAsyncId

PR-URL: https://github.com/nodejs/node/pull/13490
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2017-06-14 12:39:53 +02:00

24 lines
672 B
JavaScript

'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);
}, /^RangeError: triggerAsyncId must be an unsigned integer$/);
assert.throws(() => {
new AsyncResource('type', Math.PI);
}, /^RangeError: triggerAsyncId must be an unsigned integer$/);