Skip to content

Commit d9362ef

Browse files
TrottMylesBorins
authored andcommitted
test: enhance test-timers
In test-timers, confirm that all input values that should be coerced to 1 ms are not being coerced to a significantly larger value. This eliminates the need for the separate test-regress-GH-897. PR-URL: #10960 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 291346e commit d9362ef

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

test/parallel/test-regress-GH-897.js

-20
This file was deleted.

test/parallel/test-timers.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
2-
require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
3+
const assert = require('assert');
44

55
var inputs = [
66
undefined,
@@ -18,13 +18,14 @@ var inputs = [
1818
-10,
1919
-1,
2020
-0.5,
21+
-0.1,
2122
-0.0,
2223
0,
2324
0.0,
25+
0.1,
2426
0.5,
2527
1,
2628
1.0,
27-
10,
2829
2147483648, // browser behaviour: timeouts > 2^31-1 run on next tick
2930
12345678901234 // ditto
3031
];
@@ -43,10 +44,17 @@ inputs.forEach(function(value, index) {
4344
}, value);
4445
});
4546

46-
process.on('exit', function() {
47-
// assert that all timers have run
47+
// All values in inputs array coerce to 1 ms. Therefore, they should all run
48+
// before a timer set here for 2 ms.
49+
50+
setTimeout(common.mustCall(function() {
51+
// assert that all other timers have run
4852
inputs.forEach(function(value, index) {
49-
assert.equal(true, timeouts[index]);
50-
assert.equal(true, intervals[index]);
53+
assert(timeouts[index]);
54+
assert(intervals[index]);
5155
});
52-
});
56+
}), 2);
57+
58+
// Test 10 ms timeout separately.
59+
setTimeout(common.mustCall(function() {}), 10);
60+
setInterval(common.mustCall(function() { clearInterval(this); }), 10);

0 commit comments

Comments
 (0)