The Wayback Machine - https://web.archive.org/web/20250407172940/https://github.com/nodejs/node/commit/31a3328269
Skip to content

Navigation Menu

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

Commit 31a3328

Browse filesBrowse 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 <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
1 parent 9808985 commit 31a3328
Copy full SHA for 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

Copy file name to clipboardexpand all lines: test/addons/make-callback-recurse/test.js
+9-27
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+
function testTimer(id) {
136+
// Make sure nextTick, setImmediate and setTimeout can all recover properly
137+
// after a thrown makeCallback call.
138138
const d = 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-
throw new Error('throw from domain 3');
143+
throw new Error(`throw from domain ${id}`);
144144
});
145145
throw new Error('UNREACHABLE');
146-
}));
146+
}
147147

148-
setImmediate(common.mustCall(function() {
149-
const d = 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-
throw new Error('throw from domain 2');
155-
});
156-
throw new Error('UNREACHABLE');
157-
}));
158-
159-
setTimeout(common.mustCall(function() {
160-
const d = 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-
throw new Error('throw from domain 1');
166-
});
167-
throw new Error('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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.