Skip to content

Commit bc03fb3

Browse 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 <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent c8b080e commit bc03fb3

File tree

1 file changed

+20
-20
lines changed
  • test/addons/make-callback-recurse

1 file changed

+20
-20
lines changed

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const makeCallback = binding.makeCallback;
1010
constmustCallCheckDomains=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
thrownewError('hi from domain error');
1616
});
1717
},/^Error:hifromdomainerror$/);
@@ -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(leti=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
}elseif(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
}elseif(arg===3){
@@ -94,16 +94,16 @@ assert.throws(function(){
9494
functioncheckDomains(){
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
constd1=domain.create();
9999
constd2=domain.create();
100100
constd3=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
constd1=domain.create();
117117
constd2=domain.create();
118118
constd3=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
constd=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
thrownewError(`throw from domain ${id}`);
142142
});
143143
thrownewError('UNREACHABLE');

0 commit comments

Comments
(0)