node: sync test-net-connect-no-arg.js (#20608)

This commit is contained in:
Meghan Denny
2025-06-24 00:02:38 -08:00
committed by GitHub
parent 0a3ac50931
commit 050a9cecb7
2 changed files with 7 additions and 8 deletions

View File

@@ -1747,7 +1747,7 @@ JSC_DEFINE_HOST_FUNCTION(Bun::jsFunctionMakeErrorWithCode, (JSC::JSGlobalObject
}
case 2: {
JSValue arg0 = callFrame->argument(1);
// ["foo", "bar", "baz"] -> 'The "foo", "bar", or "baz" argument must be specified'
// ["foo", "bar", "baz"] -> 'The "foo" or "bar" or "baz" argument must be specified'
if (auto* arr = jsDynamicCast<JSC::JSArray*>(arg0)) {
ASSERT(arr->length() > 0);
WTF::StringBuilder builder;
@@ -1755,7 +1755,7 @@ JSC_DEFINE_HOST_FUNCTION(Bun::jsFunctionMakeErrorWithCode, (JSC::JSGlobalObject
for (unsigned i = 0, length = arr->length(); i < length; i++) {
JSValue index = arr->getIndex(globalObject, i);
RETURN_IF_EXCEPTION(scope, {});
if (i == length - 1) builder.append("or "_s);
if (i > 0) builder.append("or "_s);
builder.append('"');
auto* jsString = index.toString(globalObject);
RETURN_IF_EXCEPTION(scope, {});
@@ -1763,7 +1763,6 @@ JSC_DEFINE_HOST_FUNCTION(Bun::jsFunctionMakeErrorWithCode, (JSC::JSGlobalObject
RETURN_IF_EXCEPTION(scope, {});
builder.append(str);
builder.append('"');
if (i != length - 1) builder.append(',');
builder.append(' ');
}
builder.append("argument must be specified"_s);

View File

@@ -5,31 +5,31 @@ const assert = require('assert');
const net = require('net');
// Tests that net.connect() called without arguments throws ERR_MISSING_ARGS.
const message = 'The "options", "port", or "path" argument must be specified';
assert.throws(() => {
net.connect();
}, {
code: 'ERR_MISSING_ARGS',
message,
message: 'The "options" or "port" or "path" argument must be specified',
});
assert.throws(() => {
new net.Socket().connect();
}, {
code: 'ERR_MISSING_ARGS',
message,
message: 'The "options" or "port" or "path" argument must be specified',
});
assert.throws(() => {
net.connect({});
}, {
code: 'ERR_MISSING_ARGS',
message,
message: 'The "options" or "port" or "path" argument must be specified',
});
assert.throws(() => {
new net.Socket().connect({});
}, {
code: 'ERR_MISSING_ARGS',
message,
message: 'The "options" or "port" or "path" argument must be specified',
});