Skip to content
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

test: Change declaration by var to let. #9711

Closed
wants to merge 2 commits into from

Conversation

ubansi
Copy link

@ubansi ubansi commented Nov 20, 2016

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

none

Description of change

I narrowed the scope of local variables in for on test-buffer-fill.js.
Since i and tmp are not used outside of for, they do not have to be var declarations.

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Nov 20, 2016
@@ -249,8 +249,8 @@ function writeToFill(string, offset, end, encoding) {

// Correction for UCS2 operations.
if (os.endianness() === 'BE' && encoding === 'ucs2') {
for (var i = 0; i < buf2.length; i += 2) {
var tmp = buf2[i];
for (let i = 0; i < buf2.length; i += 2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its against no-let-in-for-loop rule.

CC: @Trott

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference: #9045

Copy link
Member

@Trott Trott Nov 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That rule was created to help people avoid the whole "using let in for loops is slow" performance problem. I would avoid it. EDIT: Whoops, but that applies to lib, not test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably doesn't matter for tests though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. It's only enabled in the lib directory.

for (var i = 0; i < buf2.length; i += 2) {
var tmp = buf2[i];
for (let i = 0; i < buf2.length; i += 2) {
let tmp = buf2[i];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can even be const.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so too.
so Fixed :)

@addaleax
Copy link
Member

Your author name in this commit is given as “ubansi”. Is that intended or do you prefer to be listed (changelog, git log, AUTHORS file) with some other name? People typically prefer their full name, but ultimately it’s up to you.

@Trott
Copy link
Member

Trott commented Nov 20, 2016

How about changing the two instances of assert.equal() in this file to assert.strictEqual()?

@mscdex mscdex added the buffer Issues and PRs related to the buffer subsystem. label Nov 20, 2016
@ubansi
Copy link
Author

ubansi commented Nov 21, 2016

@addaleax It's ok. Thank you.

@ubansi
Copy link
Author

ubansi commented Nov 21, 2016

@Trott I tried it after your advice.
but that is not simple issue.
I don't know why,

assert.strictEqual(Buffer.allocUnsafe(1).fill('\u0222', 'ucs2')[0], os.endianness() === 'LE' ? 0x22 : 0x02);

this code is faild in win10.
but.

Buffer.allocUnsafe(1).fill('\u0222', 'ucs2')[0] === (os.endianness() === 'LE' ? 0x22 : 0x02) //true

I stop it this time.

@ubansi
Copy link
Author

ubansi commented Nov 24, 2016

@Trott It was just a Lint error.
solved.

@ubansi ubansi force-pushed the var_to_let branch 5 times, most recently from 5c17df5 to 6355c2c Compare November 30, 2016 17:02
@ubansi ubansi changed the title test:Change declaration by var to let. test: Change declaration by var to let. Dec 5, 2016
I narrowed the scope of local variables in "for" on test.
Because "tmp" is never changed.
@italoacasas
Copy link
Contributor

@Trott
Copy link
Member

Trott commented Jan 17, 2017

@italoacasas I'm pretty sure rebasing this will make it a no-op. There's no var left in that file. I think @cjihrig did a mass "use const and let everywhere in the test directory" change.

@Trott
Copy link
Member

Trott commented Jan 17, 2017

I'm going to close this because I don't think it's applicable to the file anymore. If I'm mistaken, please comment here and/or re-open. Thanks!

@Trott Trott closed this Jan 17, 2017
@cjihrig
Copy link
Contributor

cjihrig commented Jan 17, 2017

I think @cjihrig did a mass "use const and let everywhere in the test directory" change.

Partially me. Mostly @gibfahn

@Trott
Copy link
Member

Trott commented Jan 17, 2017

Partially me. Mostly @gibfahn

Oh, sorry, yeah, @gibfahn! I've been really good at failing to credit the people who do the hard work lately. Gotta be better about that....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants