-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Cleanup test file write stream #8894
Conversation
This replace all `var` occurrences in test-file-write-stream.js with `const` (where they are not being reassigned) and `let` (where they are being reassigned).
This add strict comparison to the asserts and if statements: - Replace `assert.equal` with `assert.strictEqual` where: 1. Result of `typeof` being compared to a string literal. 2. Result of `fs.readFileSync` with UTF-8 encoding being compared to a string constant. - Replace `==` with `===` where integer values are being compared to integer literals.
@@ -51,14 +51,14 @@ file | |||
fs.unlinkSync(fn); | |||
}); | |||
|
|||
for (var i = 0; i < 11; i++) { | |||
for (let i = 0; i < 11; i++) { | |||
(function(i) { | |||
file.write('' + i); | |||
})(i); |
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.
I think this can be simplified by removing the IIFE
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.
Removed the IIFE, Thanks for pointing it out.
} | ||
|
||
process.on('exit', function() { | ||
for (var k in callbacks) { | ||
for (const k in callbacks) { | ||
assert.equal(0, callbacks[k], k + ' count off by ' + callbacks[k]); |
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.
Nit: how about using strictEqual
and a template literal 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.
Thanks for pointing it out. Updated it.
This replace a `assert.equal` with a `assert.strictEqual` which was missed in previous commit.
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.
LGTM
LGTM if CI doesn't reveal any issues with the test. Looping in @thealphanerd in case they have an opinion about the introduction of |
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.
LGTM, and fwiw I’m perfectly fine with let
here.
CI failures are unrelated known flaky tests. Landing. |
Replace all `var` occurrences in test-file-write-stream.js with `const` (where they are not being reassigned) and `let` (where they are being reassigned). Add strict comparison to the asserts and if statements: - Replace `assert.equal` with `assert.strictEqual` where: 1. Result of `typeof` being compared to a string literal. 2. Result of `fs.readFileSync` with UTF-8 encoding being compared to a string constant. - Replace `==` with `===` where integer values are being compared to integer literals. Remove unnecessary very IIFE. Use template literals. PR-URL: nodejs#8894 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Landed in 1d4ba1b |
Replace all `var` occurrences in test-file-write-stream.js with `const` (where they are not being reassigned) and `let` (where they are being reassigned). Add strict comparison to the asserts and if statements: - Replace `assert.equal` with `assert.strictEqual` where: 1. Result of `typeof` being compared to a string literal. 2. Result of `fs.readFileSync` with UTF-8 encoding being compared to a string constant. - Replace `==` with `===` where integer values are being compared to integer literals. Remove unnecessary very IIFE. Use template literals. PR-URL: #8894 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Replace all `var` occurrences in test-file-write-stream.js with `const` (where they are not being reassigned) and `let` (where they are being reassigned). Add strict comparison to the asserts and if statements: - Replace `assert.equal` with `assert.strictEqual` where: 1. Result of `typeof` being compared to a string literal. 2. Result of `fs.readFileSync` with UTF-8 encoding being compared to a string constant. - Replace `==` with `===` where integer values are being compared to integer literals. Remove unnecessary very IIFE. Use template literals. PR-URL: #8894 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
Description of change
Some trivial changes to improve the test code in
test/parallel/test-file-write-stream.js
.Submitting this as my first contribution as per instructions from NodeTodo.