summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgarygsc <garygsc@gmail.com>2019-10-26 02:54:18 -0600
committerAnna Henningsen <anna@addaleax.net>2019-11-30 18:08:59 +0100
commit79faa875026a275b3e5eca019b3c50e1cbe2e34e (patch)
tree0fb5327abc56edd199553a66ab3e6f8e0952f2bc
parentc8930fb9bf647b88bba9b6e7be4f4ea119fb3d57 (diff)
downloadandroid-node-v8-79faa875026a275b3e5eca019b3c50e1cbe2e34e.tar.gz
android-node-v8-79faa875026a275b3e5eca019b3c50e1cbe2e34e.tar.bz2
android-node-v8-79faa875026a275b3e5eca019b3c50e1cbe2e34e.zip
test: use arrow functions in addons tests
Convert all anonymous callback functions in `test/addons/**/*.js` to use arrow functions, except for those in `test/addons/make-callback/test.js` (which reference `this`) `writing-tests.md` states to use arrow functions when appropriate. PR-URL: https://github.com/nodejs/node/pull/30131 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
-rw-r--r--test/addons/async-hello-world/test-makecallback.js2
-rw-r--r--test/addons/async-hello-world/test.js2
-rw-r--r--test/addons/load-long-path/test.js2
-rw-r--r--test/addons/make-callback-domain-warning/test.js10
-rw-r--r--test/addons/make-callback-recurse/test.js2
-rw-r--r--test/addons/openssl-client-cert-engine/test.js6
-rw-r--r--test/addons/openssl-key-engine/test.js6
-rw-r--r--test/addons/repl-domain-abort/test.js2
-rw-r--r--test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js2
-rw-r--r--test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js2
-rw-r--r--test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js2
-rw-r--r--test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js2
-rw-r--r--test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js6
-rw-r--r--test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js2
14 files changed, 24 insertions, 24 deletions
diff --git a/test/addons/async-hello-world/test-makecallback.js b/test/addons/async-hello-world/test-makecallback.js
index 0edf052e8c..abbc4be9c6 100644
--- a/test/addons/async-hello-world/test-makecallback.js
+++ b/test/addons/async-hello-world/test-makecallback.js
@@ -3,7 +3,7 @@ const common = require('../../common');
const assert = require('assert');
const { runMakeCallback } = require(`./build/${common.buildType}/binding`);
-runMakeCallback(5, common.mustCall(function(err, val) {
+runMakeCallback(5, common.mustCall((err, val) => {
assert.strictEqual(err, null);
assert.strictEqual(val, 10);
process.nextTick(common.mustCall());
diff --git a/test/addons/async-hello-world/test.js b/test/addons/async-hello-world/test.js
index f24071087c..72b31f7ab6 100644
--- a/test/addons/async-hello-world/test.js
+++ b/test/addons/async-hello-world/test.js
@@ -3,7 +3,7 @@ const common = require('../../common');
const assert = require('assert');
const { runCall } = require(`./build/${common.buildType}/binding`);
-runCall(5, common.mustCall(function(err, val) {
+runCall(5, common.mustCall((err, val) => {
assert.strictEqual(err, null);
assert.strictEqual(val, 10);
process.nextTick(common.mustCall());
diff --git a/test/addons/load-long-path/test.js b/test/addons/load-long-path/test.js
index 168dad492b..9a9d076399 100644
--- a/test/addons/load-long-path/test.js
+++ b/test/addons/load-long-path/test.js
@@ -48,6 +48,6 @@ fs.writeFileSync(addonDestinationPath, contents);
// Run test
const child = fork(__filename, ['child'], { stdio: 'inherit' });
-child.on('exit', common.mustCall(function(code) {
+child.on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0);
}));
diff --git a/test/addons/make-callback-domain-warning/test.js b/test/addons/make-callback-domain-warning/test.js
index 2ea3c3f3d1..0377415e12 100644
--- a/test/addons/make-callback-domain-warning/test.js
+++ b/test/addons/make-callback-domain-warning/test.js
@@ -10,23 +10,23 @@ function makeCallback(object, cb) {
}
let latestWarning = null;
-process.on('warning', function(warning) {
+process.on('warning', (warning) => {
latestWarning = warning;
});
const d = domain.create();
// When domain is disabled, no warning will be emitted
-makeCallback({ domain: d }, common.mustCall(function() {
+makeCallback({ domain: d }, common.mustCall(() => {
assert.strictEqual(latestWarning, null);
- d.run(common.mustCall(function() {
+ d.run(common.mustCall(() => {
// No warning will be emitted when no domain property is applied
- makeCallback({}, common.mustCall(function() {
+ makeCallback({}, common.mustCall(() => {
assert.strictEqual(latestWarning, null);
// Warning is emitted when domain property is used and domain is enabled
- makeCallback({ domain: d }, common.mustCall(function() {
+ makeCallback({ domain: d }, common.mustCall(() => {
assert.strictEqual(latestWarning.name, 'DeprecationWarning');
assert.strictEqual(latestWarning.code, 'DEP0097');
}));
diff --git a/test/addons/make-callback-recurse/test.js b/test/addons/make-callback-recurse/test.js
index a93a0a4e01..4a540003ac 100644
--- a/test/addons/make-callback-recurse/test.js
+++ b/test/addons/make-callback-recurse/test.js
@@ -71,7 +71,7 @@ assert.throws(() => {
if (arg === 1) {
// The tests are first run on bootstrap during LoadEnvironment() in
// src/node.cc. Now run the tests through node::MakeCallback().
- setImmediate(function() {
+ setImmediate(() => {
makeCallback({}, common.mustCall(() => {
verifyExecutionOrder(2);
}));
diff --git a/test/addons/openssl-client-cert-engine/test.js b/test/addons/openssl-client-cert-engine/test.js
index 9e7d507b07..e843e4bf43 100644
--- a/test/addons/openssl-client-cert-engine/test.js
+++ b/test/addons/openssl-client-cert-engine/test.js
@@ -43,14 +43,14 @@ const server = https.createServer(serverOptions, common.mustCall((req, res) => {
headers: {}
};
- const req = https.request(clientOptions, common.mustCall(function(response) {
+ const req = https.request(clientOptions, common.mustCall((response) => {
let body = '';
response.setEncoding('utf8');
- response.on('data', function(chunk) {
+ response.on('data', (chunk) => {
body += chunk;
});
- response.on('end', common.mustCall(function() {
+ response.on('end', common.mustCall(() => {
assert.strictEqual(body, 'hello world');
server.close();
}));
diff --git a/test/addons/openssl-key-engine/test.js b/test/addons/openssl-key-engine/test.js
index 5c93e62636..2cd7ddabc1 100644
--- a/test/addons/openssl-key-engine/test.js
+++ b/test/addons/openssl-key-engine/test.js
@@ -45,14 +45,14 @@ const server = https.createServer(serverOptions, common.mustCall((req, res) => {
headers: {}
};
- const req = https.request(clientOptions, common.mustCall(function(response) {
+ const req = https.request(clientOptions, common.mustCall((response) => {
let body = '';
response.setEncoding('utf8');
- response.on('data', function(chunk) {
+ response.on('data', (chunk) => {
body += chunk;
});
- response.on('end', common.mustCall(function() {
+ response.on('end', common.mustCall(() => {
assert.strictEqual(body, 'hello world');
server.close();
}));
diff --git a/test/addons/repl-domain-abort/test.js b/test/addons/repl-domain-abort/test.js
index 2049fe6e6a..f8e70ffce9 100644
--- a/test/addons/repl-domain-abort/test.js
+++ b/test/addons/repl-domain-abort/test.js
@@ -31,7 +31,7 @@ if (common.isWindows)
buildPath = buildPath.replace(/\\/g, '/');
let cb_ran = false;
-process.on('exit', function() {
+process.on('exit', () => {
assert(cb_ran);
console.log('ok');
});
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js
index 5e3033db3e..55f50f5249 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js
+++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js
@@ -25,7 +25,7 @@ if (!binding.ensureAllocation(2 * kStringMaxLength))
common.skip(skipMessage);
const stringLengthHex = kStringMaxLength.toString(16);
-common.expectsError(function() {
+common.expectsError(() => {
buf.toString('ascii');
}, {
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js
index 400477034d..20d968787b 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js
+++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js
@@ -25,7 +25,7 @@ if (!binding.ensureAllocation(2 * kStringMaxLength))
common.skip(skipMessage);
const stringLengthHex = kStringMaxLength.toString(16);
-common.expectsError(function() {
+common.expectsError(() => {
buf.toString('base64');
}, {
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js
index ef5d6a21ed..f6ae5217dd 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js
+++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js
@@ -27,7 +27,7 @@ if (!binding.ensureAllocation(2 * kStringMaxLength))
common.skip(skipMessage);
const stringLengthHex = kStringMaxLength.toString(16);
-common.expectsError(function() {
+common.expectsError(() => {
buf.toString('latin1');
}, {
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js
index 844c8bcb33..fa7a47cf18 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js
+++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js
@@ -25,7 +25,7 @@ if (!binding.ensureAllocation(2 * kStringMaxLength))
common.skip(skipMessage);
const stringLengthHex = kStringMaxLength.toString(16);
-common.expectsError(function() {
+common.expectsError(() => {
buf.toString('hex');
}, {
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js
index 15ec78b6c9..43c88bd49e 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js
+++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js
@@ -27,9 +27,9 @@ if (!binding.ensureAllocation(2 * kStringMaxLength))
const stringLengthHex = kStringMaxLength.toString(16);
-assert.throws(function() {
+assert.throws(() => {
buf.toString();
-}, function(e) {
+}, (e) => {
if (e.message !== 'Array buffer allocation failed') {
common.expectsError({
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
@@ -43,7 +43,7 @@ assert.throws(function() {
}
});
-common.expectsError(function() {
+common.expectsError(() => {
buf.toString('utf8');
}, {
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js
index d65144e04d..8b419eb436 100644
--- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js
+++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js
@@ -26,7 +26,7 @@ if (!binding.ensureAllocation(2 * kStringMaxLength))
const stringLengthHex = kStringMaxLength.toString(16);
-common.expectsError(function() {
+common.expectsError(() => {
buf.toString('utf16le');
}, {
message: `Cannot create a string longer than 0x${stringLengthHex} ` +