-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
Changes from 1 commit
79d1fbc
c0e7ee8
6dccb02
0739723
fa4eb72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ const a = assert; | |
|
|
||
| function makeBlock(f) { | ||
| const args = Array.prototype.slice.call(arguments, 1); | ||
| return function() { | ||
| return () => { | ||
| return f.apply(this, args); | ||
| }; | ||
| } | ||
|
|
@@ -183,7 +183,7 @@ assert.doesNotThrow(makeBlock(a.deepEqual, a1, a2)); | |
|
|
||
| // having an identical prototype property | ||
| const nbRoot = { | ||
| toString: function() { return `${this.first} ${this.last}`; } | ||
| toString: () => { return `${this.first} ${this.last}`; } | ||
|
Contributor
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. The same.
Contributor
Author
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. Thank you for your review. I'll fix this problem with like: toString() { return `${this.first} ${this.last}`; } |
||
| }; | ||
|
|
||
| function nameBuilder(first, last) { | ||
|
|
@@ -458,10 +458,10 @@ assert.throws(makeBlock(thrower, TypeError)); | |
| 'a.doesNotThrow is not catching type matching errors'); | ||
| } | ||
|
|
||
| assert.throws(function() { assert.ifError(new Error('test error')); }, | ||
| assert.throws(() => { assert.ifError(new Error('test error')); }, | ||
| /^Error: test error$/); | ||
| assert.doesNotThrow(function() { assert.ifError(null); }); | ||
| assert.doesNotThrow(function() { assert.ifError(); }); | ||
| assert.doesNotThrow(() => { assert.ifError(null); }); | ||
| assert.doesNotThrow(() => { assert.ifError(); }); | ||
|
|
||
| assert.throws(() => { | ||
| assert.doesNotThrow(makeBlock(thrower, Error), 'user message'); | ||
|
|
@@ -501,7 +501,7 @@ assert.throws(() => { | |
| let threw = false; | ||
| try { | ||
| assert.throws( | ||
| function() { | ||
| () => { | ||
| throw ({}); // eslint-disable-line no-throw-literal | ||
| }, | ||
| Array | ||
|
|
@@ -516,7 +516,7 @@ assert.throws(() => { | |
| a.throws(makeBlock(thrower, TypeError), /\[object Object\]/); | ||
|
|
||
| // use a fn to validate error object | ||
| a.throws(makeBlock(thrower, TypeError), function(err) { | ||
| a.throws(makeBlock(thrower, TypeError), (err) => { | ||
| if ((err instanceof TypeError) && /\[object Object\]/.test(err)) { | ||
| return true; | ||
| } | ||
|
|
@@ -607,7 +607,7 @@ testAssertionMessage([1, 2, 3], '[ 1, 2, 3 ]'); | |
| testAssertionMessage(/a/, '/a/'); | ||
| testAssertionMessage(/abc/gim, '/abc/gim'); | ||
| testAssertionMessage(function f() {}, '[Function: f]'); | ||
| testAssertionMessage(function() {}, '[Function]'); | ||
| testAssertionMessage(() => {}, '[Function]'); | ||
|
Contributor
Author
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. I think that it should be reverted because What do you think about it ?
Member
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. In my humble opinion, this check would be better to not replace arrow function. Because assert message also should have '[Function]' when |
||
| testAssertionMessage({}, '{}'); | ||
| testAssertionMessage(circular, '{ y: 1, x: [Circular] }'); | ||
| testAssertionMessage({ a: undefined, b: null }, '{ a: undefined, b: null }'); | ||
|
|
@@ -619,7 +619,7 @@ testAssertionMessage({ a: NaN, b: Infinity, c: -Infinity }, | |
| let threw = false; | ||
| try { | ||
| // eslint-disable-next-line no-restricted-syntax | ||
| assert.throws(function() { | ||
| assert.throws(() => { | ||
| assert.ifError(null); | ||
| }); | ||
| } catch (e) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ const { test, assert_equals, assert_true, assert_array_equals } = | |
| License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html | ||
| */ | ||
| /* eslint-disable */ | ||
| test(function() { | ||
| test(() => { | ||
|
Contributor
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. As per the comment above, it seems we should not change this fragment.
Contributor
Author
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.
I'm sorry to have missed it. |
||
| var params = new URLSearchParams('a=b&c=d'); | ||
| assert_array_equals(params.getAll('a'), ['b']); | ||
| assert_array_equals(params.getAll('c'), ['d']); | ||
|
|
@@ -25,7 +25,7 @@ test(function() { | |
| assert_array_equals(params.getAll('a'), ['', 'e']); | ||
| }, 'getAll() basics'); | ||
|
|
||
| test(function() { | ||
| test(() => { | ||
|
Contributor
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. Ditto. |
||
| var params = new URLSearchParams('a=1&a=2&a=3&a'); | ||
| assert_true(params.has('a'), 'Search params object has name "a"'); | ||
| var matches = params.getAll('a'); | ||
|
|
||
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
thislexical. 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
.callnor.applyin this file.This code equivalent to:
Should I replace
thiswithnull?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.