Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: use arrow functions in addons tests #30131

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/addons/async-hello-world/test-makecallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion test/addons/async-hello-world/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion test/addons/load-long-path/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
10 changes: 5 additions & 5 deletions test/addons/make-callback-domain-warning/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}));
Expand Down
2 changes: 1 addition & 1 deletion test/addons/make-callback-recurse/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
Expand Down
6 changes: 3 additions & 3 deletions test/addons/openssl-client-cert-engine/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}));
Expand Down
6 changes: 3 additions & 3 deletions test/addons/openssl-key-engine/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}));
Expand Down
2 changes: 1 addition & 1 deletion test/addons/repl-domain-abort/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} ` +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} ` +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} ` +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} ` +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} ` +
Expand All @@ -43,7 +43,7 @@ assert.throws(function() {
}
});

common.expectsError(function() {
common.expectsError(() => {
buf.toString('utf8');
}, {
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} ` +
Expand Down