-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: refactor several parallel/test-timer tests
Change var to const/let. Simplify test-timers-uncaught-exception. PR-URL: #10524 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
- Loading branch information
1 parent
dba8d20
commit 0a2fb0d
Showing
5 changed files
with
29 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,18 @@ | ||
'use strict'; | ||
require('../common'); | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
var exceptions = 0; | ||
var timer1 = 0; | ||
var timer2 = 0; | ||
const errorMsg = 'BAM!'; | ||
|
||
// the first timer throws... | ||
console.error('set first timer'); | ||
setTimeout(function() { | ||
console.error('first timer'); | ||
timer1++; | ||
throw new Error('BAM!'); | ||
}, 100); | ||
setTimeout(common.mustCall(function() { | ||
throw new Error(errorMsg); | ||
}), 1); | ||
|
||
// ...but the second one should still run | ||
console.error('set second timer'); | ||
setTimeout(function() { | ||
console.error('second timer'); | ||
assert.equal(timer1, 1); | ||
timer2++; | ||
}, 100); | ||
setTimeout(common.mustCall(function() {}), 1); | ||
|
||
function uncaughtException(err) { | ||
console.error('uncaught handler'); | ||
assert.equal(err.message, 'BAM!'); | ||
exceptions++; | ||
assert.strictEqual(err.message, errorMsg); | ||
} | ||
process.on('uncaughtException', uncaughtException); | ||
|
||
var exited = false; | ||
process.on('exit', function() { | ||
assert(!exited); | ||
exited = true; | ||
process.removeListener('uncaughtException', uncaughtException); | ||
assert.equal(exceptions, 1); | ||
assert.equal(timer1, 1); | ||
assert.equal(timer2, 1); | ||
}); | ||
process.on('uncaughtException', common.mustCall(uncaughtException)); |