Skip to content

Commit

Permalink
test: use template strings in parallel tests
Browse files Browse the repository at this point in the history
PR-URL: #32549
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
dericop authored and targos committed Apr 11, 2020
1 parent 62db9a0 commit cca269c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
26 changes: 13 additions & 13 deletions test/parallel/test-buffer-bigint64.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
4 changes: 2 additions & 2 deletions test/parallel/test-http-readable-data-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-http2-origin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
{
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http2-server-session-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
4 changes: 2 additions & 2 deletions test/parallel/test-promises-warning-on-unhandled-rejection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tls-psk-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-worker-relative-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
}));
Expand Down

0 comments on commit cca269c

Please sign in to comment.