Skip to content

Commit

Permalink
test: use arrow functions in async-hooks tests
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
GaryGSC authored and targos committed Dec 5, 2019
1 parent b802d51 commit ed7dd93
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion test/async-hooks/test-disable-in-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions test/async-hooks/test-graph.http.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions test/async-hooks/test-graph.pipeconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions test/async-hooks/test-nexttick-default-trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions test/async-hooks/test-pipeconnectwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
4 changes: 2 additions & 2 deletions test/async-hooks/test-queue-microtask.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit ed7dd93

Please sign in to comment.