-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swap arguments in strictEqual() and comment the third argument (test-timers) #21660
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ let interval_count = 0; | |
clearTimeout(null); | ||
clearInterval(null); | ||
|
||
assert.strictEqual(true, setTimeout instanceof Function); | ||
assert.strictEqual(setTimeout instanceof Function, true); | ||
const starttime = new Date(); | ||
setTimeout(common.mustCall(function() { | ||
const endtime = new Date(); | ||
|
@@ -40,7 +40,7 @@ setTimeout(common.mustCall(function() { | |
assert.ok(diff > 0); | ||
console.error(`diff: ${diff}`); | ||
|
||
assert.strictEqual(true, 1000 - WINDOW < diff && diff < 1000 + WINDOW); | ||
assert.strictEqual(1000 - WINDOW < diff && diff < 1000 + WINDOW, true); | ||
}), 1000); | ||
|
||
// this timer shouldn't execute | ||
|
@@ -57,23 +57,23 @@ setInterval(function() { | |
|
||
const t = interval_count * 1000; | ||
|
||
assert.strictEqual(true, t - WINDOW < diff && diff < t + WINDOW); | ||
assert.strictEqual(t - WINDOW < diff && diff < t + WINDOW, true); | ||
|
||
assert.strictEqual(true, interval_count <= 3); | ||
assert.strictEqual(interval_count <= 3, true); | ||
if (interval_count === 3) | ||
clearInterval(this); | ||
}, 1000); | ||
|
||
|
||
// Single param: | ||
setTimeout(function(param) { | ||
assert.strictEqual('test param', param); | ||
assert.strictEqual(param, 'test param'); | ||
}, 1000, 'test param'); | ||
|
||
let interval_count2 = 0; | ||
setInterval(function(param) { | ||
++interval_count2; | ||
assert.strictEqual('test param', param); | ||
assert.strictEqual(param, 'test param'); | ||
|
||
if (interval_count2 === 3) | ||
clearInterval(this); | ||
|
@@ -82,15 +82,15 @@ setInterval(function(param) { | |
|
||
// Multiple param | ||
setTimeout(function(param1, param2) { | ||
assert.strictEqual('param1', param1); | ||
assert.strictEqual('param2', param2); | ||
assert.strictEqual(param1, 'param1'); | ||
assert.strictEqual(param2, 'param2'); | ||
}, 1000, 'param1', 'param2'); | ||
|
||
let interval_count3 = 0; | ||
setInterval(function(param1, param2) { | ||
++interval_count3; | ||
assert.strictEqual('param1', param1); | ||
assert.strictEqual('param2', param2); | ||
assert.strictEqual(param1, 'param1'); | ||
assert.strictEqual(param2, 'param2'); | ||
|
||
if (interval_count3 === 3) | ||
clearInterval(this); | ||
|
@@ -120,8 +120,9 @@ clearTimeout(y); | |
|
||
|
||
process.on('exit', function() { | ||
assert.strictEqual(3, interval_count); | ||
assert.strictEqual(11, count4); | ||
assert.strictEqual(0, expectedTimeouts, | ||
'clearTimeout cleared too many timeouts'); | ||
assert.strictEqual(interval_count, 3); | ||
assert.strictEqual(count4, 11); | ||
|
||
// clearTimeout cleared too many timeouts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Now that I'm looking at it, perhaps the comment might better as: // Check that the correct number of timers ran. |
||
assert.strictEqual(expectedTimeouts, 0); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
assert.ok
? And in some other places./cc @Trott — do we have a reason for a strict check here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.ok()
would be fine here of course, but I'm not terribly bothered by the strict check either.There are 5 other files in our test suite that use
strictEqual()
for aninstanceof
check. If there is consensus that changing it toassert.ok()
would be better, I'd rather change them all at once in a separate PR and add a lint rule.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that should not block this PR, just asking. 😃