summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorgarygsc <garygsc@gmail.com>2019-10-26 13:17:23 -0600
committerGireesh Punathil <gpunathi@in.ibm.com>2019-12-02 20:03:17 +0530
commitb27e2408af6683d34852221ae70b937b0f95943f (patch)
treeadc4c7a9f20aa89877b350b59bbd4e04f0674985 /test
parentcf3a05ae5f8c78dd837b0135f467683477ccc5bc (diff)
downloadandroid-node-v8-b27e2408af6683d34852221ae70b937b0f95943f.tar.gz
android-node-v8-b27e2408af6683d34852221ae70b937b0f95943f.tar.bz2
android-node-v8-b27e2408af6683d34852221ae70b937b0f95943f.zip
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>
Diffstat (limited to 'test')
-rw-r--r--test/async-hooks/test-disable-in-init.js2
-rw-r--r--test/async-hooks/test-graph.http.js8
-rw-r--r--test/async-hooks/test-graph.pipeconnect.js4
-rw-r--r--test/async-hooks/test-nexttick-default-trigger.js4
-rw-r--r--test/async-hooks/test-pipeconnectwrap.js4
-rw-r--r--test/async-hooks/test-queue-microtask.js4
6 files changed, 13 insertions, 13 deletions
diff --git a/test/async-hooks/test-disable-in-init.js b/test/async-hooks/test-disable-in-init.js
index b7ab31e6d9..17537c62f3 100644
--- a/test/async-hooks/test-disable-in-init.js
+++ b/test/async-hooks/test-disable-in-init.js
@@ -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;
diff --git a/test/async-hooks/test-graph.http.js b/test/async-hooks/test-graph.http.js
index 12862467a6..db0c126567 100644
--- a/test/async-hooks/test-graph.http.js
+++ b/test/async-hooks/test-graph.http.js
@@ -11,11 +11,11 @@ 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,
@@ -23,7 +23,7 @@ server.listen(0, common.mustCall(function() {
}, common.mustCall());
}));
-process.on('exit', function() {
+process.on('exit', () => {
hooks.disable();
verifyGraph(
diff --git a/test/async-hooks/test-graph.pipeconnect.js b/test/async-hooks/test-graph.pipeconnect.js
index 03d2902c83..440ea906a1 100644
--- a/test/async-hooks/test-graph.pipeconnect.js
+++ b/test/async-hooks/test-graph.pipeconnect.js
@@ -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() {
diff --git a/test/async-hooks/test-nexttick-default-trigger.js b/test/async-hooks/test-nexttick-default-trigger.js
index 1bc93f2973..7d6d98c9ab 100644
--- a/test/async-hooks/test-nexttick-default-trigger.js
+++ b/test/async-hooks/test-nexttick-default-trigger.js
@@ -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');
diff --git a/test/async-hooks/test-pipeconnectwrap.js b/test/async-hooks/test-pipeconnectwrap.js
index f086807e39..b57cc63cf5 100644
--- a/test/async-hooks/test-pipeconnectwrap.js
+++ b/test/async-hooks/test-pipeconnectwrap.js
@@ -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));
diff --git a/test/async-hooks/test-queue-microtask.js b/test/async-hooks/test-queue-microtask.js
index dfa537752e..1e2029efe4 100644
--- a/test/async-hooks/test-queue-microtask.js
+++ b/test/async-hooks/test-queue-microtask.js
@@ -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');