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: scope redeclared variable #4854

Closed
wants to merge 1 commit into from

Conversation

Trott
Copy link
Member

@Trott Trott commented Jan 25, 2016

test-assert.js redeclares a variable with var. This change converts
it to a const declaration and wraps it in an IIFE to scope it to just
the test that uses it.

@Trott Trott added assert Issues and PRs related to the assert subsystem. test Issues and PRs related to the tests. labels Jan 25, 2016
@Trott
Copy link
Member Author

Trott commented Jan 25, 2016

@cjihrig
Copy link
Contributor

cjihrig commented Jan 25, 2016

LGTM

One thing we might want to consider while moving forward with block scoping is that we don't need to use IIFEs. The changes in this PR could just be wrapped in curly braces and create a new block scope.

@silverwind
Copy link
Contributor

@cjihrig do you know since when v8 supports the curly scope thing? Is it listed on the ES6 table?

@targos
Copy link
Member

targos commented Jan 25, 2016

@silverwind It is already supported in strict mode.

@silverwind
Copy link
Contributor

Oh, I never knew, thanks!

@cjihrig
Copy link
Contributor

cjihrig commented Jan 25, 2016

@silverwind I think it's just part of the definition of block scope. It works at least back to io.js v1.0.0.

@silverwind
Copy link
Contributor

So called standalone blocks seem to have been around since JavaScript 1.0 according to MDN. It's the combination of strict mode creating a scope on them and block scoped vars that makes them useful now.

`test-assert.js` redeclares a variable with `var`. This change converts
it to a `const` declaration and wraps it in a standalone block to scope
it to just the test that uses it.
@Trott Trott force-pushed the no-redeclare-test-assert branch from 7cb700f to 73bb5bb Compare January 25, 2016 19:19
@Trott
Copy link
Member Author

Trott commented Jan 25, 2016

I sure like the idea of not having the creation of a function as unnecessary overhead. Converted to block scope, force pushed, looks good.

CI: https://ci.nodejs.org/job/node-test-pull-request/1373/

@silverwind
Copy link
Contributor

LGTM

1 similar comment
@targos
Copy link
Member

targos commented Jan 25, 2016

LGTM

Trott added a commit to Trott/io.js that referenced this pull request Jan 26, 2016
`test-assert.js` redeclares a variable with `var`. This change converts
it to a `const` declaration and wraps it in a standalone block to scope
it to just the test that uses it.

PR-URL: nodejs#4854
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
@Trott
Copy link
Member Author

Trott commented Jan 26, 2016

Landed in 34daaa7

@Trott Trott closed this Jan 26, 2016
rvagg pushed a commit that referenced this pull request Jan 27, 2016
`test-assert.js` redeclares a variable with `var`. This change converts
it to a `const` declaration and wraps it in a standalone block to scope
it to just the test that uses it.

PR-URL: #4854
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
benjamingr pushed a commit to benjamingr/io.js that referenced this pull request Jan 27, 2016
`test-assert.js` redeclares a variable with `var`. This change converts
it to a `const` declaration and wraps it in a standalone block to scope
it to just the test that uses it.

PR-URL: nodejs#4854
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
@jasnell
Copy link
Member

jasnell commented Jan 27, 2016

Added the lts-watch-v4.x label. For commits like this, getting them on the lts-watch list for v4.x helps significantly when determining which commits need to be cherry picked. We cherry pick almost all the test commits unless they specifically relate to semver-minor/major updates.

rvagg pushed a commit that referenced this pull request Feb 8, 2016
`test-assert.js` redeclares a variable with `var`. This change converts
it to a `const` declaration and wraps it in a standalone block to scope
it to just the test that uses it.

PR-URL: #4854
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
MylesBorins pushed a commit that referenced this pull request Feb 17, 2016
`test-assert.js` redeclares a variable with `var`. This change converts
it to a `const` declaration and wraps it in a standalone block to scope
it to just the test that uses it.

PR-URL: #4854
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
MylesBorins pushed a commit that referenced this pull request Feb 18, 2016
`test-assert.js` redeclares a variable with `var`. This change converts
it to a `const` declaration and wraps it in a standalone block to scope
it to just the test that uses it.

PR-URL: #4854
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Feb 18, 2016
MylesBorins pushed a commit that referenced this pull request Mar 2, 2016
`test-assert.js` redeclares a variable with `var`. This change converts
it to a `const` declaration and wraps it in a standalone block to scope
it to just the test that uses it.

PR-URL: #4854
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
`test-assert.js` redeclares a variable with `var`. This change converts
it to a `const` declaration and wraps it in a standalone block to scope
it to just the test that uses it.

PR-URL: nodejs#4854
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
@Trott Trott deleted the no-redeclare-test-assert branch January 13, 2022 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert Issues and PRs related to the assert subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants