-
Notifications
You must be signed in to change notification settings - Fork 30k
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
assert: align argument names #22760
Closed
Closed
assert: align argument names #22760
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,8 +62,8 @@ const net = require('net'); | |
const hints = (dns.ADDRCONFIG | dns.V4MAPPED) + 42; | ||
const hintOptBlocks = doConnect([{ hints }], | ||
() => common.mustNotCall()); | ||
for (const block of hintOptBlocks) { | ||
common.expectsError(block, { | ||
for (const fn of hintOptBlocks) { | ||
common.expectsError(fn, { | ||
code: 'ERR_INVALID_OPT_VALUE', | ||
type: TypeError, | ||
message: /The value "\d+" is invalid for option "hints"/ | ||
|
@@ -136,67 +136,59 @@ function doConnect(args, getCb) { | |
function syncFailToConnect(port, assertErr, optOnly) { | ||
if (!optOnly) { | ||
// connect(port, cb) and connect(port) | ||
const portArgBlocks = doConnect([port], () => common.mustNotCall()); | ||
for (const block of portArgBlocks) { | ||
assert.throws(block, | ||
assertErr, | ||
`${block.name}(${port})`); | ||
const portArgFunctions = doConnect([port], () => common.mustNotCall()); | ||
for (const fn of portArgFunctions) { | ||
assert.throws(fn, assertErr, `${fn.name}(${port})`); | ||
} | ||
|
||
// connect(port, host, cb) and connect(port, host) | ||
const portHostArgBlocks = doConnect([port, 'localhost'], | ||
() => common.mustNotCall()); | ||
for (const block of portHostArgBlocks) { | ||
assert.throws(block, | ||
assertErr, | ||
`${block.name}(${port}, 'localhost')`); | ||
const portHostArgFunctions = doConnect([port, 'localhost'], | ||
() => common.mustNotCall()); | ||
for (const fn of portHostArgFunctions) { | ||
assert.throws(fn, assertErr, `${fn.name}(${port}, 'localhost')`); | ||
} | ||
} | ||
// connect({port}, cb) and connect({port}) | ||
const portOptBlocks = doConnect([{ port }], | ||
() => common.mustNotCall()); | ||
for (const block of portOptBlocks) { | ||
assert.throws(block, | ||
assertErr, | ||
`${block.name}({port: ${port}})`); | ||
const portOptFunctions = doConnect([{ port }], () => common.mustNotCall()); | ||
for (const fn of portOptFunctions) { | ||
assert.throws(fn, assertErr, `${fn.name}({port: ${port}})`); | ||
} | ||
|
||
// connect({port, host}, cb) and connect({port, host}) | ||
const portHostOptBlocks = doConnect([{ port: port, host: 'localhost' }], | ||
() => common.mustNotCall()); | ||
for (const block of portHostOptBlocks) { | ||
assert.throws(block, | ||
const portHostOptFunctions = doConnect([{ port: port, host: 'localhost' }], | ||
() => common.mustNotCall()); | ||
for (const fn of portHostOptFunctions) { | ||
assert.throws(fn, | ||
assertErr, | ||
`${block.name}({port: ${port}, host: 'localhost'})`); | ||
`${fn.name}({port: ${port}, host: 'localhost'})`); | ||
} | ||
} | ||
|
||
function canConnect(port) { | ||
const noop = () => common.mustCall(); | ||
|
||
// connect(port, cb) and connect(port) | ||
const portArgBlocks = doConnect([port], noop); | ||
for (const block of portArgBlocks) { | ||
block(); | ||
const portArgFunctions = doConnect([port], noop); | ||
for (const fn of portArgFunctions) { | ||
fn(); | ||
} | ||
|
||
// connect(port, host, cb) and connect(port, host) | ||
const portHostArgBlocks = doConnect([port, 'localhost'], noop); | ||
for (const block of portHostArgBlocks) { | ||
block(); | ||
const portHostArgFunctions = doConnect([port, 'localhost'], noop); | ||
for (const fn of portHostArgFunctions) { | ||
fn(); | ||
} | ||
|
||
// connect({port}, cb) and connect({port}) | ||
const portOptBlocks = doConnect([{ port }], noop); | ||
for (const block of portOptBlocks) { | ||
block(); | ||
const portOptFunctions = doConnect([{ port }], noop); | ||
for (const fn of portOptFunctions) { | ||
fn(); | ||
} | ||
|
||
// connect({port, host}, cb) and connect({port, host}) | ||
const portHostOptBlocks = doConnect([{ port: port, host: 'localhost' }], | ||
noop); | ||
for (const block of portHostOptBlocks) { | ||
block(); | ||
const portHostOptFns = doConnect([{ port: port, host: 'localhost' }], noop); | ||
for (const fn of portHostOptFns) { | ||
fn(); | ||
} | ||
} | ||
|
||
|
@@ -208,21 +200,20 @@ function asyncFailToConnect(port) { | |
|
||
const dont = () => common.mustNotCall(); | ||
// connect(port, cb) and connect(port) | ||
const portArgBlocks = doConnect([port], dont); | ||
for (const block of portArgBlocks) { | ||
block().on('error', onError()); | ||
const portArgFunctions = doConnect([port], dont); | ||
for (const fn of portArgFunctions) { | ||
fn().on('error', onError()); | ||
} | ||
|
||
// connect({port}, cb) and connect({port}) | ||
const portOptBlocks = doConnect([{ port }], dont); | ||
for (const block of portOptBlocks) { | ||
block().on('error', onError()); | ||
const portOptFunctions = doConnect([{ port }], dont); | ||
for (const fn of portOptFunctions) { | ||
fn().on('error', onError()); | ||
} | ||
|
||
// connect({port, host}, cb) and connect({port, host}) | ||
const portHostOptBlocks = doConnect([{ port: port, host: 'localhost' }], | ||
dont); | ||
for (const block of portHostOptBlocks) { | ||
block().on('error', onError()); | ||
const portHostOptFns = doConnect([{ port: port, host: 'localhost' }], dont); | ||
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. |
||
for (const fn of portHostOptFns) { | ||
fn().on('error', onError()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
{ port, host: 'localhost' }
?