Skip to content
Permalink
Browse files

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: #30137
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
GaryGSC authored and MylesBorins committed Oct 26, 2019
1 parent 2aa8654 commit 6c6ffdd56c5c0bff777594e1255d36192f84c268
@@ -7,7 +7,7 @@ const fs = require('fs');
let nestedCall = false;

async_hooks.createHook({
init: common.mustCall(function() {
init: common.mustCall(() => {
nestedHook.disable();
if (!nestedCall) {
nestedCall = true;
@@ -11,19 +11,19 @@ const http = require('http');
const hooks = initHooks();
hooks.enable();

const server = http.createServer(common.mustCall(function(req, res) {
const server = http.createServer(common.mustCall((req, res) => {
res.end();
this.close(common.mustCall());
server.close(common.mustCall());
}));
server.listen(0, common.mustCall(function() {
server.listen(0, common.mustCall(() => {
http.get({
host: '::1',
family: 6,
port: server.address().port
}, common.mustCall());
}));

process.on('exit', function() {
process.on('exit', () => {
hooks.disable();

verifyGraph(
@@ -12,9 +12,9 @@ tmpdir.refresh();
const hooks = initHooks();
hooks.enable();

net.createServer(function(c) {
const server = net.createServer((c) => {
c.end();
this.close();
server.close();
}).listen(common.PIPE, common.mustCall(onlisten));

function onlisten() {
@@ -14,11 +14,11 @@ hooks.enable();

const rootAsyncId = async_hooks.executionAsyncId();

process.nextTick(common.mustCall(function() {
process.nextTick(common.mustCall(() => {
assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId);
}));

process.on('exit', function() {
process.on('exit', () => {
hooks.sanityCheck();

const as = hooks.activitiesOfTypes('TickObject');
@@ -17,9 +17,9 @@ let pipe1, pipe2;
let pipeserver;
let pipeconnect;

net.createServer(common.mustCall(function(c) {
const server = net.createServer(common.mustCall((c) => {
c.end();
this.close();
server.close();
process.nextTick(maybeOnconnect.bind(null, 'server'));
})).listen(common.PIPE, common.mustCall(onlisten));

@@ -11,11 +11,11 @@ hooks.enable();

const rootAsyncId = async_hooks.executionAsyncId();

queueMicrotask(common.mustCall(function() {
queueMicrotask(common.mustCall(() => {
assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId);
}));

process.on('exit', function() {
process.on('exit', () => {
hooks.sanityCheck();

const as = hooks.activitiesOfTypes('Microtask');

0 comments on commit 6c6ffdd

Please sign in to comment.
You can’t perform that action at this time.