-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: replace indexOf with includes #12604
Conversation
assert.ok(propertyNames.indexOf('readonlyValue') >= 0); | ||
assert.ok(propertyNames.includes('echo')); | ||
assert.ok(propertyNames.includes('readwriteValue')); | ||
assert.ok(propertyNames.includes('readonlyValue')); | ||
assert.ok(propertyNames.indexOf('hiddenValue') < 0); | ||
assert.ok(propertyNames.indexOf('readwriteAccessor1') < 0); | ||
assert.ok(propertyNames.indexOf('readwriteAccessor2') < 0); |
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.
These should be updated to !propertyNames.includes()
too so that the code is consistent.
assert.ok(propertyNames.indexOf('readonlyValue') >= 0); | ||
assert.ok(propertyNames.includes('echo')); | ||
assert.ok(propertyNames.includes('readwriteValue')); | ||
assert.ok(propertyNames.includes('readonlyValue')); | ||
assert.ok(propertyNames.indexOf('hiddenValue') < 0); |
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.
@@ -54,7 +54,7 @@ dInput._read = function _read(size) { | |||
}; | |||
|
|||
dOutput._write = function _write(chunk, encoding, cb) { | |||
if (chunk.toString().indexOf('cb_ran') === 0) | |||
if (chunk.toString().startsWith('cb_ran')) |
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 it makes sense to decouple changes to startsWith
to a different PR. As far as I can see from the discussion in #12586, that PR won't be controversial like this one may potentially be :)
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 agree, all === 0
could be in a separate PR, and land easily.
assert.ok(propertyNames.includes('readwriteValue')); | ||
assert.ok(propertyNames.includes('readonlyValue')); | ||
assert.ok(!propertyNames.includes('hiddenValue')); | ||
assert.ok(!propertyNames.includes('readwriteAccessor1')); |
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.
👍
Partly fixes nodejs#12586
I'm -1 on this for the reasons I described in #12586. |
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 if CI is green
CI is green now. |
@mscdex ... can you use the "request changes" thing on here to put the big red X so folks don't miss your objection. |
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'm -1 on this for the reasons I described in #12586.
@mscdex the @nodejs/lts have deceived that "theoretically test improvements wouldn't be backported to maintenance branches" will you be willing to lift your objection? |
@mscdex at the last LTS meeting we agreed that test changes will not be backported (except in some once-in-a-blue-moon occasion where it's really crucial). Given that, do you still object? cc/ @nodejs/lts , does anyone have an issue with these changes landing now? |
@gibfahn It's not just general test changes (e.g. adding |
Test changes still need to be backport to v6.x
…On Apr 27, 2017 1:36 PM, "Brian White" ***@***.***> wrote:
@gibfahn <https://github.com/gibfahn> It's not just general test changes
(e.g. adding common.mustCall() in places) but even things like
non-semver-major changes that get backported that include tests (that may
use .includes()). I guess as long as whoever is backporting doesn't mind
having to change commit(s) for v4.x, then it's fine. Anyway, it seems I'm
in the minority here, so I say go ahead.
—
You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub
<#12604 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAecV1aOe51sQVfSSHJ6mImzE3pcvlSTks5r0NIxgaJpZM4NFQYt>
.
|
@MylesBorins are |
Seems to work for me: > process.version
'v6.10.1'
> [1,2,3].includes(2)
true
> '123'.includes(2)
true |
Given that there are no more objections, I'm going to go ahead and land this. |
Landed in 0142276. |
Start the transition to Array.prototype.includes() and String.prototype.includes(). This commit refactors most of the comparisons of Array.prototype.indexOf() and String.prototype.indexOf() return values with -1 to the former methods in tests. PR-URL: #12604 Refs: #12586 Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Start the transition to Array.prototype.includes() and String.prototype.includes(). This commit refactors most of the comparisons of Array.prototype.indexOf() and String.prototype.indexOf() return values with -1 to the former methods in tests. PR-URL: #12604 Refs: #12586 Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Start the transition to Array.prototype.includes() and String.prototype.includes(). This commit refactors most of the comparisons of Array.prototype.indexOf() and String.prototype.indexOf() return values with -1 to the former methods in tests. PR-URL: #12604 Refs: #12586 Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Start the transition to Array.prototype.includes() and String.prototype.includes(). This commit refactors most of the comparisons of Array.prototype.indexOf() and String.prototype.indexOf() return values with -1 to the former methods in tests. PR-URL: #12604 Refs: #12586 Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Start the transition to Array.prototype.includes() and String.prototype.includes(). This commit refactors most of the comparisons of Array.prototype.indexOf() and String.prototype.indexOf() return values with -1 to the former methods in tests. PR-URL: nodejs#12604 Refs: nodejs#12586 Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Start the transition to Array.prototype.includes() and String.prototype.includes(). This commit refactors most of the comparisons of Array.prototype.indexOf() and String.prototype.indexOf() return values with -1 to the former methods in tests. Backport-PR-URL: #19447 PR-URL: #12604 Refs: #12586 Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Partly fixes #12586
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)