mirror of https://github.com/nodejs/node.git
test: use template strings in parallel tests
PR-URL: https://github.com/nodejs/node/pull/32549 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>pull/32617/head
parent
0be9ebb722
commit
a6ab883eaa
|
@ -7,49 +7,49 @@ const buf = Buffer.allocUnsafe(8);
|
|||
['LE', 'BE'].forEach(function(endianness) {
|
||||
// Should allow simple BigInts to be written and read
|
||||
let val = 123456789n;
|
||||
buf['writeBigInt64' + endianness](val, 0);
|
||||
let rtn = buf['readBigInt64' + endianness](0);
|
||||
buf[`writeBigInt64${endianness}`](val, 0);
|
||||
let rtn = buf[`readBigInt64${endianness}`](0);
|
||||
assert.strictEqual(val, rtn);
|
||||
|
||||
// Should allow INT64_MAX to be written and read
|
||||
val = 0x7fffffffffffffffn;
|
||||
buf['writeBigInt64' + endianness](val, 0);
|
||||
rtn = buf['readBigInt64' + endianness](0);
|
||||
buf[`writeBigInt64${endianness}`](val, 0);
|
||||
rtn = buf[`readBigInt64${endianness}`](0);
|
||||
assert.strictEqual(val, rtn);
|
||||
|
||||
// Should read and write a negative signed 64-bit integer
|
||||
val = -123456789n;
|
||||
buf['writeBigInt64' + endianness](val, 0);
|
||||
assert.strictEqual(val, buf['readBigInt64' + endianness](0));
|
||||
buf[`writeBigInt64${endianness}`](val, 0);
|
||||
assert.strictEqual(val, buf[`readBigInt64${endianness}`](0));
|
||||
|
||||
// Should read and write an unsigned 64-bit integer
|
||||
val = 123456789n;
|
||||
buf['writeBigUInt64' + endianness](val, 0);
|
||||
assert.strictEqual(val, buf['readBigUInt64' + endianness](0));
|
||||
buf[`writeBigUInt64${endianness}`](val, 0);
|
||||
assert.strictEqual(val, buf[`readBigUInt64${endianness}`](0));
|
||||
|
||||
// Should throw a RangeError upon INT64_MAX+1 being written
|
||||
assert.throws(function() {
|
||||
const val = 0x8000000000000000n;
|
||||
buf['writeBigInt64' + endianness](val, 0);
|
||||
buf[`writeBigInt64${endianness}`](val, 0);
|
||||
}, RangeError);
|
||||
|
||||
// Should throw a RangeError upon UINT64_MAX+1 being written
|
||||
assert.throws(function() {
|
||||
const val = 0x10000000000000000n;
|
||||
buf['writeBigUInt64' + endianness](val, 0);
|
||||
buf[`writeBigUInt64${endianness}`](val, 0);
|
||||
}, {
|
||||
code: 'ERR_OUT_OF_RANGE',
|
||||
message: 'The value of "value" is out of range. It must be ' +
|
||||
'>= 0n and < 2n ** 64n. Received 18_446_744_073_709_551_616n'
|
||||
'>= 0n and < 2n ** 64n. Received 18_446_744_073_709_551_616n'
|
||||
});
|
||||
|
||||
// Should throw a TypeError upon invalid input
|
||||
assert.throws(function() {
|
||||
buf['writeBigInt64' + endianness]('bad', 0);
|
||||
buf[`writeBigInt64${endianness}`]('bad', 0);
|
||||
}, TypeError);
|
||||
|
||||
// Should throw a TypeError upon invalid input
|
||||
assert.throws(function() {
|
||||
buf['writeBigUInt64' + endianness]('bad', 0);
|
||||
buf[`writeBigUInt64${endianness}`]('bad', 0);
|
||||
}, TypeError);
|
||||
});
|
||||
|
|
|
@ -10,14 +10,14 @@ let next = null;
|
|||
|
||||
const server = http.createServer((req, res) => {
|
||||
res.writeHead(200, {
|
||||
'Content-Length': '' + (helloWorld.length + helloAgainLater.length)
|
||||
'Content-Length': `${(helloWorld.length + helloAgainLater.length)}`
|
||||
});
|
||||
|
||||
// We need to make sure the data is flushed
|
||||
// before writing again
|
||||
next = () => {
|
||||
res.end(helloAgainLater);
|
||||
next = () => {};
|
||||
next = () => { };
|
||||
};
|
||||
|
||||
res.write(helloWorld);
|
||||
|
|
|
@ -70,7 +70,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary');
|
|||
}
|
||||
);
|
||||
});
|
||||
const longInput = 'http://foo.bar' + 'a'.repeat(16383);
|
||||
const longInput = `http://foo.bar${'a'.repeat(16383)}`;
|
||||
throws(
|
||||
() => session.origin(longInput),
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary');
|
|||
|
||||
// Test automatically sending origin on connection start
|
||||
{
|
||||
const origins = [ 'https://foo.org/a/b/c', 'https://bar.org' ];
|
||||
const origins = ['https://foo.org/a/b/c', 'https://bar.org'];
|
||||
const server = createSecureServer({ key, cert, origins });
|
||||
server.on('stream', mustCall((stream) => {
|
||||
stream.respond();
|
||||
|
|
|
@ -16,5 +16,5 @@ server.listen(0, common.localhostIPv4, common.mustCall(() => {
|
|||
|
||||
const port = server.address().port;
|
||||
const host = common.localhostIPv4;
|
||||
h2.connect('http://' + host + ':' + port, afterConnect);
|
||||
h2.connect(`http://${host}:${port}`, afterConnect);
|
||||
}));
|
||||
|
|
|
@ -23,7 +23,7 @@ process.on('warning', common.mustCall((warning) => {
|
|||
assert(
|
||||
/Unhandled promise rejection/.test(warning.message),
|
||||
'Expected warning message to contain "Unhandled promise rejection" ' +
|
||||
'but did not. Had "' + warning.message + '" instead.'
|
||||
`but did not. Had "${warning.message}" instead.`
|
||||
);
|
||||
break;
|
||||
case 2:
|
||||
|
@ -40,7 +40,7 @@ process.on('warning', common.mustCall((warning) => {
|
|||
assert(
|
||||
/Unhandled promise rejection/.test(warning.message),
|
||||
'Expected warning message to contain "Unhandled promise rejection" ' +
|
||||
'but did not. Had "' + warning.message + '" instead.'
|
||||
`but did not. Had "${warning.message}" instead.`
|
||||
);
|
||||
break;
|
||||
case 5:
|
||||
|
|
|
@ -43,7 +43,7 @@ let gotWorld = false;
|
|||
server.listen(0, () => {
|
||||
const client = spawn(common.opensslCli, [
|
||||
's_client',
|
||||
'-connect', '127.0.0.1:' + server.address().port,
|
||||
'-connect', `127.0.0.1:${server.address().port}`,
|
||||
'-cipher', CIPHERS,
|
||||
'-psk', KEY,
|
||||
'-psk_identity', IDENTITY
|
||||
|
|
|
@ -5,7 +5,7 @@ const assert = require('assert');
|
|||
const { Worker, isMainThread, parentPort } = require('worker_threads');
|
||||
|
||||
if (isMainThread) {
|
||||
const w = new Worker('./' + path.relative('.', __filename));
|
||||
const w = new Worker(`./${path.relative('.', __filename)}`);
|
||||
w.on('message', common.mustCall((message) => {
|
||||
assert.strictEqual(message, 'Hello, world!');
|
||||
}));
|
||||
|
|
Loading…
Reference in New Issue