Skip to content

Commit aae3765

Browse 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

4 files changed

Lines changed: 13 additions & 36 deletions

File tree

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

Lines 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
letticked=false;
1513

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

Lines 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
constTIMEOUT_DELAY=1.1;
2121
constNB_TIMEOUTS_FIRED=50;
2222

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22
require('../common');
33
constassert=require('assert');
4-
constTimer=process.binding('timer_wrap').Timer;
54

5+
constTimer=process.binding('timer_wrap').Timer;
66
constN=30;
77

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

5-
letexceptions=0;
6-
lettimer1=0;
7-
lettimer2=0;
5+
consterrorMsg='BAM!';
86

97
// the first timer throws...
10-
console.error('set first timer');
11-
setTimeout(function(){
12-
console.error('first timer');
13-
timer1++;
14-
thrownewError('BAM!');
15-
},100);
8+
setTimeout(common.mustCall(function(){
9+
thrownewError(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
functionuncaughtException(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-
letexited=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)