Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ee40a00

Browse filesBrowse files
GaryGSCtargos
authored andcommitted
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: #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>
1 parent 536d088 commit ee40a00
Copy full SHA for ee40a00

File tree

Expand file treeCollapse file tree

13 files changed

+23
-23
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

13 files changed

+23
-23
lines changed
Open diff view settings
Collapse file

‎test/addons/async-hello-world/test-makecallback.js‎

Copy file name to clipboardExpand all lines: test/addons/async-hello-world/test-makecallback.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const common = require('../../common');
33
const assert = require('assert');
44
const { runMakeCallback } = require(`./build/${common.buildType}/binding`);
55

6-
runMakeCallback(5, common.mustCall(function(err, val) {
6+
runMakeCallback(5, common.mustCall((err, val) => {
77
assert.strictEqual(err, null);
88
assert.strictEqual(val, 10);
99
process.nextTick(common.mustCall());
Collapse file

‎test/addons/async-hello-world/test.js‎

Copy file name to clipboardExpand all lines: test/addons/async-hello-world/test.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const common = require('../../common');
33
const assert = require('assert');
44
const { runCall } = require(`./build/${common.buildType}/binding`);
55

6-
runCall(5, common.mustCall(function(err, val) {
6+
runCall(5, common.mustCall((err, val) => {
77
assert.strictEqual(err, null);
88
assert.strictEqual(val, 10);
99
process.nextTick(common.mustCall());
Collapse file

‎test/addons/make-callback-domain-warning/test.js‎

Copy file name to clipboardExpand all lines: test/addons/make-callback-domain-warning/test.js
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ function makeCallback(object, cb) {
1010
}
1111

1212
let latestWarning = null;
13-
process.on('warning', function(warning) {
13+
process.on('warning', (warning) => {
1414
latestWarning = warning;
1515
});
1616

1717
const d = domain.create();
1818

1919
// When domain is disabled, no warning will be emitted
20-
makeCallback({ domain: d }, common.mustCall(function() {
20+
makeCallback({ domain: d }, common.mustCall(() => {
2121
assert.strictEqual(latestWarning, null);
2222

23-
d.run(common.mustCall(function() {
23+
d.run(common.mustCall(() => {
2424
// No warning will be emitted when no domain property is applied
25-
makeCallback({}, common.mustCall(function() {
25+
makeCallback({}, common.mustCall(() => {
2626
assert.strictEqual(latestWarning, null);
2727

2828
// Warning is emitted when domain property is used and domain is enabled
29-
makeCallback({ domain: d }, common.mustCall(function() {
29+
makeCallback({ domain: d }, common.mustCall(() => {
3030
assert.strictEqual(latestWarning.name, 'DeprecationWarning');
3131
assert.strictEqual(latestWarning.code, 'DEP0097');
3232
}));
Collapse file

‎test/addons/make-callback-recurse/test.js‎

Copy file name to clipboardExpand all lines: test/addons/make-callback-recurse/test.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ assert.throws(() => {
7171
if (arg === 1) {
7272
// The tests are first run on bootstrap during LoadEnvironment() in
7373
// src/node.cc. Now run the tests through node::MakeCallback().
74-
setImmediate(function() {
74+
setImmediate(() => {
7575
makeCallback({}, common.mustCall(() => {
7676
verifyExecutionOrder(2);
7777
}));
Collapse file

‎test/addons/openssl-client-cert-engine/test.js‎

Copy file name to clipboardExpand all lines: test/addons/openssl-client-cert-engine/test.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ const server = https.createServer(serverOptions, common.mustCall((req, res) => {
4343
headers: {}
4444
};
4545

46-
const req = https.request(clientOptions, common.mustCall(function(response) {
46+
const req = https.request(clientOptions, common.mustCall((response) => {
4747
let body = '';
4848
response.setEncoding('utf8');
49-
response.on('data', function(chunk) {
49+
response.on('data', (chunk) => {
5050
body += chunk;
5151
});
5252

53-
response.on('end', common.mustCall(function() {
53+
response.on('end', common.mustCall(() => {
5454
assert.strictEqual(body, 'hello world');
5555
server.close();
5656
}));
Collapse file

‎test/addons/openssl-key-engine/test.js‎

Copy file name to clipboardExpand all lines: test/addons/openssl-key-engine/test.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ const server = https.createServer(serverOptions, common.mustCall((req, res) => {
4545
headers: {}
4646
};
4747

48-
const req = https.request(clientOptions, common.mustCall(function(response) {
48+
const req = https.request(clientOptions, common.mustCall((response) => {
4949
let body = '';
5050
response.setEncoding('utf8');
51-
response.on('data', function(chunk) {
51+
response.on('data', (chunk) => {
5252
body += chunk;
5353
});
5454

55-
response.on('end', common.mustCall(function() {
55+
response.on('end', common.mustCall(() => {
5656
assert.strictEqual(body, 'hello world');
5757
server.close();
5858
}));
Collapse file

‎test/addons/repl-domain-abort/test.js‎

Copy file name to clipboardExpand all lines: test/addons/repl-domain-abort/test.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if (common.isWindows)
3131
buildPath = buildPath.replace(/\\/g, '/');
3232
let cb_ran = false;
3333

34-
process.on('exit', function() {
34+
process.on('exit', () => {
3535
assert(cb_ran);
3636
console.log('ok');
3737
});
Collapse file

‎test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js‎

Copy file name to clipboardExpand all lines: test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if (!binding.ensureAllocation(2 * kStringMaxLength))
2525
common.skip(skipMessage);
2626

2727
const stringLengthHex = kStringMaxLength.toString(16);
28-
common.expectsError(function() {
28+
common.expectsError(() => {
2929
buf.toString('ascii');
3030
}, {
3131
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
Collapse file

‎test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js‎

Copy file name to clipboardExpand all lines: test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if (!binding.ensureAllocation(2 * kStringMaxLength))
2525
common.skip(skipMessage);
2626

2727
const stringLengthHex = kStringMaxLength.toString(16);
28-
common.expectsError(function() {
28+
common.expectsError(() => {
2929
buf.toString('base64');
3030
}, {
3131
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
Collapse file

‎test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js‎

Copy file name to clipboardExpand all lines: test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (!binding.ensureAllocation(2 * kStringMaxLength))
2727
common.skip(skipMessage);
2828

2929
const stringLengthHex = kStringMaxLength.toString(16);
30-
common.expectsError(function() {
30+
common.expectsError(() => {
3131
buf.toString('latin1');
3232
}, {
3333
message: `Cannot create a string longer than 0x${stringLengthHex} ` +

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.