Skip to content

Commit 31a3328

Browse files
Trottaddaleax
authored andcommitted
test: refactor make-callback-recurse test
Move copy/pasted callback into its own function. PR-URL: #9498 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent 9808985 commit 31a3328

File tree

1 file changed

+9
-27
lines changed
  • test/addons/make-callback-recurse

1 file changed

+9
-27
lines changed

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

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -132,38 +132,20 @@ function checkDomains(){
132132
}));
133133
}),1);
134134

135-
// Make sure nextTick, setImmediate and setTimeout can all recover properly
136-
// after a thrown makeCallback call.
137-
process.nextTick(common.mustCall(function(){
135+
functiontestTimer(id){
136+
// Make sure nextTick, setImmediate and setTimeout can all recover properly
137+
// after a thrown makeCallback call.
138138
constd=domain.create();
139139
d.on('error',common.mustCall(function(e){
140-
assert.strictEqual(e.message,'throw from domain 3');
140+
assert.strictEqual(e.message,`throw from domain ${id}`);
141141
}));
142142
makeCallback({domain: d},function(){
143-
thrownewError('throw from domain 3');
143+
thrownewError(`throw from domain ${id}`);
144144
});
145145
thrownewError('UNREACHABLE');
146-
}));
146+
}
147147

148-
setImmediate(common.mustCall(function(){
149-
constd=domain.create();
150-
d.on('error',common.mustCall(function(e){
151-
assert.strictEqual(e.message,'throw from domain 2');
152-
}));
153-
makeCallback({domain: d},function(){
154-
thrownewError('throw from domain 2');
155-
});
156-
thrownewError('UNREACHABLE');
157-
}));
158-
159-
setTimeout(common.mustCall(function(){
160-
constd=domain.create();
161-
d.on('error',common.mustCall(function(e){
162-
assert.strictEqual(e.message,'throw from domain 1');
163-
}));
164-
makeCallback({domain: d},function(){
165-
thrownewError('throw from domain 1');
166-
});
167-
thrownewError('UNREACHABLE');
168-
}));
148+
process.nextTick(common.mustCall(testTimer),3);
149+
setImmediate(common.mustCall(testTimer),2);
150+
setTimeout(common.mustCall(testTimer),1,1);
169151
}

0 commit comments

Comments
(0)