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 d96e8b6

Browse filesBrowse files
mpark86targos
authored andcommitted
test: use arrow functions for callbacks
Use arrow functions for callbacks in test/addons/make-callback-recurse/test.js. PR-URL: #30069 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent d586070 commit d96e8b6
Copy full SHA for d96e8b6

File tree

Expand file treeCollapse file tree

1 file changed

+20
-20
lines changed
Open diff view settings
Filter options
  • test/addons/make-callback-recurse
Expand file treeCollapse file tree

1 file changed

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

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

Copy file name to clipboardExpand all lines: test/addons/make-callback-recurse/test.js
+20-20Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const makeCallback = binding.makeCallback;
1010
const mustCallCheckDomains = common.mustCall(checkDomains);
1111

1212
// Make sure that using MakeCallback allows the error to propagate.
13-
assert.throws(function() {
14-
makeCallback({}, function() {
13+
assert.throws(() => {
14+
makeCallback({}, () => {
1515
throw new Error('hi from domain error');
1616
});
1717
}, /^Error: hi from domain error$/);
@@ -27,22 +27,22 @@ assert.throws(function() {
2727

2828
// Processing of the MicrotaskQueue is manually handled by node. They are not
2929
// processed until after the nextTickQueue has been processed.
30-
Promise.resolve(1).then(common.mustCall(function() {
30+
Promise.resolve(1).then(common.mustCall(() => {
3131
results.push(7);
3232
}));
3333

3434
// The nextTick should run after all immediately invoked calls.
35-
process.nextTick(common.mustCall(function() {
35+
process.nextTick(common.mustCall(() => {
3636
results.push(3);
3737

3838
// Run same test again but while processing the nextTickQueue to make sure
3939
// the following MakeCallback call breaks in the middle of processing the
4040
// queue and allows the script to run normally.
41-
process.nextTick(common.mustCall(function() {
41+
process.nextTick(common.mustCall(() => {
4242
results.push(6);
4343
}));
4444

45-
makeCallback({}, common.mustCall(function() {
45+
makeCallback({}, common.mustCall(() => {
4646
results.push(4);
4747
}));
4848

@@ -54,7 +54,7 @@ assert.throws(function() {
5454
// MakeCallback is calling the function immediately, but should then detect
5555
// that a script is already in the middle of execution and return before
5656
// either the nextTickQueue or MicrotaskQueue are processed.
57-
makeCallback({}, common.mustCall(function() {
57+
makeCallback({}, common.mustCall(() => {
5858
results.push(1);
5959
}));
6060

@@ -63,7 +63,7 @@ assert.throws(function() {
6363
// and process them immediately.
6464
results.push(2);
6565

66-
setImmediate(common.mustCall(function() {
66+
setImmediate(common.mustCall(() => {
6767
for (let i = 0; i < results.length; i++) {
6868
assert.strictEqual(results[i], i,
6969
`verifyExecutionOrder(${arg}) results: ${results}`);
@@ -72,14 +72,14 @@ assert.throws(function() {
7272
// The tests are first run on bootstrap during LoadEnvironment() in
7373
// src/node.cc. Now run the tests through node::MakeCallback().
7474
setImmediate(function() {
75-
makeCallback({}, common.mustCall(function() {
75+
makeCallback({}, common.mustCall(() => {
7676
verifyExecutionOrder(2);
7777
}));
7878
});
7979
} else if (arg === 2) {
8080
// Make sure there are no conflicts using node::MakeCallback()
8181
// within timers.
82-
setTimeout(common.mustCall(function() {
82+
setTimeout(common.mustCall(() => {
8383
verifyExecutionOrder(3);
8484
}), 10);
8585
} else if (arg === 3) {
@@ -94,16 +94,16 @@ assert.throws(function() {
9494
function checkDomains() {
9595
// Check that domains are properly entered/exited when called in multiple
9696
// levels from both node::MakeCallback() and AsyncWrap::MakeCallback
97-
setImmediate(common.mustCall(function() {
97+
setImmediate(common.mustCall(() => {
9898
const d1 = domain.create();
9999
const d2 = domain.create();
100100
const d3 = domain.create();
101101

102-
makeCallback({ domain: d1 }, common.mustCall(function() {
102+
makeCallback({ domain: d1 }, common.mustCall(() => {
103103
assert.strictEqual(d1, process.domain);
104-
makeCallback({ domain: d2 }, common.mustCall(function() {
104+
makeCallback({ domain: d2 }, common.mustCall(() => {
105105
assert.strictEqual(d2, process.domain);
106-
makeCallback({ domain: d3 }, common.mustCall(function() {
106+
makeCallback({ domain: d3 }, common.mustCall(() => {
107107
assert.strictEqual(d3, process.domain);
108108
}));
109109
assert.strictEqual(d2, process.domain);
@@ -112,16 +112,16 @@ function checkDomains() {
112112
}));
113113
}));
114114

115-
setTimeout(common.mustCall(function() {
115+
setTimeout(common.mustCall(() => {
116116
const d1 = domain.create();
117117
const d2 = domain.create();
118118
const d3 = domain.create();
119119

120-
makeCallback({ domain: d1 }, common.mustCall(function() {
120+
makeCallback({ domain: d1 }, common.mustCall(() => {
121121
assert.strictEqual(d1, process.domain);
122-
makeCallback({ domain: d2 }, common.mustCall(function() {
122+
makeCallback({ domain: d2 }, common.mustCall(() => {
123123
assert.strictEqual(d2, process.domain);
124-
makeCallback({ domain: d3 }, common.mustCall(function() {
124+
makeCallback({ domain: d3 }, common.mustCall(() => {
125125
assert.strictEqual(d3, process.domain);
126126
}));
127127
assert.strictEqual(d2, process.domain);
@@ -134,10 +134,10 @@ function checkDomains() {
134134
// Make sure nextTick, setImmediate and setTimeout can all recover properly
135135
// after a thrown makeCallback call.
136136
const d = domain.create();
137-
d.on('error', common.mustCall(function(e) {
137+
d.on('error', common.mustCall((e) => {
138138
assert.strictEqual(e.message, `throw from domain ${id}`);
139139
}));
140-
makeCallback({ domain: d }, function() {
140+
makeCallback({ domain: d }, () => {
141141
throw new Error(`throw from domain ${id}`);
142142
});
143143
throw new Error('UNREACHABLE');

0 commit comments

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