Skip to content

Conversation

@Trott
Copy link
Member

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.

@TrottTrott 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
MemberAuthor

@cjihrig
Copy link
Contributor

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

@silverwind It is already supported in strict mode.

@silverwind
Copy link
Contributor

Oh, I never knew, thanks!

@cjihrig
Copy link
Contributor

@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.
@TrottTrottforce-pushed the no-redeclare-test-assert branch from 7cb700f to 73bb5bbCompareJanuary 25, 2016 19:19
@Trott
Copy link
MemberAuthor

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

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 <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
@Trott
Copy link
MemberAuthor

Landed in 34daaa7

@TrottTrott 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 <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
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 <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
@jasnell
Copy link
Member

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 <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
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 <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
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 <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
@MylesBorinsMylesBorins 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 <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
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 <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
@TrottTrott deleted the no-redeclare-test-assert branch January 13, 2022 22:32
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

assertIssues and PRs related to the assert subsystem.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@Trott@cjihrig@silverwind@targos@jasnell@MylesBorins