test: replace assert.throws w/ common.expectsError
PR-URL: https://github.com/nodejs/node/pull/17498 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Jon Moss <me@jonathanmoss.me>
This commit is contained in:
parent
20d6b8c6c0
commit
eae0c05697
@ -72,28 +72,28 @@ server.listen(0, common.mustCall(function() {
|
|||||||
':path',
|
':path',
|
||||||
':authority',
|
':authority',
|
||||||
':scheme'
|
':scheme'
|
||||||
].forEach((header) => assert.throws(
|
].forEach((header) => common.expectsError(
|
||||||
() => response.setHeader(header, 'foobar'),
|
() => response.setHeader(header, 'foobar'),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED',
|
code: 'ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED',
|
||||||
type: Error,
|
type: Error,
|
||||||
message: 'Cannot set HTTP/2 pseudo-headers'
|
message: 'Cannot set HTTP/2 pseudo-headers'
|
||||||
})
|
})
|
||||||
));
|
);
|
||||||
assert.throws(function() {
|
common.expectsError(function() {
|
||||||
response.setHeader(real, null);
|
response.setHeader(real, null);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_HTTP2_INVALID_HEADER_VALUE',
|
code: 'ERR_HTTP2_INVALID_HEADER_VALUE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Invalid value "null" for header "foo-bar"'
|
message: 'Invalid value "null" for header "foo-bar"'
|
||||||
}));
|
});
|
||||||
assert.throws(function() {
|
common.expectsError(function() {
|
||||||
response.setHeader(real, undefined);
|
response.setHeader(real, undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_HTTP2_INVALID_HEADER_VALUE',
|
code: 'ERR_HTTP2_INVALID_HEADER_VALUE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Invalid value "undefined" for header "foo-bar"'
|
message: 'Invalid value "undefined" for header "foo-bar"'
|
||||||
}));
|
});
|
||||||
common.expectsError(
|
common.expectsError(
|
||||||
() => response.setHeader(), // header name undefined
|
() => response.setHeader(), // header name undefined
|
||||||
{
|
{
|
||||||
|
@ -34,24 +34,24 @@ server.listen(0, common.mustCall(function() {
|
|||||||
response.statusCode = realStatusCodes.internalServerError;
|
response.statusCode = realStatusCodes.internalServerError;
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.throws(function() {
|
common.expectsError(function() {
|
||||||
response.statusCode = realStatusCodes.continue;
|
response.statusCode = realStatusCodes.continue;
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_HTTP2_INFO_STATUS_NOT_ALLOWED',
|
code: 'ERR_HTTP2_INFO_STATUS_NOT_ALLOWED',
|
||||||
type: RangeError
|
type: RangeError
|
||||||
}));
|
});
|
||||||
assert.throws(function() {
|
common.expectsError(function() {
|
||||||
response.statusCode = fakeStatusCodes.tooLow;
|
response.statusCode = fakeStatusCodes.tooLow;
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_HTTP2_STATUS_INVALID',
|
code: 'ERR_HTTP2_STATUS_INVALID',
|
||||||
type: RangeError
|
type: RangeError
|
||||||
}));
|
});
|
||||||
assert.throws(function() {
|
common.expectsError(function() {
|
||||||
response.statusCode = fakeStatusCodes.tooHigh;
|
response.statusCode = fakeStatusCodes.tooHigh;
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_HTTP2_STATUS_INVALID',
|
code: 'ERR_HTTP2_STATUS_INVALID',
|
||||||
type: RangeError
|
type: RangeError
|
||||||
}));
|
});
|
||||||
|
|
||||||
response.on('finish', common.mustCall(function() {
|
response.on('finish', common.mustCall(function() {
|
||||||
server.close();
|
server.close();
|
||||||
|
@ -44,25 +44,25 @@ assert.doesNotThrow(() => http2.getPackedSettings({ enablePush: false }));
|
|||||||
['maxHeaderListSize', -1],
|
['maxHeaderListSize', -1],
|
||||||
['maxHeaderListSize', 2 ** 32]
|
['maxHeaderListSize', 2 ** 32]
|
||||||
].forEach((i) => {
|
].forEach((i) => {
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
http2.getPackedSettings({ [i[0]]: i[1] });
|
http2.getPackedSettings({ [i[0]]: i[1] });
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
|
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
|
||||||
type: RangeError,
|
type: RangeError,
|
||||||
message: `Invalid value for setting "${i[0]}": ${i[1]}`
|
message: `Invalid value for setting "${i[0]}": ${i[1]}`
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
[
|
[
|
||||||
1, null, '', Infinity, new Date(), {}, NaN, [false]
|
1, null, '', Infinity, new Date(), {}, NaN, [false]
|
||||||
].forEach((i) => {
|
].forEach((i) => {
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
http2.getPackedSettings({ enablePush: i });
|
http2.getPackedSettings({ enablePush: i });
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
|
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: `Invalid value for setting "enablePush": ${i}`
|
message: `Invalid value for setting "enablePush": ${i}`
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -99,23 +99,23 @@ assert.doesNotThrow(() => http2.getPackedSettings({ enablePush: false }));
|
|||||||
0x00, 0x02, 0x00, 0x00, 0x00, 0x01]);
|
0x00, 0x02, 0x00, 0x00, 0x00, 0x01]);
|
||||||
|
|
||||||
[1, true, '', [], {}, NaN].forEach((i) => {
|
[1, true, '', [], {}, NaN].forEach((i) => {
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
http2.getUnpackedSettings(i);
|
http2.getUnpackedSettings(i);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message:
|
message:
|
||||||
'The "buf" argument must be one of type Buffer, TypedArray, or DataView'
|
'The "buf" argument must be one of type Buffer, TypedArray, or DataView'
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
http2.getUnpackedSettings(packed.slice(5));
|
http2.getUnpackedSettings(packed.slice(5));
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH',
|
code: 'ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH',
|
||||||
type: RangeError,
|
type: RangeError,
|
||||||
message: 'Packed settings length must be a multiple of six'
|
message: 'Packed settings length must be a multiple of six'
|
||||||
}));
|
});
|
||||||
|
|
||||||
const settings = http2.getUnpackedSettings(packed);
|
const settings = http2.getUnpackedSettings(packed);
|
||||||
|
|
||||||
@ -160,24 +160,24 @@ assert.doesNotThrow(() => http2.getPackedSettings({ enablePush: false }));
|
|||||||
{
|
{
|
||||||
const packed = Buffer.from([0x00, 0x05, 0x01, 0x00, 0x00, 0x00]);
|
const packed = Buffer.from([0x00, 0x05, 0x01, 0x00, 0x00, 0x00]);
|
||||||
|
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
http2.getUnpackedSettings(packed, { validate: true });
|
http2.getUnpackedSettings(packed, { validate: true });
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
|
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
|
||||||
type: RangeError,
|
type: RangeError,
|
||||||
message: 'Invalid value for setting "maxFrameSize": 16777216'
|
message: 'Invalid value for setting "maxFrameSize": 16777216'
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for maxConcurrentStreams failing the max number
|
// check for maxConcurrentStreams failing the max number
|
||||||
{
|
{
|
||||||
const packed = Buffer.from([0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFF]);
|
const packed = Buffer.from([0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFF]);
|
||||||
|
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
http2.getUnpackedSettings(packed, { validate: true });
|
http2.getUnpackedSettings(packed, { validate: true });
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
|
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
|
||||||
type: RangeError,
|
type: RangeError,
|
||||||
message: 'Invalid value for setting "maxConcurrentStreams": 4294967295'
|
message: 'Invalid value for setting "maxConcurrentStreams": 4294967295'
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
@ -18,19 +18,19 @@ const afterRespondregex =
|
|||||||
|
|
||||||
function onStream(stream, headers, flags) {
|
function onStream(stream, headers, flags) {
|
||||||
|
|
||||||
assert.throws(() => stream.additionalHeaders({ ':status': 201 }),
|
common.expectsError(() => stream.additionalHeaders({ ':status': 201 }),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_HTTP2_INVALID_INFO_STATUS',
|
code: 'ERR_HTTP2_INVALID_INFO_STATUS',
|
||||||
type: RangeError,
|
type: RangeError,
|
||||||
message: /^Invalid informational status code: 201$/
|
message: /^Invalid informational status code: 201$/
|
||||||
}));
|
});
|
||||||
|
|
||||||
assert.throws(() => stream.additionalHeaders({ ':status': 101 }),
|
common.expectsError(() => stream.additionalHeaders({ ':status': 101 }),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_HTTP2_STATUS_101',
|
code: 'ERR_HTTP2_STATUS_101',
|
||||||
type: Error,
|
type: Error,
|
||||||
message: status101regex
|
message: status101regex
|
||||||
}));
|
});
|
||||||
|
|
||||||
common.expectsError(
|
common.expectsError(
|
||||||
() => stream.additionalHeaders({ ':method': 'POST' }),
|
() => stream.additionalHeaders({ ':method': 'POST' }),
|
||||||
@ -50,12 +50,12 @@ function onStream(stream, headers, flags) {
|
|||||||
':status': 200
|
':status': 200
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.throws(() => stream.additionalHeaders({ abc: 123 }),
|
common.expectsError(() => stream.additionalHeaders({ abc: 123 }),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_HTTP2_HEADERS_AFTER_RESPOND',
|
code: 'ERR_HTTP2_HEADERS_AFTER_RESPOND',
|
||||||
type: Error,
|
type: Error,
|
||||||
message: afterRespondregex
|
message: afterRespondregex
|
||||||
}));
|
});
|
||||||
|
|
||||||
stream.end('hello world');
|
stream.end('hello world');
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto)
|
||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
const assert = require('assert');
|
|
||||||
const h2 = require('http2');
|
const h2 = require('http2');
|
||||||
|
|
||||||
const server = h2.createServer();
|
const server = h2.createServer();
|
||||||
@ -19,10 +18,10 @@ function onStream(stream, headers, flags) {
|
|||||||
':method',
|
':method',
|
||||||
':scheme'
|
':scheme'
|
||||||
].forEach((i) => {
|
].forEach((i) => {
|
||||||
assert.throws(() => stream.respond({ [i]: '/' }),
|
common.expectsError(() => stream.respond({ [i]: '/' }),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_HTTP2_INVALID_PSEUDOHEADER'
|
code: 'ERR_HTTP2_INVALID_PSEUDOHEADER'
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
stream.respond({
|
stream.respond({
|
||||||
|
@ -17,11 +17,11 @@ let clients = 2;
|
|||||||
function doTest(session) {
|
function doTest(session) {
|
||||||
for (let n = 0; n < maxPendingAck; n++)
|
for (let n = 0; n < maxPendingAck; n++)
|
||||||
assert.doesNotThrow(() => session.settings({ enablePush: false }));
|
assert.doesNotThrow(() => session.settings({ enablePush: false }));
|
||||||
assert.throws(() => session.settings({ enablePush: false }),
|
common.expectsError(() => session.settings({ enablePush: false }),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_HTTP2_MAX_PENDING_SETTINGS_ACK',
|
code: 'ERR_HTTP2_MAX_PENDING_SETTINGS_ACK',
|
||||||
type: Error
|
type: Error
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
server.on('stream', common.mustNotCall());
|
server.on('stream', common.mustNotCall());
|
||||||
|
@ -27,17 +27,17 @@ const {
|
|||||||
[],
|
[],
|
||||||
[{}]
|
[{}]
|
||||||
].forEach((i) => {
|
].forEach((i) => {
|
||||||
assert.throws(() => assertIsObject(i, 'foo', 'Object'),
|
common.expectsError(() => assertIsObject(i, 'foo', 'Object'),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
message: /^The "foo" argument must be of type Object$/
|
message: /^The "foo" argument must be of type Object$/
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.doesNotThrow(() => assertWithinRange('foo', 1, 0, 2));
|
assert.doesNotThrow(() => assertWithinRange('foo', 1, 0, 2));
|
||||||
|
|
||||||
assert.throws(() => assertWithinRange('foo', 1, 2, 3),
|
common.expectsError(() => assertWithinRange('foo', 1, 2, 3),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
|
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
|
||||||
message: /^Invalid value for setting "foo": 1$/
|
message: /^Invalid value for setting "foo": 1$/
|
||||||
}));
|
});
|
||||||
|
@ -52,91 +52,91 @@ errors.E('TEST_ERROR_2', (a, b) => `${a} ${b}`);
|
|||||||
assert.strictEqual(err.code, 'TEST_ERROR_1');
|
assert.strictEqual(err.code, 'TEST_ERROR_1');
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.Error('TEST_FOO_KEY'),
|
() => new errors.Error('TEST_FOO_KEY'),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey('TEST_FOO_KEY')
|
message: invalidKey('TEST_FOO_KEY')
|
||||||
}));
|
});
|
||||||
// Calling it twice yields same result (using the key does not create it)
|
// Calling it twice yields same result (using the key does not create it)
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.Error('TEST_FOO_KEY'),
|
() => new errors.Error('TEST_FOO_KEY'),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey('TEST_FOO_KEY')
|
message: invalidKey('TEST_FOO_KEY')
|
||||||
}));
|
});
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.Error(1),
|
() => new errors.Error(1),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey(1)
|
message: invalidKey(1)
|
||||||
}));
|
});
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.Error({}),
|
() => new errors.Error({}),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey('\\[object Object\\]')
|
message: invalidKey('\\[object Object\\]')
|
||||||
}));
|
});
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.Error([]),
|
() => new errors.Error([]),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey('')
|
message: invalidKey('')
|
||||||
}));
|
});
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.Error(true),
|
() => new errors.Error(true),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey('true')
|
message: invalidKey('true')
|
||||||
}));
|
});
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.TypeError(1),
|
() => new errors.TypeError(1),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey(1)
|
message: invalidKey(1)
|
||||||
}));
|
});
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.TypeError({}),
|
() => new errors.TypeError({}),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey('\\[object Object\\]')
|
message: invalidKey('\\[object Object\\]')
|
||||||
}));
|
});
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.TypeError([]),
|
() => new errors.TypeError([]),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey('')
|
message: invalidKey('')
|
||||||
}));
|
});
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.TypeError(true),
|
() => new errors.TypeError(true),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey('true')
|
message: invalidKey('true')
|
||||||
}));
|
});
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.RangeError(1),
|
() => new errors.RangeError(1),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey(1)
|
message: invalidKey(1)
|
||||||
}));
|
});
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.RangeError({}),
|
() => new errors.RangeError({}),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey('\\[object Object\\]')
|
message: invalidKey('\\[object Object\\]')
|
||||||
}));
|
});
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.RangeError([]),
|
() => new errors.RangeError([]),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey('')
|
message: invalidKey('')
|
||||||
}));
|
});
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new errors.RangeError(true),
|
() => new errors.RangeError(true),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: invalidKey('true')
|
message: invalidKey('true')
|
||||||
}));
|
});
|
||||||
|
|
||||||
|
|
||||||
// Tests for common.expectsError
|
// Tests for common.expectsError
|
||||||
@ -166,25 +166,25 @@ assert.doesNotThrow(() => {
|
|||||||
}, common.expectsError({ code: 'TEST_ERROR_1', type: Error }));
|
}, common.expectsError({ code: 'TEST_ERROR_1', type: Error }));
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
throw new errors.TypeError('TEST_ERROR_1', 'a');
|
throw new errors.TypeError('TEST_ERROR_1', 'a');
|
||||||
}, common.expectsError({ code: 'TEST_ERROR_1', type: RangeError }));
|
}, { code: 'TEST_ERROR_1', type: RangeError });
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: /^.+ is not instance of \S/
|
message: /^.+ is not instance of \S/
|
||||||
}));
|
});
|
||||||
|
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
throw new errors.TypeError('TEST_ERROR_1', 'a');
|
throw new errors.TypeError('TEST_ERROR_1', 'a');
|
||||||
}, common.expectsError({ code: 'TEST_ERROR_1',
|
}, { code: 'TEST_ERROR_1',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: /^Error for testing 2/ }));
|
message: /^Error for testing 2/ });
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: /.+ does not match \S/
|
message: /.+ does not match \S/
|
||||||
}));
|
});
|
||||||
|
|
||||||
// // Test ERR_INVALID_ARG_TYPE
|
// // Test ERR_INVALID_ARG_TYPE
|
||||||
assert.strictEqual(errors.message('ERR_INVALID_ARG_TYPE', ['a', 'b']),
|
assert.strictEqual(errors.message('ERR_INVALID_ARG_TYPE', ['a', 'b']),
|
||||||
@ -229,12 +229,12 @@ assert.strictEqual(errors.message('ERR_INVALID_URL_SCHEME', [['http', 'ftp']]),
|
|||||||
'The URL must be one of scheme http or ftp');
|
'The URL must be one of scheme http or ftp');
|
||||||
assert.strictEqual(errors.message('ERR_INVALID_URL_SCHEME', [['a', 'b', 'c']]),
|
assert.strictEqual(errors.message('ERR_INVALID_URL_SCHEME', [['a', 'b', 'c']]),
|
||||||
'The URL must be one of scheme a, b, or c');
|
'The URL must be one of scheme a, b, or c');
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => errors.message('ERR_INVALID_URL_SCHEME', [[]]),
|
() => errors.message('ERR_INVALID_URL_SCHEME', [[]]),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: /^At least one expected value needs to be specified$/
|
message: /^At least one expected value needs to be specified$/
|
||||||
}));
|
});
|
||||||
|
|
||||||
// Test ERR_MISSING_ARGS
|
// Test ERR_MISSING_ARGS
|
||||||
assert.strictEqual(errors.message('ERR_MISSING_ARGS', ['name']),
|
assert.strictEqual(errors.message('ERR_MISSING_ARGS', ['name']),
|
||||||
@ -243,12 +243,12 @@ assert.strictEqual(errors.message('ERR_MISSING_ARGS', ['name', 'value']),
|
|||||||
'The "name" and "value" arguments must be specified');
|
'The "name" and "value" arguments must be specified');
|
||||||
assert.strictEqual(errors.message('ERR_MISSING_ARGS', ['a', 'b', 'c']),
|
assert.strictEqual(errors.message('ERR_MISSING_ARGS', ['a', 'b', 'c']),
|
||||||
'The "a", "b", and "c" arguments must be specified');
|
'The "a", "b", and "c" arguments must be specified');
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => errors.message('ERR_MISSING_ARGS'),
|
() => errors.message('ERR_MISSING_ARGS'),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: /^At least one arg needs to be specified$/
|
message: /^At least one arg needs to be specified$/
|
||||||
}));
|
});
|
||||||
|
|
||||||
// Test ERR_SOCKET_BAD_PORT
|
// Test ERR_SOCKET_BAD_PORT
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
|
@ -59,16 +59,16 @@ assert.throws(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
require,
|
require,
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: /^missing path$/
|
message: /^missing path$/
|
||||||
}));
|
});
|
||||||
|
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => { require({}); },
|
() => { require({}); },
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
message: /^path must be a string$/
|
message: /^path must be a string$/
|
||||||
}));
|
});
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const assert = require('assert');
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const fp = '/tmp/fadagagsdfgsdf';
|
const fp = '/tmp/fadagagsdfgsdf';
|
||||||
@ -15,8 +14,8 @@ const assert = require('assert');
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => net.createConnection({ path: {} }),
|
() => net.createConnection({ path: {} }),
|
||||||
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE' })
|
{ code: 'ERR_INVALID_ARG_TYPE' }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -63,11 +63,11 @@ const net = require('net');
|
|||||||
const hintOptBlocks = doConnect([{ hints: hints }],
|
const hintOptBlocks = doConnect([{ hints: hints }],
|
||||||
() => common.mustNotCall());
|
() => common.mustNotCall());
|
||||||
for (const block of hintOptBlocks) {
|
for (const block of hintOptBlocks) {
|
||||||
assert.throws(block, common.expectsError({
|
common.expectsError(block, {
|
||||||
code: 'ERR_INVALID_OPT_VALUE',
|
code: 'ERR_INVALID_OPT_VALUE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: /The value "\d+" is invalid for option "hints"/
|
message: /The value "\d+" is invalid for option "hints"/
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,12 +13,12 @@ function connectThrows(input) {
|
|||||||
lookup: input
|
lookup: input
|
||||||
};
|
};
|
||||||
|
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
net.connect(opts);
|
net.connect(opts);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError
|
type: TypeError
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
connectDoesNotThrow(() => {});
|
connectDoesNotThrow(() => {});
|
||||||
|
@ -57,12 +57,12 @@ const listenOnPort = [
|
|||||||
const block = () => {
|
const block = () => {
|
||||||
net.createServer().listen(options, common.mustNotCall());
|
net.createServer().listen(options, common.mustNotCall());
|
||||||
};
|
};
|
||||||
assert.throws(block,
|
common.expectsError(block,
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_INVALID_OPT_VALUE',
|
code: 'ERR_INVALID_OPT_VALUE',
|
||||||
type: Error,
|
type: Error,
|
||||||
message: /^The value "{.*}" is invalid for option "options"$/
|
message: /^The value "{.*}" is invalid for option "options"$/
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldFailToListen(false, { port: false });
|
shouldFailToListen(false, { port: false });
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
assert.throws(function() { net.createServer('path'); },
|
common.expectsError(function() { net.createServer('path'); },
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError
|
type: TypeError
|
||||||
}));
|
});
|
||||||
|
|
||||||
assert.throws(function() { net.createServer(0); },
|
common.expectsError(function() { net.createServer(0); },
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError
|
type: TypeError
|
||||||
}));
|
});
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
const server = net.createServer().listen(0, connectToServer);
|
const server = net.createServer().listen(0, connectToServer);
|
||||||
|
|
||||||
function connectToServer() {
|
function connectToServer() {
|
||||||
const client = net.createConnection(this.address().port, () => {
|
const client = net.createConnection(this.address().port, () => {
|
||||||
assert.throws(() => client.write(1337),
|
common.expectsError(() => client.write(1337),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError
|
type: TypeError
|
||||||
}));
|
});
|
||||||
|
|
||||||
client.end();
|
client.end();
|
||||||
})
|
})
|
||||||
|
@ -225,13 +225,13 @@ function checkFormat(path, testCases) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[null, undefined, 1, true, false, 'string'].forEach((pathObject) => {
|
[null, undefined, 1, true, false, 'string'].forEach((pathObject) => {
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
path.format(pathObject);
|
path.format(pathObject);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "pathObject" argument must be of type Object. ' +
|
message: 'The "pathObject" argument must be of type Object. ' +
|
||||||
`Received type ${typeName(pathObject)}`
|
`Received type ${typeName(pathObject)}`
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,9 @@ const typeErrorTests = [true, false, 7, null, {}, undefined, [], NaN];
|
|||||||
function fail(fn) {
|
function fail(fn) {
|
||||||
const args = Array.from(arguments).slice(1);
|
const args = Array.from(arguments).slice(1);
|
||||||
|
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
fn.apply(null, args);
|
fn.apply(null, args);
|
||||||
}, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }));
|
}, { code: 'ERR_INVALID_ARG_TYPE', type: TypeError });
|
||||||
}
|
}
|
||||||
|
|
||||||
typeErrorTests.forEach((test) => {
|
typeErrorTests.forEach((test) => {
|
||||||
|
@ -71,12 +71,12 @@ const {
|
|||||||
|
|
||||||
{
|
{
|
||||||
[1, {}, [], null, undefined, Infinity].forEach((i) => {
|
[1, {}, [], null, undefined, Infinity].forEach((i) => {
|
||||||
assert.throws(() => performance.timerify(i),
|
common.expectsError(() => performance.timerify(i),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "fn" argument must be of type Function'
|
message: 'The "fn" argument must be of type Function'
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,19 +3,19 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
assert.strictEqual(process.assert(1, 'error'), undefined);
|
assert.strictEqual(process.assert(1, 'error'), undefined);
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
process.assert(undefined, 'errorMessage');
|
process.assert(undefined, 'errorMessage');
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
type: Error,
|
type: Error,
|
||||||
message: 'errorMessage'
|
message: 'errorMessage'
|
||||||
})
|
}
|
||||||
);
|
);
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
process.assert(false);
|
process.assert(false);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
type: Error,
|
type: Error,
|
||||||
message: 'assertion error'
|
message: 'assertion error'
|
||||||
})
|
}
|
||||||
);
|
);
|
||||||
|
@ -33,34 +33,34 @@ validateTuple(tuple);
|
|||||||
validateTuple(process.hrtime(tuple));
|
validateTuple(process.hrtime(tuple));
|
||||||
|
|
||||||
// test that only an Array may be passed to process.hrtime()
|
// test that only an Array may be passed to process.hrtime()
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
process.hrtime(1);
|
process.hrtime(1);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "time" argument must be of type Array. Received type number'
|
message: 'The "time" argument must be of type Array. Received type number'
|
||||||
}));
|
});
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
process.hrtime([]);
|
process.hrtime([]);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARRAY_LENGTH',
|
code: 'ERR_INVALID_ARRAY_LENGTH',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The array "time" (length 0) must be of length 2.'
|
message: 'The array "time" (length 0) must be of length 2.'
|
||||||
}));
|
});
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
process.hrtime([1]);
|
process.hrtime([1]);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARRAY_LENGTH',
|
code: 'ERR_INVALID_ARRAY_LENGTH',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The array "time" (length 1) must be of length 2.'
|
message: 'The array "time" (length 1) must be of length 2.'
|
||||||
}));
|
});
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
process.hrtime([1, 2, 3]);
|
process.hrtime([1, 2, 3]);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARRAY_LENGTH',
|
code: 'ERR_INVALID_ARRAY_LENGTH',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The array "time" (length 3) must be of length 2.'
|
message: 'The array "time" (length 3) must be of length 2.'
|
||||||
}));
|
});
|
||||||
|
|
||||||
function validateTuple(tuple) {
|
function validateTuple(tuple) {
|
||||||
assert(Array.isArray(tuple));
|
assert(Array.isArray(tuple));
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
|
||||||
const N = 2;
|
const N = 2;
|
||||||
|
|
||||||
function cb() {
|
function cb() {
|
||||||
@ -39,10 +38,10 @@ process.on('exit', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
[null, 1, 'test', {}, [], Infinity, true].forEach((i) => {
|
[null, 1, 'test', {}, [], Infinity, true].forEach((i) => {
|
||||||
assert.throws(() => process.nextTick(i),
|
common.expectsError(() => process.nextTick(i),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_INVALID_CALLBACK',
|
code: 'ERR_INVALID_CALLBACK',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Callback must be a function'
|
message: 'Callback must be a function'
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
@ -73,13 +73,13 @@ assert.doesNotThrow(() => readline.cursorTo(writable, 'a', 'b'));
|
|||||||
assert.strictEqual(writable.data, '');
|
assert.strictEqual(writable.data, '');
|
||||||
|
|
||||||
writable.data = '';
|
writable.data = '';
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => readline.cursorTo(writable, 'a', 1),
|
() => readline.cursorTo(writable, 'a', 1),
|
||||||
common.expectsError({
|
{
|
||||||
type: Error,
|
type: Error,
|
||||||
code: 'ERR_INVALID_CURSOR_POS',
|
code: 'ERR_INVALID_CURSOR_POS',
|
||||||
message: 'Cannot set cursor row without setting its column'
|
message: 'Cannot set cursor row without setting its column'
|
||||||
}));
|
});
|
||||||
assert.strictEqual(writable.data, '');
|
assert.strictEqual(writable.data, '');
|
||||||
|
|
||||||
writable.data = '';
|
writable.data = '';
|
||||||
|
@ -14,25 +14,25 @@ net.Server().listen(0, function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// The first argument is a configuration object
|
// The first argument is a configuration object
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
net.Server().listen({ port: invalidPort }, common.mustNotCall());
|
net.Server().listen({ port: invalidPort }, common.mustNotCall());
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_SOCKET_BAD_PORT',
|
code: 'ERR_SOCKET_BAD_PORT',
|
||||||
type: RangeError
|
type: RangeError
|
||||||
}));
|
});
|
||||||
|
|
||||||
// The first argument is the port, no IP given.
|
// The first argument is the port, no IP given.
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
net.Server().listen(invalidPort, common.mustNotCall());
|
net.Server().listen(invalidPort, common.mustNotCall());
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_SOCKET_BAD_PORT',
|
code: 'ERR_SOCKET_BAD_PORT',
|
||||||
type: RangeError
|
type: RangeError
|
||||||
}));
|
});
|
||||||
|
|
||||||
// The first argument is the port, the second an IP.
|
// The first argument is the port, the second an IP.
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
net.Server().listen(invalidPort, '0.0.0.0', common.mustNotCall());
|
net.Server().listen(invalidPort, '0.0.0.0', common.mustNotCall());
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_SOCKET_BAD_PORT',
|
code: 'ERR_SOCKET_BAD_PORT',
|
||||||
type: RangeError
|
type: RangeError
|
||||||
}));
|
});
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
|
||||||
|
|
||||||
// Should be an invalid package path.
|
// Should be an invalid package path.
|
||||||
assert.throws(() => require('package.json'),
|
common.expectsError(() => require('package.json'),
|
||||||
common.expectsError({ code: 'MODULE_NOT_FOUND' })
|
{ code: 'MODULE_NOT_FOUND' }
|
||||||
);
|
);
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
const assert = require('assert');
|
|
||||||
|
|
||||||
const readable = new stream.Readable();
|
const readable = new stream.Readable();
|
||||||
|
|
||||||
assert.throws(() => readable.read(), common.expectsError({
|
common.expectsError(() => readable.read(), {
|
||||||
code: 'ERR_STREAM_READ_NOT_IMPLEMENTED',
|
code: 'ERR_STREAM_READ_NOT_IMPLEMENTED',
|
||||||
type: Error,
|
type: Error,
|
||||||
message: '_read() is not implemented'
|
message: '_read() is not implemented'
|
||||||
}));
|
});
|
||||||
|
@ -68,13 +68,13 @@ r._read = function(n) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function pushError() {
|
function pushError() {
|
||||||
assert.throws(function() {
|
common.expectsError(function() {
|
||||||
r.push(Buffer.allocUnsafe(1));
|
r.push(Buffer.allocUnsafe(1));
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_STREAM_PUSH_AFTER_EOF',
|
code: 'ERR_STREAM_PUSH_AFTER_EOF',
|
||||||
type: Error,
|
type: Error,
|
||||||
message: 'stream.push() after EOF'
|
message: 'stream.push() after EOF'
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -86,13 +86,13 @@ w._write = function(chunk, encoding, cb) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
r.on('end', common.mustCall(function() {
|
r.on('end', common.mustCall(function() {
|
||||||
assert.throws(function() {
|
common.expectsError(function() {
|
||||||
r.unshift(Buffer.allocUnsafe(1));
|
r.unshift(Buffer.allocUnsafe(1));
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_STREAM_UNSHIFT_AFTER_END_EVENT',
|
code: 'ERR_STREAM_UNSHIFT_AFTER_END_EVENT',
|
||||||
type: Error,
|
type: Error,
|
||||||
message: 'stream.unshift() after end event'
|
message: 'stream.unshift() after end event'
|
||||||
}));
|
});
|
||||||
w.end();
|
w.end();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const timers = require('timers');
|
const timers = require('timers');
|
||||||
const assert = require('assert');
|
|
||||||
|
|
||||||
[
|
[
|
||||||
{},
|
{},
|
||||||
@ -11,12 +10,12 @@ const assert = require('assert');
|
|||||||
() => { },
|
() => { },
|
||||||
Symbol('foo')
|
Symbol('foo')
|
||||||
].forEach((val) => {
|
].forEach((val) => {
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => timers.enroll({}, val),
|
() => timers.enroll({}, val),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError
|
type: TypeError
|
||||||
})
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -25,13 +24,13 @@ const assert = require('assert');
|
|||||||
Infinity,
|
Infinity,
|
||||||
NaN
|
NaN
|
||||||
].forEach((val) => {
|
].forEach((val) => {
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => timers.enroll({}, val),
|
() => timers.enroll({}, val),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_VALUE_OUT_OF_RANGE',
|
code: 'ERR_VALUE_OUT_OF_RANGE',
|
||||||
type: RangeError,
|
type: RangeError,
|
||||||
message: 'The value of "msecs" must be a non-negative ' +
|
message: 'The value of "msecs" must be a non-negative ' +
|
||||||
`finite number. Received "${val}"`
|
`finite number. Received "${val}"`
|
||||||
})
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -22,12 +22,12 @@ assert.throws(() => tls.createServer({ key: 'dummykey', passphrase: 1 }),
|
|||||||
assert.throws(() => tls.createServer({ ecdhCurve: 1 }),
|
assert.throws(() => tls.createServer({ ecdhCurve: 1 }),
|
||||||
/TypeError: ECDH curve name must be a string/);
|
/TypeError: ECDH curve name must be a string/);
|
||||||
|
|
||||||
assert.throws(() => tls.createServer({ handshakeTimeout: 'abcd' }),
|
common.expectsError(() => tls.createServer({ handshakeTimeout: 'abcd' }),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "timeout" argument must be of type number'
|
message: 'The "timeout" argument must be of type number'
|
||||||
})
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.throws(() => tls.createServer({ sessionTimeout: 'abcd' }),
|
assert.throws(() => tls.createServer({ sessionTimeout: 'abcd' }),
|
||||||
|
@ -4,12 +4,11 @@ const common = require('../common');
|
|||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto)
|
||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const assert = require('assert');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
|
||||||
{
|
{
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => { tls.createSecureContext({ clientCertEngine: 0 }); },
|
() => { tls.createSecureContext({ clientCertEngine: 0 }); },
|
||||||
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE',
|
{ code: 'ERR_INVALID_ARG_TYPE',
|
||||||
message: / Received type number$/ }));
|
message: / Received type number$/ });
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,14 @@ binding.SecureContext = function() {
|
|||||||
return rv;
|
return rv;
|
||||||
};
|
};
|
||||||
|
|
||||||
const assert = require('assert');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
|
||||||
{
|
{
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => { tls.createSecureContext({ clientCertEngine: 'Cannonmouth' }); },
|
() => { tls.createSecureContext({ clientCertEngine: 'Cannonmouth' }); },
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED',
|
code: 'ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED',
|
||||||
message: 'Custom engines not supported by this OpenSSL'
|
message: 'Custom engines not supported by this OpenSSL'
|
||||||
})
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,12 @@ tls.createServer(assert.fail)
|
|||||||
tls.createServer({})
|
tls.createServer({})
|
||||||
.listen(0, common.mustCall(close));
|
.listen(0, common.mustCall(close));
|
||||||
|
|
||||||
assert.throws(() => tls.createServer('this is not valid'),
|
common.expectsError(() => tls.createServer('this is not valid'),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "options" argument must be of type Object'
|
message: 'The "options" argument must be of type Object'
|
||||||
})
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
tls.createServer()
|
tls.createServer()
|
||||||
|
@ -98,13 +98,13 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
|
|||||||
[[keyStr, keyStr2], true, invalidCertRE],
|
[[keyStr, keyStr2], true, invalidCertRE],
|
||||||
[true, [certBuff, certBuff2], invalidKeyRE]
|
[true, [certBuff, certBuff2], invalidKeyRE]
|
||||||
].map(([key, cert, message]) => {
|
].map(([key, cert, message]) => {
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
tls.createServer({ key, cert });
|
tls.createServer({ key, cert });
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message
|
message
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Checks to ensure tls.createServer works with the CA parameter
|
// Checks to ensure tls.createServer works with the CA parameter
|
||||||
@ -132,13 +132,13 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
|
|||||||
[keyBuff, certBuff, true],
|
[keyBuff, certBuff, true],
|
||||||
[keyBuff, certBuff, [caCert, true]]
|
[keyBuff, certBuff, [caCert, true]]
|
||||||
].map(([key, cert, ca]) => {
|
].map(([key, cert, ca]) => {
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
tls.createServer({ key, cert, ca });
|
tls.createServer({ key, cert, ca });
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: /^The "ca" argument must be one of type string, Buffer, TypedArray, or DataView$/
|
message: /^The "ca" argument must be one of type string, Buffer, TypedArray, or DataView$/
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Checks to ensure tls.createServer throws an error for CA assignment
|
// Checks to ensure tls.createServer throws an error for CA assignment
|
||||||
@ -150,13 +150,13 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
|
|||||||
[keyBuff, certBuff, true],
|
[keyBuff, certBuff, true],
|
||||||
[keyBuff, certBuff, [caCert, true]]
|
[keyBuff, certBuff, [caCert, true]]
|
||||||
].map(([key, cert, ca]) => {
|
].map(([key, cert, ca]) => {
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
tls.createServer({ key, cert, ca });
|
tls.createServer({ key, cert, ca });
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: /^The "ca" argument must be one of type string, Buffer, TypedArray, or DataView$/
|
message: /^The "ca" argument must be one of type string, Buffer, TypedArray, or DataView$/
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Checks to ensure tls.createSecureContext works with false-y input
|
// Checks to ensure tls.createSecureContext works with false-y input
|
||||||
|
@ -229,13 +229,13 @@ const values = [
|
|||||||
{
|
{
|
||||||
// Verify that non-function inputs throw.
|
// Verify that non-function inputs throw.
|
||||||
['foo', null, undefined, false, 0, {}, Symbol(), []].forEach((value) => {
|
['foo', null, undefined, false, 0, {}, Symbol(), []].forEach((value) => {
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
callbackify(value);
|
callbackify(value);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "original" argument must be of type Function'
|
message: 'The "original" argument must be of type Function'
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,12 +250,12 @@ const values = [
|
|||||||
// Verify that the last argument to the callbackified function is a function.
|
// Verify that the last argument to the callbackified function is a function.
|
||||||
['foo', null, undefined, false, 0, {}, Symbol(), []].forEach((value) => {
|
['foo', null, undefined, false, 0, {}, Symbol(), []].forEach((value) => {
|
||||||
args.push(value);
|
args.push(value);
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
cb(...args);
|
cb(...args);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The last argument must be of type Function'
|
message: 'The last argument must be of type Function'
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -80,22 +80,22 @@ assert.strictEqual(e.e(), 'e');
|
|||||||
assert.strictEqual(e.constructor, E);
|
assert.strictEqual(e.constructor, E);
|
||||||
|
|
||||||
// should throw with invalid arguments
|
// should throw with invalid arguments
|
||||||
assert.throws(function() {
|
common.expectsError(function() {
|
||||||
inherits(A, {});
|
inherits(A, {});
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "superCtor.prototype" property must be of type Function'
|
message: 'The "superCtor.prototype" property must be of type Function'
|
||||||
})
|
}
|
||||||
);
|
);
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
inherits(A, null);
|
inherits(A, null);
|
||||||
}, errCheck);
|
}, errCheck);
|
||||||
assert.throws(function() {
|
common.expectsError(function() {
|
||||||
inherits(null, A);
|
inherits(null, A);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "ctor" argument must be of type Function'
|
message: 'The "ctor" argument must be of type Function'
|
||||||
})
|
}
|
||||||
);
|
);
|
||||||
|
@ -1136,22 +1136,22 @@ if (typeof Symbol !== 'undefined') {
|
|||||||
JSON.stringify(oldOptions)
|
JSON.stringify(oldOptions)
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
util.inspect.defaultOptions = null;
|
util.inspect.defaultOptions = null;
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "options" argument must be of type Object'
|
message: 'The "options" argument must be of type Object'
|
||||||
})
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
util.inspect.defaultOptions = 'bad';
|
util.inspect.defaultOptions = 'bad';
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "options" argument must be of type Object'
|
message: 'The "options" argument must be of type Object'
|
||||||
})
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,12 +52,13 @@ assert(TextDecoder);
|
|||||||
if (common.hasIntl) {
|
if (common.hasIntl) {
|
||||||
['unicode-1-1-utf-8', 'utf8', 'utf-8'].forEach((i) => {
|
['unicode-1-1-utf-8', 'utf8', 'utf-8'].forEach((i) => {
|
||||||
const dec = new TextDecoder(i, { fatal: true });
|
const dec = new TextDecoder(i, { fatal: true });
|
||||||
assert.throws(() => dec.decode(buf.slice(0, 8)),
|
common.expectsError(() => dec.decode(buf.slice(0, 8)),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_ENCODING_INVALID_ENCODED_DATA',
|
code: 'ERR_ENCODING_INVALID_ENCODED_DATA',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The encoded data was not valid for encoding utf-8'
|
message: 'The encoded data was not valid ' +
|
||||||
}));
|
'for encoding utf-8'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
['unicode-1-1-utf-8', 'utf8', 'utf-8'].forEach((i) => {
|
['unicode-1-1-utf-8', 'utf8', 'utf-8'].forEach((i) => {
|
||||||
@ -66,13 +67,13 @@ if (common.hasIntl) {
|
|||||||
assert.doesNotThrow(() => dec.decode(buf.slice(8)));
|
assert.doesNotThrow(() => dec.decode(buf.slice(8)));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
assert.throws(
|
common.expectsError(
|
||||||
() => new TextDecoder('utf-8', { fatal: true }),
|
() => new TextDecoder('utf-8', { fatal: true }),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_NO_ICU',
|
code: 'ERR_NO_ICU',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: '"fatal" option is not supported on Node.js compiled without ICU'
|
message: '"fatal" option is not supported on Node.js compiled without ICU'
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test TextDecoder, UTF-16le
|
// Test TextDecoder, UTF-16le
|
||||||
@ -96,12 +97,12 @@ if (common.hasIntl) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
[{}, [], true, 1, '', new TextEncoder()].forEach((i) => {
|
[{}, [], true, 1, '', new TextEncoder()].forEach((i) => {
|
||||||
assert.throws(() => fn.call(i, Infinity, {}),
|
common.expectsError(() => fn.call(i, Infinity, {}),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type TextDecoder'
|
message: 'Value of "this" must be of type TextDecoder'
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,11 +41,11 @@ assert(TextEncoder);
|
|||||||
});
|
});
|
||||||
|
|
||||||
[{}, [], true, 1, '', new TextDecoder()].forEach((i) => {
|
[{}, [], true, 1, '', new TextDecoder()].forEach((i) => {
|
||||||
assert.throws(() => fn.call(i, Infinity, {}),
|
common.expectsError(() => fn.call(i, Infinity, {}),
|
||||||
common.expectsError({
|
{
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type TextEncoder'
|
message: 'Value of "this" must be of type TextEncoder'
|
||||||
}));
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -52,20 +52,20 @@ test(function() {
|
|||||||
// Tests below are not from WPT.
|
// Tests below are not from WPT.
|
||||||
{
|
{
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.append.call(undefined);
|
params.append.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParams'
|
message: 'Value of "this" must be of type URLSearchParams'
|
||||||
}));
|
});
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.append('a');
|
params.append('a');
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_MISSING_ARGS',
|
code: 'ERR_MISSING_ARGS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "name" and "value" arguments must be specified'
|
message: 'The "name" and "value" arguments must be specified'
|
||||||
}));
|
});
|
||||||
|
|
||||||
const obj = {
|
const obj = {
|
||||||
toString() { throw new Error('toString'); },
|
toString() { throw new Error('toString'); },
|
||||||
|
@ -62,20 +62,20 @@ test(function() {
|
|||||||
// Tests below are not from WPT.
|
// Tests below are not from WPT.
|
||||||
{
|
{
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.delete.call(undefined);
|
params.delete.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParams'
|
message: 'Value of "this" must be of type URLSearchParams'
|
||||||
}));
|
});
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.delete();
|
params.delete();
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_MISSING_ARGS',
|
code: 'ERR_MISSING_ARGS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "name" argument must be specified'
|
message: 'The "name" argument must be specified'
|
||||||
}));
|
});
|
||||||
|
|
||||||
const obj = {
|
const obj = {
|
||||||
toString() { throw new Error('toString'); },
|
toString() { throw new Error('toString'); },
|
||||||
|
@ -26,17 +26,17 @@ assert.deepStrictEqual(entries.next(), {
|
|||||||
done: true
|
done: true
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
entries.next.call(undefined);
|
entries.next.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParamsIterator'
|
message: 'Value of "this" must be of type URLSearchParamsIterator'
|
||||||
}));
|
});
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.entries.call(undefined);
|
params.entries.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParams'
|
message: 'Value of "this" must be of type URLSearchParams'
|
||||||
}));
|
});
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
|
||||||
const { URL, URLSearchParams } = require('url');
|
const { URL, URLSearchParams } = require('url');
|
||||||
const { test, assert_array_equals, assert_unreached } =
|
const { test, assert_array_equals, assert_unreached } =
|
||||||
require('../common/wpt');
|
require('../common/wpt');
|
||||||
@ -50,11 +49,11 @@ test(function() {
|
|||||||
// Tests below are not from WPT.
|
// Tests below are not from WPT.
|
||||||
{
|
{
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.forEach.call(undefined);
|
params.forEach.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParams'
|
message: 'Value of "this" must be of type URLSearchParams'
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
@ -37,20 +37,20 @@ test(function() {
|
|||||||
// Tests below are not from WPT.
|
// Tests below are not from WPT.
|
||||||
{
|
{
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.get.call(undefined);
|
params.get.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParams'
|
message: 'Value of "this" must be of type URLSearchParams'
|
||||||
}));
|
});
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.get();
|
params.get();
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_MISSING_ARGS',
|
code: 'ERR_MISSING_ARGS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "name" argument must be specified'
|
message: 'The "name" argument must be specified'
|
||||||
}));
|
});
|
||||||
|
|
||||||
const obj = {
|
const obj = {
|
||||||
toString() { throw new Error('toString'); },
|
toString() { throw new Error('toString'); },
|
||||||
|
@ -42,20 +42,20 @@ test(function() {
|
|||||||
// Tests below are not from WPT.
|
// Tests below are not from WPT.
|
||||||
{
|
{
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.getAll.call(undefined);
|
params.getAll.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParams'
|
message: 'Value of "this" must be of type URLSearchParams'
|
||||||
}));
|
});
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.getAll();
|
params.getAll();
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_MISSING_ARGS',
|
code: 'ERR_MISSING_ARGS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "name" argument must be specified'
|
message: 'The "name" argument must be specified'
|
||||||
}));
|
});
|
||||||
|
|
||||||
const obj = {
|
const obj = {
|
||||||
toString() { throw new Error('toString'); },
|
toString() { throw new Error('toString'); },
|
||||||
|
@ -40,20 +40,20 @@ test(function() {
|
|||||||
// Tests below are not from WPT.
|
// Tests below are not from WPT.
|
||||||
{
|
{
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.has.call(undefined);
|
params.has.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParams'
|
message: 'Value of "this" must be of type URLSearchParams'
|
||||||
}));
|
});
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.has();
|
params.has();
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_MISSING_ARGS',
|
code: 'ERR_MISSING_ARGS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "name" argument must be specified'
|
message: 'The "name" argument must be specified'
|
||||||
}));
|
});
|
||||||
|
|
||||||
const obj = {
|
const obj = {
|
||||||
toString() { throw new Error('toString'); },
|
toString() { throw new Error('toString'); },
|
||||||
|
@ -27,17 +27,17 @@ assert.deepStrictEqual(keys.next(), {
|
|||||||
done: true
|
done: true
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
keys.next.call(undefined);
|
keys.next.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParamsIterator'
|
message: 'Value of "this" must be of type URLSearchParamsIterator'
|
||||||
}));
|
});
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.keys.call(undefined);
|
params.keys.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParams'
|
message: 'Value of "this" must be of type URLSearchParams'
|
||||||
}));
|
});
|
||||||
|
@ -38,20 +38,20 @@ test(function() {
|
|||||||
// Tests below are not from WPT.
|
// Tests below are not from WPT.
|
||||||
{
|
{
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.set.call(undefined);
|
params.set.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParams'
|
message: 'Value of "this" must be of type URLSearchParams'
|
||||||
}));
|
});
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.set('a');
|
params.set('a');
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_MISSING_ARGS',
|
code: 'ERR_MISSING_ARGS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "name" and "value" arguments must be specified'
|
message: 'The "name" and "value" arguments must be specified'
|
||||||
}));
|
});
|
||||||
|
|
||||||
const obj = {
|
const obj = {
|
||||||
toString() { throw new Error('toString'); },
|
toString() { throw new Error('toString'); },
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
|
||||||
const URLSearchParams = require('url').URLSearchParams;
|
const URLSearchParams = require('url').URLSearchParams;
|
||||||
const { test, assert_equals } = require('../common/wpt');
|
const { test, assert_equals } = require('../common/wpt');
|
||||||
|
|
||||||
@ -126,11 +125,11 @@ test(function() {
|
|||||||
// Tests below are not from WPT.
|
// Tests below are not from WPT.
|
||||||
{
|
{
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.toString.call(undefined);
|
params.toString.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParams'
|
message: 'Value of "this" must be of type URLSearchParams'
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
@ -27,17 +27,17 @@ assert.deepStrictEqual(values.next(), {
|
|||||||
done: true
|
done: true
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
values.next.call(undefined);
|
values.next.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParamsIterator'
|
message: 'Value of "this" must be of type URLSearchParamsIterator'
|
||||||
}));
|
});
|
||||||
assert.throws(() => {
|
common.expectsError(() => {
|
||||||
params.values.call(undefined);
|
params.values.call(undefined);
|
||||||
}, common.expectsError({
|
}, {
|
||||||
code: 'ERR_INVALID_THIS',
|
code: 'ERR_INVALID_THIS',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'Value of "this" must be of type URLSearchParams'
|
message: 'Value of "this" must be of type URLSearchParams'
|
||||||
}));
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user