Skip to content

Conversation

@ruggertech
Copy link
Contributor

@ruggertechruggertech commented Nov 17, 2016

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • commit message follows commit guidelines
Description of change

changed es5 "var" to "const" and anonymous functions to arrow function syntax

@nodejs-github-botnodejs-github-bot added the test Issues and PRs related to the tests. label Nov 17, 2016
@mscdexmscdex added the fs Issues and PRs related to the fs subsystem / file system. label Nov 17, 2016
@mscdex
Copy link
Contributor

@Trott
Copy link
Member

If we're going to refactor the test for mostly stylistic reasons, I'd ask that we also change the three instances of assert.equal() to assert.strictEqual().

@cjihrig
Copy link
Contributor

I agree with @Trott. I think the process.nextTick() that surrounds those assertions should also have a common.mustCall().

@ruggertech
Copy link
ContributorAuthor

done

Copy link
Member

Choose a reason for hiding this comment

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

Use common.mustCall() to make sure those assertions a run, as @cjihrig suggested

Copy link
Contributor

Choose a reason for hiding this comment

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

why did you use an () => here, and leave function() on line 11?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

because I saw that in line 11 the previous developer used a named function expression, contrary to other places where he used an anonymous function in the old form.

Named function expressions can be handy when errors are thrown and I believe that was the reason for using a named function on line 11.
I didn't want to break this behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see your thinking, but think its too subtle, function names don't matter, particularly not in tests. Better change them all.

@sam-github
Copy link
Contributor

const arguably does something useful, es6 functions don't (unless you are trying to access the enclosing this). I don't really mind all the code churn, but if you are going to change some functions to es6, please do them all, so the file is internally consistent.

@ruggertech
Copy link
ContributorAuthor

I changed all the functions in the code except for the function declaration on line 11 which was originally set as a named function, for the sake of easier debugging, by the original developer. I changed all of the anonymous functions to their respective es6 arrow function form, but did not want to affect code stability or ease of debugging by changing line 11.

Should line 11 also be changed?

@sam-github
Copy link
Contributor

I think none should be changed, but if we are going to go all es6y, lets go all the way, not half way.

I'm a bit worried that the wave of "name functions for readability of stack traces" is going to crash against the wave of "use the new es6 function syntax", and leave confusion, but for now, all es6 in this test is fine.

@ruggertech
Copy link
ContributorAuthor

I see your point. Removed the named function to maintain consistency across this file.

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 line can be removed

Copy link
Member

Choose a reason for hiding this comment

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

@ruggertech Do you agree with @targos 's suggestion here?

Copy link
ContributorAuthor

@ruggertechruggertechNov 24, 2016

Choose a reason for hiding this comment

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

I do, will take it off

@ruggertech
Copy link
ContributorAuthor

do we need anything else for this to be merged ?

Copy link
Contributor

@Fishrock123Fishrock123Nov 20, 2016

Choose a reason for hiding this comment

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

It would be better not not invoke common.fail directly but rather wrap it in a function and pass it a message string.

Copy link
ContributorAuthor

@ruggertechruggertechNov 20, 2016

Choose a reason for hiding this comment

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

Something like that:

stream.on('data', () =>{
stream.on('data', () => common.fail('no more "data" events should follow'));
});

?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

done

@sam-github
Copy link
Contributor

commit message doesn't follow guidelines, it's too long and doesn't start with test: , see https://github.com/nodejs/node/blob/master/CONTRIBUTING.md#step-3-commit

Copy link
Contributor

Choose a reason for hiding this comment

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

should be either () => common.fail() or just common.fail.

@cjihrig
Copy link
Contributor

@ruggertech
Copy link
ContributorAuthor

Can someone merge please :-)

Copy link
Member

Choose a reason for hiding this comment

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

arguments now refers to the outer function's arguments. It doesn't change the outcome of the test but I think it's better not to change this one to an arrow function.

implemented arrow functions and changed var to const where appropriate.
@ruggertechruggertech reopened this Dec 3, 2016
@targos
Copy link
Member

Thanks. LGTM. Final CI: https://ci.nodejs.org/job/node-test-pull-request/5155/

jasnell pushed a commit that referenced this pull request Dec 5, 2016
implemented arrow functions and changed var to const where appropriate. PR-URL: #9669 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
@jasnell
Copy link
Member

Landed in ef74e03.

@jasnelljasnell closed this Dec 5, 2016
Fishrock123 pushed a commit that referenced this pull request Dec 6, 2016
implemented arrow functions and changed var to const where appropriate. PR-URL: #9669 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
addaleax pushed a commit to addaleax/node that referenced this pull request Dec 8, 2016
implemented arrow functions and changed var to const where appropriate. PR-URL: nodejs#9669 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
jmdarling pushed a commit to jmdarling/node that referenced this pull request Dec 8, 2016
implemented arrow functions and changed var to const where appropriate. PR-URL: nodejs#9669 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Dec 20, 2016
implemented arrow functions and changed var to const where appropriate. PR-URL: #9669 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Dec 21, 2016
implemented arrow functions and changed var to const where appropriate. PR-URL: #9669 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Dec 21, 2016
implemented arrow functions and changed var to const where appropriate. PR-URL: #9669 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
This was referenced Dec 21, 2016
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fsIssues and PRs related to the fs subsystem / file system.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

14 participants

@ruggertech@mscdex@Trott@cjihrig@sam-github@targos@jasnell@bjouhier@santigimeno@Fishrock123@gibfahn@MylesBorins@addaleax@nodejs-github-bot