test: use arrow functions in async-hooks tests
Convert all anonymous callback functions in `test/async-hooks/*.js` to use arrow functions. `writing-tests.md` states to use arrow functions when appropriate. PR-URL: https://github.com/nodejs/node/pull/30137 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
cf3a05ae5f
commit
b27e2408af
@ -7,7 +7,7 @@ const fs = require('fs');
|
|||||||
let nestedCall = false;
|
let nestedCall = false;
|
||||||
|
|
||||||
async_hooks.createHook({
|
async_hooks.createHook({
|
||||||
init: common.mustCall(function() {
|
init: common.mustCall(() => {
|
||||||
nestedHook.disable();
|
nestedHook.disable();
|
||||||
if (!nestedCall) {
|
if (!nestedCall) {
|
||||||
nestedCall = true;
|
nestedCall = true;
|
||||||
|
@ -11,11 +11,11 @@ const http = require('http');
|
|||||||
const hooks = initHooks();
|
const hooks = initHooks();
|
||||||
hooks.enable();
|
hooks.enable();
|
||||||
|
|
||||||
const server = http.createServer(common.mustCall(function(req, res) {
|
const server = http.createServer(common.mustCall((req, res) => {
|
||||||
res.end();
|
res.end();
|
||||||
this.close(common.mustCall());
|
server.close(common.mustCall());
|
||||||
}));
|
}));
|
||||||
server.listen(0, common.mustCall(function() {
|
server.listen(0, common.mustCall(() => {
|
||||||
http.get({
|
http.get({
|
||||||
host: '::1',
|
host: '::1',
|
||||||
family: 6,
|
family: 6,
|
||||||
@ -23,7 +23,7 @@ server.listen(0, common.mustCall(function() {
|
|||||||
}, common.mustCall());
|
}, common.mustCall());
|
||||||
}));
|
}));
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', () => {
|
||||||
hooks.disable();
|
hooks.disable();
|
||||||
|
|
||||||
verifyGraph(
|
verifyGraph(
|
||||||
|
@ -12,9 +12,9 @@ tmpdir.refresh();
|
|||||||
const hooks = initHooks();
|
const hooks = initHooks();
|
||||||
hooks.enable();
|
hooks.enable();
|
||||||
|
|
||||||
net.createServer(function(c) {
|
const server = net.createServer((c) => {
|
||||||
c.end();
|
c.end();
|
||||||
this.close();
|
server.close();
|
||||||
}).listen(common.PIPE, common.mustCall(onlisten));
|
}).listen(common.PIPE, common.mustCall(onlisten));
|
||||||
|
|
||||||
function onlisten() {
|
function onlisten() {
|
||||||
|
@ -14,11 +14,11 @@ hooks.enable();
|
|||||||
|
|
||||||
const rootAsyncId = async_hooks.executionAsyncId();
|
const rootAsyncId = async_hooks.executionAsyncId();
|
||||||
|
|
||||||
process.nextTick(common.mustCall(function() {
|
process.nextTick(common.mustCall(() => {
|
||||||
assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId);
|
assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', () => {
|
||||||
hooks.sanityCheck();
|
hooks.sanityCheck();
|
||||||
|
|
||||||
const as = hooks.activitiesOfTypes('TickObject');
|
const as = hooks.activitiesOfTypes('TickObject');
|
||||||
|
@ -17,9 +17,9 @@ let pipe1, pipe2;
|
|||||||
let pipeserver;
|
let pipeserver;
|
||||||
let pipeconnect;
|
let pipeconnect;
|
||||||
|
|
||||||
net.createServer(common.mustCall(function(c) {
|
const server = net.createServer(common.mustCall((c) => {
|
||||||
c.end();
|
c.end();
|
||||||
this.close();
|
server.close();
|
||||||
process.nextTick(maybeOnconnect.bind(null, 'server'));
|
process.nextTick(maybeOnconnect.bind(null, 'server'));
|
||||||
})).listen(common.PIPE, common.mustCall(onlisten));
|
})).listen(common.PIPE, common.mustCall(onlisten));
|
||||||
|
|
||||||
|
@ -11,11 +11,11 @@ hooks.enable();
|
|||||||
|
|
||||||
const rootAsyncId = async_hooks.executionAsyncId();
|
const rootAsyncId = async_hooks.executionAsyncId();
|
||||||
|
|
||||||
queueMicrotask(common.mustCall(function() {
|
queueMicrotask(common.mustCall(() => {
|
||||||
assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId);
|
assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', () => {
|
||||||
hooks.sanityCheck();
|
hooks.sanityCheck();
|
||||||
|
|
||||||
const as = hooks.activitiesOfTypes('Microtask');
|
const as = hooks.activitiesOfTypes('Microtask');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user