summaryrefslogtreecommitdiff
path: root/test/async-hooks/test-nexttick-default-trigger.js
diff options
context:
space:
mode:
authorAnatoli Papirovski <apapirovski@mac.com>2018-03-05 12:20:48 +0100
committerAnatoli Papirovski <apapirovski@mac.com>2018-03-08 13:23:44 +0100
commit4d074343ddf674817b8479896bfdce5ae23a83e8 (patch)
treebceb875819220e1bf33ecc7428777a1c267f820d /test/async-hooks/test-nexttick-default-trigger.js
parent64d523411f4a87e4f27624f83590341eb3693cef (diff)
downloadandroid-node-v8-4d074343ddf674817b8479896bfdce5ae23a83e8.tar.gz
android-node-v8-4d074343ddf674817b8479896bfdce5ae23a83e8.tar.bz2
android-node-v8-4d074343ddf674817b8479896bfdce5ae23a83e8.zip
async_hooks,process: remove internalNextTick
Instead of having mostly duplicate code in form of internalNextTick, instead use the existing defaultAsyncTriggerIdScope with a slight modification which allows undefined triggerAsyncId to be passed in, which then just triggers the callback with the provided arguments. PR-URL: https://github.com/nodejs/node/pull/19147 Refs: https://github.com/nodejs/node/issues/19104 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/async-hooks/test-nexttick-default-trigger.js')
-rw-r--r--test/async-hooks/test-nexttick-default-trigger.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/async-hooks/test-nexttick-default-trigger.js b/test/async-hooks/test-nexttick-default-trigger.js
new file mode 100644
index 0000000000..1bc93f2973
--- /dev/null
+++ b/test/async-hooks/test-nexttick-default-trigger.js
@@ -0,0 +1,28 @@
+'use strict';
+const common = require('../common');
+
+// This tests ensures that the triggerId of the nextTick function sets the
+// triggerAsyncId correctly.
+
+const assert = require('assert');
+const async_hooks = require('async_hooks');
+const initHooks = require('./init-hooks');
+const { checkInvocations } = require('./hook-checks');
+
+const hooks = initHooks();
+hooks.enable();
+
+const rootAsyncId = async_hooks.executionAsyncId();
+
+process.nextTick(common.mustCall(function() {
+ assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId);
+}));
+
+process.on('exit', function() {
+ hooks.sanityCheck();
+
+ const as = hooks.activitiesOfTypes('TickObject');
+ checkInvocations(as[0], {
+ init: 1, before: 1, after: 1, destroy: 1
+ }, 'when process exits');
+});