Skip to content

Commit dae3d3e

Browse files
Trottaddaleax
authored andcommitted
test: refactor test-next-tick-error-spin
* use common.mustCall() * setTimeout() -> setImmediate() * assert() -> assert.strictEqual() * var -> const * remove unneeded console.log() * remove commented-out code PR-URL: #9537 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 8c859d5 commit dae3d3e

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed
+11-14
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
3+
const assert = require('assert');
44

55
if (process.argv[2] !== 'child') {
6-
var spawn = require('child_process').spawn;
7-
var child = spawn(process.execPath, [__filename, 'child'], {
6+
const spawn = require('child_process').spawn;
7+
const child = spawn(process.execPath, [__filename, 'child'], {
88
stdio: 'pipe'//'inherit'
99
});
10-
var timer = setTimeout(function() {
10+
const timer = setTimeout(function() {
1111
throw new Error('child is hung');
1212
}, common.platformTimeout(3000));
13-
child.on('exit', function(code) {
14-
console.error('ok');
15-
assert(!code);
13+
child.on('exit', common.mustCall(function(code) {
14+
assert.strictEqual(code, 0);
1615
clearTimeout(timer);
17-
});
16+
}));
1817
} else {
1918

20-
var domain = require('domain');
21-
var d = domain.create();
19+
const domain = require('domain');
20+
const d = domain.create();
2221
process.maxTickDepth = 10;
2322

2423
// in the error handler, we trigger several MakeCallback events
@@ -40,10 +39,8 @@ if (process.argv[2] !== 'child') {
4039
}
4140

4241
f();
43-
setTimeout(function() {
42+
setImmediate(function() {
4443
console.error('broke in!');
45-
//process.stdout.close();
46-
//process.stderr.close();
4744
process.exit(0);
4845
});
4946
}

0 commit comments

Comments
 (0)