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: replace indexOf with includes #12604

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
8 participants
@gwer
Copy link
Contributor

commented Apr 23, 2017

Partly fixes #12586

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)
@refack

This comment has been minimized.

Copy link
Member

commented Apr 23, 2017

@gwer Looks good. But we're still discussing the implication of #12586, so it might take some time to land (or might even be rejected). But thank you very much for the effort!

test/addons-napi/test_constructor/test.js Outdated
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);

This comment has been minimized.

Copy link
@aqrln

aqrln Apr 23, 2017

Member

These should be updated to !propertyNames.includes() too so that the code is consistent.

test/addons-napi/test_properties/test.js Outdated
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);

This comment has been minimized.

Copy link
@aqrln

aqrln Apr 23, 2017

Member

Ditto.

test/addons/repl-domain-abort/test.js Outdated
@@ -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'))

This comment has been minimized.

Copy link
@aqrln

aqrln Apr 23, 2017

Member

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 :)

This comment has been minimized.

Copy link
@refack

refack Apr 23, 2017

Member

I agree, all === 0 could be in a separate PR, and land easily.

@gwer gwer force-pushed the gwer:indexOf-replace branch Apr 23, 2017

assert.ok(propertyNames.includes('readwriteValue'));
assert.ok(propertyNames.includes('readonlyValue'));
assert.ok(!propertyNames.includes('hiddenValue'));
assert.ok(!propertyNames.includes('readwriteAccessor1'));

This comment has been minimized.

Copy link
@refack

@gwer gwer force-pushed the gwer:indexOf-replace branch to d918367 Apr 23, 2017

@aqrln

This comment has been minimized.

@aqrln

aqrln approved these changes Apr 23, 2017

@mscdex

This comment has been minimized.

Copy link
Contributor

commented Apr 23, 2017

I'm -1 on this for the reasons I described in #12586.

@jasnell
Copy link
Member

left a comment

LGTM if CI is green

@gwer

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2017

CI is green now.

@jasnell

This comment has been minimized.

Copy link
Member

commented Apr 24, 2017

@mscdex ... can you use the "request changes" thing on here to put the big red X so folks don't miss your objection.

@mscdex
Copy link
Contributor

left a comment

I'm -1 on this for the reasons I described in #12586.

@refack refack referenced this pull request Apr 27, 2017

Closed

Remove `indexOf` usage from tests in favor of `includes` #12586

0 of 29 tasks complete
@refack

This comment has been minimized.

Copy link
Member

commented Apr 27, 2017

@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?

@gibfahn

This comment has been minimized.

Copy link
Member

commented Apr 27, 2017

@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?

@mscdex

This comment has been minimized.

Copy link
Contributor

commented Apr 27, 2017

@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.

@mscdex mscdex dismissed their stale review Apr 27, 2017

no longer disapprove

@MylesBorins

This comment has been minimized.

Copy link
Member

commented Apr 27, 2017

@refack

This comment has been minimized.

Copy link
Member

commented Apr 27, 2017

@MylesBorins are String.prototype.includes and Array.prototype.includes compatible with v6.x?

@gibfahn

This comment has been minimized.

Copy link
Member

commented Apr 27, 2017

Seems to work for me:

> process.version
'v6.10.1'
> [1,2,3].includes(2)
true
> '123'.includes(2)
true
@aqrln

This comment has been minimized.

Copy link
Member

commented Apr 29, 2017

Given that there are no more objections, I'm going to go ahead and land this.
Fresh CI: https://ci.nodejs.org/job/node-test-pull-request/7749/

@aqrln

This comment has been minimized.

Copy link
Member

commented Apr 30, 2017

Landed in 0142276.

@aqrln aqrln closed this Apr 30, 2017

aqrln added a commit that referenced this pull request Apr 30, 2017

test: replace indexOf with includes
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>

@jasnell jasnell referenced this pull request May 11, 2017

Closed

8.0.0 Release Proposal #12220

@gibfahn gibfahn referenced this pull request Jun 15, 2017

Closed

Auditing for 6.11.1 #230

2 of 3 tasks complete

gibfahn added a commit that referenced this pull request Jun 18, 2017

test: replace indexOf with includes
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>

@gibfahn gibfahn added land-on-v6.x and removed lts-watch-v6.x labels Jun 18, 2017

gibfahn added a commit that referenced this pull request Jun 20, 2017

test: replace indexOf with includes
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>

MylesBorins added a commit that referenced this pull request Jul 11, 2017

test: replace indexOf with includes
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>

@MylesBorins MylesBorins referenced this pull request Jul 18, 2017

Merged

v6.11.2 proposal #14356

gabrielschulhof added a commit to gabrielschulhof/node that referenced this pull request Mar 11, 2018

test: replace indexOf with includes
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.

This applies portions of 0142276 that
are relevant to N-API.

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>

gabrielschulhof added a commit to gabrielschulhof/node that referenced this pull request Mar 31, 2018

test: replace indexOf with includes
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>

gabrielschulhof added a commit to gabrielschulhof/node that referenced this pull request Apr 10, 2018

test: replace indexOf with includes
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>

MylesBorins added a commit that referenced this pull request Apr 16, 2018

test: replace indexOf with includes
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>

@MylesBorins MylesBorins referenced this pull request Apr 16, 2018

Merged

v6.14.2 proposal #19996

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.