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 fa8baa2

Browse filesBrowse files
TrottItalo A. Casas
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 <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 74ff804 commit fa8baa2
Copy full SHA for fa8baa2

File tree

Expand file treeCollapse file tree

2 files changed

+15
-27
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-27
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-regress-GH-897.js
-20Lines changed: 0 additions & 20 deletions
This file was deleted.
Collapse file

‎test/parallel/test-timers.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-timers.js
+15-7Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
33
const assert = require('assert');
44

55
const inputs = [
@@ -18,13 +18,14 @@ const 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.strictEqual(true, timeouts[index]);
50-
assert.strictEqual(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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.