Skip to content

Navigation Menu

Sign in
Appearance settings

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

Appearance settings

Commit aae3765

Browse filesBrowse files
BethGriggsMylesBorins
authored andcommitted
test: refactor several parallel/test-timer tests
Change var to const/let. Simplify test-timers-uncaught-exception. Backport-PR-URL: #12401 PR-URL: #10524 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
1 parent cd78a2b commit aae3765
Copy full SHA for aae3765

File tree

Expand file treeCollapse file tree

4 files changed

+13
-36
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+13
-36
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-timers-immediate-queue.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-timers-immediate-queue.js
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ const assert = require('assert');
66
// but immediates queued while processing the current queue should happen
77
// on the next turn of the event loop.
88

9-
// in v0.10 hit should be 1, because we only process one cb per turn
10-
// in v0.11 and beyond it should be the exact same size of QUEUE
11-
// if we're letting things recursively add to the immediate QUEUE hit will be
12-
// > QUEUE
9+
// hit should be the exact same size of QUEUE, if we're letting things
10+
// recursively add to the immediate QUEUE hit will be > QUEUE
1311

1412
let ticked = false;
1513

Collapse file

‎test/parallel/test-timers-non-integer-delay.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-timers-non-integer-delay.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
'use strict';
2+
require('../common');
3+
24
/*
35
* This test makes sure that non-integer timer delays do not make the process
46
* hang. See https://github.com/joyent/node/issues/8065 and
@@ -15,8 +17,6 @@
1517
* it 100%.
1618
*/
1719

18-
require('../common');
19-
2020
const TIMEOUT_DELAY = 1.1;
2121
const NB_TIMEOUTS_FIRED = 50;
2222

Collapse file

‎test/parallel/test-timers-ordering.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-timers-ordering.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22
require('../common');
33
const assert = require('assert');
4-
const Timer = process.binding('timer_wrap').Timer;
54

5+
const Timer = process.binding('timer_wrap').Timer;
66
const N = 30;
77

88
let last_i = 0;
Collapse file
+8-29Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,19 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
33
const assert = require('assert');
44

5-
let exceptions = 0;
6-
let timer1 = 0;
7-
let timer2 = 0;
5+
const errorMsg = 'BAM!';
86

97
// the first timer throws...
10-
console.error('set first timer');
11-
setTimeout(function() {
12-
console.error('first timer');
13-
timer1++;
14-
throw new Error('BAM!');
15-
}, 100);
8+
setTimeout(common.mustCall(function() {
9+
throw new Error(errorMsg);
10+
}), 1);
1611

1712
// ...but the second one should still run
18-
console.error('set second timer');
19-
setTimeout(function() {
20-
console.error('second timer');
21-
assert.strictEqual(timer1, 1);
22-
timer2++;
23-
}, 100);
13+
setTimeout(common.mustCall(function() {}), 1);
2414

2515
function uncaughtException(err) {
26-
console.error('uncaught handler');
27-
assert.strictEqual(err.message, 'BAM!');
28-
exceptions++;
16+
assert.strictEqual(err.message, errorMsg);
2917
}
30-
process.on('uncaughtException', uncaughtException);
3118

32-
let exited = false;
33-
process.on('exit', function() {
34-
assert(!exited);
35-
exited = true;
36-
process.removeListener('uncaughtException', uncaughtException);
37-
assert.strictEqual(exceptions, 1);
38-
assert.strictEqual(timer1, 1);
39-
assert.strictEqual(timer2, 1);
40-
});
19+
process.on('uncaughtException', common.mustCall(uncaughtException));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.