Skip to content

Commit 37c70ee

Browse files
GaryGSCtargos
authored andcommitted
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 <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent b5c7dad commit 37c70ee

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

‎test/async-hooks/test-disable-in-init.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const fs = require('fs');
77
letnestedCall=false;
88

99
async_hooks.createHook({
10-
init: common.mustCall(function(){
10+
init: common.mustCall(()=>{
1111
nestedHook.disable();
1212
if(!nestedCall){
1313
nestedCall=true;

‎test/async-hooks/test-graph.http.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ const http = require('http');
1111
consthooks=initHooks();
1212
hooks.enable();
1313

14-
constserver=http.createServer(common.mustCall(function(req,res){
14+
constserver=http.createServer(common.mustCall((req,res)=>{
1515
res.end();
16-
this.close(common.mustCall());
16+
server.close(common.mustCall());
1717
}));
18-
server.listen(0,common.mustCall(function(){
18+
server.listen(0,common.mustCall(()=>{
1919
http.get({
2020
host: '::1',
2121
family: 6,
2222
port: server.address().port
2323
},common.mustCall());
2424
}));
2525

26-
process.on('exit',function(){
26+
process.on('exit',()=>{
2727
hooks.disable();
2828

2929
verifyGraph(

‎test/async-hooks/test-graph.pipeconnect.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ tmpdir.refresh();
1212
consthooks=initHooks();
1313
hooks.enable();
1414

15-
net.createServer(function(c){
15+
constserver=net.createServer((c)=>{
1616
c.end();
17-
this.close();
17+
server.close();
1818
}).listen(common.PIPE,common.mustCall(onlisten));
1919

2020
functiononlisten(){

‎test/async-hooks/test-nexttick-default-trigger.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ hooks.enable();
1414

1515
constrootAsyncId=async_hooks.executionAsyncId();
1616

17-
process.nextTick(common.mustCall(function(){
17+
process.nextTick(common.mustCall(()=>{
1818
assert.strictEqual(async_hooks.triggerAsyncId(),rootAsyncId);
1919
}));
2020

21-
process.on('exit',function(){
21+
process.on('exit',()=>{
2222
hooks.sanityCheck();
2323

2424
constas=hooks.activitiesOfTypes('TickObject');

‎test/async-hooks/test-pipeconnectwrap.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ let pipe1, pipe2;
1717
letpipeserver;
1818
letpipeconnect;
1919

20-
net.createServer(common.mustCall(function(c){
20+
constserver=net.createServer(common.mustCall((c)=>{
2121
c.end();
22-
this.close();
22+
server.close();
2323
process.nextTick(maybeOnconnect.bind(null,'server'));
2424
})).listen(common.PIPE,common.mustCall(onlisten));
2525

‎test/async-hooks/test-queue-microtask.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ hooks.enable();
1111

1212
constrootAsyncId=async_hooks.executionAsyncId();
1313

14-
queueMicrotask(common.mustCall(function(){
14+
queueMicrotask(common.mustCall(()=>{
1515
assert.strictEqual(async_hooks.triggerAsyncId(),rootAsyncId);
1616
}));
1717

18-
process.on('exit',function(){
18+
process.on('exit',()=>{
1919
hooks.sanityCheck();
2020

2121
constas=hooks.activitiesOfTypes('Microtask');

0 commit comments

Comments
(0)