Browse Source

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: https://github.com/nodejs/node/pull/9537
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v6.x
Rich Trott 8 years ago
committed by Anna Henningsen
parent
commit
64d7ea9ce4
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 25
      test/sequential/test-next-tick-error-spin.js

25
test/sequential/test-next-tick-error-spin.js

@ -1,24 +1,23 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
if (process.argv[2] !== 'child') { if (process.argv[2] !== 'child') {
var spawn = require('child_process').spawn; const spawn = require('child_process').spawn;
var child = spawn(process.execPath, [__filename, 'child'], { const child = spawn(process.execPath, [__filename, 'child'], {
stdio: 'pipe'//'inherit' stdio: 'pipe'//'inherit'
}); });
var timer = setTimeout(function() { const timer = setTimeout(function() {
throw new Error('child is hung'); throw new Error('child is hung');
}, common.platformTimeout(3000)); }, common.platformTimeout(3000));
child.on('exit', function(code) { child.on('exit', common.mustCall(function(code) {
console.error('ok'); assert.strictEqual(code, 0);
assert(!code);
clearTimeout(timer); clearTimeout(timer);
}); }));
} else { } else {
var domain = require('domain'); const domain = require('domain');
var d = domain.create(); const d = domain.create();
process.maxTickDepth = 10; process.maxTickDepth = 10;
// in the error handler, we trigger several MakeCallback events // in the error handler, we trigger several MakeCallback events
@ -40,10 +39,8 @@ if (process.argv[2] !== 'child') {
} }
f(); f();
setTimeout(function() { setImmediate(function() {
console.error('broke in!'); console.error('broke in!');
//process.stdout.close();
//process.stderr.close();
process.exit(0); process.exit(0);
}); });
} }

Loading…
Cancel
Save