Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
test: replace function with arrow function#17345
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
Among the list of [Code and Learn](nodejs/code-and-learn#72 (comment)), I solved the unfinished task of replacing function with arrow function
| functionmakeBlock(f){ | ||
| constargs=Array.prototype.slice.call(arguments,1); | ||
| returnfunction(){ | ||
| return()=>{ |
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.
This makes this lexical. Is it OK 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.
Thank you for your review.
I think that it is OK because test passed locally.
It is not called with neither .call nor .apply in this file.
This code equivalent to:
return()=>{returnf.apply(null,args);};Should I replace this with null ?
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.
Maybe, for a clarity, but let's see what others think)
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 got it.
Please let us know what others think.
test/parallel/test-assert.js Outdated
| // having an identical prototype property | ||
| constnbRoot={ | ||
| toString: function(){return`${this.first}${this.last}`;} | ||
| toString: ()=>{return`${this.first}${this.last}`;} |
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.
The same.
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.
Thank you for your review.
I was mistaken.
I'll fix this problem with like:
toString(){return`${this.first}${this.last}`;}| */ | ||
| /* eslint-disable */ | ||
| test(function(){ | ||
| test(()=>{ |
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.
As per the comment above, it seems we should not change this fragment.
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.
Modifications to them should be upstreamed first.
I'm sorry to have missed it.
I'll revert changes in this file.
| },'getAll() basics'); | ||
| test(function(){ | ||
| test(()=>{ |
vsemozhetbytNov 27, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
Ditto.
Arrow function makes `this` lexical scope. But toString expects evaluate `this` in runtime.
These tests are copied from WPT. I should not changed it directly.
test/parallel/test-assert.js Outdated
| testAssertionMessage(/abc/gim,'/abc/gim'); | ||
| testAssertionMessage(functionf(){},'[Function: f]'); | ||
| testAssertionMessage(function(){},'[Function]'); | ||
| testAssertionMessage(()=>{},'[Function]'); |
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 that it should be reverted because function(){} and () =>{} are should be tested both.
This PR changes only syntax, should not change test case.
So it better of separated by another PR.
What do you think about it ?
test/parallel/test-assert.js Outdated
| testAssertionMessage(/abc/gim,'/abc/gim'); | ||
| testAssertionMessage(functionf(){},'[Function: f]'); | ||
| testAssertionMessage(function(){},'[Function]'); | ||
| testAssertionMessage(()=>{},'[Function]'); |
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.
In my humble opinion, this check would be better to not replace arrow function. Because assert message also should have '[Function]' when function(){} is input.
We would be better to check both function style arrow function and normal function.
makeBlock does not need `this`. update `this` with `null` to clarify the intent.
vsemozhetbyt commented Nov 27, 2017
`function(){}` and `() =>{}` are should be tested both. See also #17345 (comment)vsemozhetbyt commented Nov 27, 2017
vsemozhetbyt commented Nov 27, 2017
Hmm. It seems CI does not post status to PR currently. |
Leko commented Nov 27, 2017
Yesterday, status integration is worked fine. |
Leko commented Nov 29, 2017
Hi @vsemozhetbyt. |
vsemozhetbyt commented Nov 29, 2017
@Leko Sorry for the delay. Let's run the CI again. If it is green, we will land it today. |
Leko commented Nov 29, 2017
@vsemozhetbyt I got it. Thank you for quick reply ! |
vsemozhetbyt commented Nov 29, 2017
One CI failure seems unrelated. Landing... |
1. Among the list of Code and Learn, I solved the unfinished task of replacing function with arrow function: nodejs/code-and-learn#72 (comment) 2. Replace arrow function with shorter property syntax Arrow function makes `this` lexical scope. But toString expects evaluate `this` in runtime. 3. Replace this with null makeBlock does not need `this`. update `this` with `null` to clarify the intent. PR-URL: #17345 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]>
vsemozhetbyt commented Nov 29, 2017
1. Among the list of Code and Learn, I solved the unfinished task of replacing function with arrow function: nodejs/code-and-learn#72 (comment) 2. Replace arrow function with shorter property syntax Arrow function makes `this` lexical scope. But toString expects evaluate `this` in runtime. 3. Replace this with null makeBlock does not need `this`. update `this` with `null` to clarify the intent. PR-URL: #17345 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]>
1. Among the list of Code and Learn, I solved the unfinished task of replacing function with arrow function: nodejs/code-and-learn#72 (comment) 2. Replace arrow function with shorter property syntax Arrow function makes `this` lexical scope. But toString expects evaluate `this` in runtime. 3. Replace this with null makeBlock does not need `this`. update `this` with `null` to clarify the intent. PR-URL: #17345 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]>
1. Among the list of Code and Learn, I solved the unfinished task of replacing function with arrow function: nodejs/code-and-learn#72 (comment) 2. Replace arrow function with shorter property syntax Arrow function makes `this` lexical scope. But toString expects evaluate `this` in runtime. 3. Replace this with null makeBlock does not need `this`. update `this` with `null` to clarify the intent. PR-URL: #17345 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]>
1. Among the list of Code and Learn, I solved the unfinished task of replacing function with arrow function: nodejs/code-and-learn#72 (comment) 2. Replace arrow function with shorter property syntax Arrow function makes `this` lexical scope. But toString expects evaluate `this` in runtime. 3. Replace this with null makeBlock does not need `this`. update `this` with `null` to clarify the intent. PR-URL: #17345 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]>
This is part of Nodefest's Code and Learn nodejs/code-and-learn#72
Among the list of Code and Learn, I solved the unfinished task of replacing function with arrow function
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
test