summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/addons/symlinked-module/test.js2
-rw-r--r--test/internet/test-dns.js5
-rw-r--r--test/parallel/test-assert-deep.js4
-rw-r--r--test/parallel/test-assert-if-error.js1
-rw-r--r--test/parallel/test-buffer-alloc.js8
-rw-r--r--test/parallel/test-buffer-bad-overload.js4
-rw-r--r--test/parallel/test-buffer-constants.js2
-rw-r--r--test/parallel/test-buffer-copy.js2
-rw-r--r--test/parallel/test-buffer-sharedarraybuffer.js5
-rw-r--r--test/parallel/test-buffer-slice.js5
-rw-r--r--test/parallel/test-child-process-spawn-typeerror.js20
-rw-r--r--test/parallel/test-console-async-write-error.js3
-rw-r--r--test/parallel/test-console-instance.js16
-rw-r--r--test/parallel/test-console-is-a-namespace.js2
-rw-r--r--test/parallel/test-console-sync-write-error.js9
-rw-r--r--test/parallel/test-crypto-padding.js36
-rw-r--r--test/parallel/test-crypto-pbkdf2.js4
-rw-r--r--test/parallel/test-crypto-rsa-dsa.js1
-rw-r--r--test/parallel/test-domain-load-after-set-uncaught-exception-capture.js3
-rw-r--r--test/parallel/test-fs-access.js2
-rw-r--r--test/parallel/test-fs-buffer.js8
-rw-r--r--test/parallel/test-fs-read-stream-throw-type-error.js2
-rw-r--r--test/parallel/test-fs-write-stream-throw-type-error.js2
-rw-r--r--test/parallel/test-http-invalidheaderfield.js1
-rw-r--r--test/parallel/test-http2-binding.js2
-rw-r--r--test/parallel/test-http2-client-rststream-before-connect.js4
-rw-r--r--test/parallel/test-http2-compat-serverresponse-statuscode.js1
-rw-r--r--test/parallel/test-http2-getpackedsettings.js9
-rw-r--r--test/parallel/test-http2-server-startup.js10
-rw-r--r--test/parallel/test-http2-socket-proxy.js1
-rw-r--r--test/parallel/test-http2-withflag.js7
-rw-r--r--test/parallel/test-https-agent-constructor.js1
-rw-r--r--test/parallel/test-icu-punycode.js4
-rw-r--r--test/parallel/test-internal-fs.js2
-rw-r--r--test/parallel/test-internal-util-decorate-error-stack.js11
-rw-r--r--test/parallel/test-module-symlinked-peer-modules.js2
-rw-r--r--test/parallel/test-net-after-close.js2
-rw-r--r--test/parallel/test-net-during-close.js6
-rw-r--r--test/parallel/test-performance.js2
-rw-r--r--test/parallel/test-process-geteuid-getegid.js1
-rw-r--r--test/parallel/test-process-setuid-setgid.js1
-rw-r--r--test/parallel/test-querystring.js2
-rw-r--r--test/parallel/test-readline-csi.js1
-rw-r--r--test/parallel/test-stream-writable-null.js30
-rw-r--r--test/parallel/test-timers-unref.js1
-rw-r--r--test/parallel/test-util-inspect.js113
-rw-r--r--test/parallel/test-vm-create-context-arg.js1
-rw-r--r--test/parallel/test-vm-cross-context.js1
-rw-r--r--test/pummel/test-fs-largefile.js1
-rw-r--r--test/pummel/test-fs-watch-file.js7
-rw-r--r--test/sequential/test-inspector-module.js1
51 files changed, 166 insertions, 205 deletions
diff --git a/test/addons/symlinked-module/test.js b/test/addons/symlinked-module/test.js
index 777d57d58f..f5596db429 100644
--- a/test/addons/symlinked-module/test.js
+++ b/test/addons/symlinked-module/test.js
@@ -30,5 +30,5 @@ const sub = require('./submodule');
const mod = require(path.join(i, 'binding.node'));
assert.notStrictEqual(mod, null);
assert.strictEqual(mod.hello(), 'world');
- sub.test(i);
+ sub.test(i); // Should not throw.
});
diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js
index dadf14c0be..f1b7b4ff05 100644
--- a/test/internet/test-dns.js
+++ b/test/internet/test-dns.js
@@ -579,11 +579,8 @@ process.on('exit', function() {
assert.ok(getaddrinfoCallbackCalled);
});
-
+// Should not throw.
dns.lookup(addresses.INET6_HOST, 6, common.mustCall());
-
dns.lookup(addresses.INET_HOST, {}, common.mustCall());
-
dns.lookupService('0.0.0.0', '0', common.mustCall());
-
dns.lookupService('0.0.0.0', 0, common.mustCall());
diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js
index 53a00c6899..129967ac95 100644
--- a/test/parallel/test-assert-deep.js
+++ b/test/parallel/test-assert-deep.js
@@ -492,8 +492,8 @@ assertOnlyDeepEqual([1, , , 3], [1, , , 3, , , ]);
// Handle NaN
assert.throws(() => { assert.deepEqual(NaN, NaN); }, assert.AssertionError);
-{ assert.deepStrictEqual(NaN, NaN); }
-{ assert.deepStrictEqual({ a: NaN }, { a: NaN }); }
+assert.deepStrictEqual(NaN, NaN);
+assert.deepStrictEqual({ a: NaN }, { a: NaN });
assert.deepStrictEqual([ 1, 2, NaN, 4 ], [ 1, 2, NaN, 4 ]);
// Handle boxed primitives
diff --git a/test/parallel/test-assert-if-error.js b/test/parallel/test-assert-if-error.js
index df464d513d..cd6f99dfa4 100644
--- a/test/parallel/test-assert-if-error.js
+++ b/test/parallel/test-assert-if-error.js
@@ -67,6 +67,7 @@ assert.throws(
}
);
+// Should not throw.
assert.ifError(null);
assert.ifError();
assert.ifError(undefined);
diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js
index 9714fcb485..bf818ed054 100644
--- a/test/parallel/test-buffer-alloc.js
+++ b/test/parallel/test-buffer-alloc.js
@@ -62,7 +62,7 @@ assert.throws(() => b.write('test', 'utf8', 0),
/is no longer supported/);
-// try to create 0-length buffers
+// Try to create 0-length buffers. Should not throw.
Buffer.from('');
Buffer.from('', 'ascii');
Buffer.from('', 'latin1');
@@ -107,7 +107,7 @@ b.copy(Buffer.alloc(1), 0, 2048, 2048);
assert.strictEqual(writeTest.toString(), 'nodejs');
}
-// Offset points to the end of the buffer
+// Offset points to the end of the buffer and does not throw.
// (see https://github.com/nodejs/node/issues/8127).
Buffer.alloc(1).write('', 1, 0);
@@ -992,10 +992,10 @@ common.expectsError(() => {
assert.strictEqual(ubuf.buffer.byteLength, 10);
}
-// Regression test
+// Regression test to verify that an empty ArrayBuffer does not throw.
Buffer.from(new ArrayBuffer());
-// Test that ArrayBuffer from a different context is detected correctly
+// Test that ArrayBuffer from a different context is detected correctly.
const arrayBuf = vm.runInNewContext('new ArrayBuffer()');
Buffer.from(arrayBuf);
Buffer.from({ buffer: arrayBuf });
diff --git a/test/parallel/test-buffer-bad-overload.js b/test/parallel/test-buffer-bad-overload.js
index ec2703341b..63acb8ebfb 100644
--- a/test/parallel/test-buffer-bad-overload.js
+++ b/test/parallel/test-buffer-bad-overload.js
@@ -2,7 +2,7 @@
const common = require('../common');
const assert = require('assert');
-Buffer.allocUnsafe(10);
+Buffer.allocUnsafe(10); // Should not throw.
const err = common.expectsError({
code: 'ERR_INVALID_ARG_TYPE',
@@ -14,4 +14,4 @@ assert.throws(function() {
Buffer.from(10, 'hex');
}, err);
-Buffer.from('deadbeaf', 'hex');
+Buffer.from('deadbeaf', 'hex'); // Should not throw.
diff --git a/test/parallel/test-buffer-constants.js b/test/parallel/test-buffer-constants.js
index dbb6186b6d..f6f0dbddc3 100644
--- a/test/parallel/test-buffer-constants.js
+++ b/test/parallel/test-buffer-constants.js
@@ -11,7 +11,7 @@ assert(MAX_STRING_LENGTH <= MAX_LENGTH);
assert.throws(() => ' '.repeat(MAX_STRING_LENGTH + 1),
/^RangeError: Invalid string length$/);
-' '.repeat(MAX_STRING_LENGTH);
+' '.repeat(MAX_STRING_LENGTH); // Should not throw.
// Legacy values match:
assert.strictEqual(kMaxLength, MAX_LENGTH);
diff --git a/test/parallel/test-buffer-copy.js b/test/parallel/test-buffer-copy.js
index 324613a04f..5c82f4de28 100644
--- a/test/parallel/test-buffer-copy.js
+++ b/test/parallel/test-buffer-copy.js
@@ -92,7 +92,7 @@ const bb = Buffer.allocUnsafe(10);
bb.fill('hello crazy world');
-// try to copy from before the beginning of b
+// Try to copy from before the beginning of b. Should not throw.
b.copy(c, 0, 100, 10);
// copy throws at negative sourceStart
diff --git a/test/parallel/test-buffer-sharedarraybuffer.js b/test/parallel/test-buffer-sharedarraybuffer.js
index 536c393936..0252847c05 100644
--- a/test/parallel/test-buffer-sharedarraybuffer.js
+++ b/test/parallel/test-buffer-sharedarraybuffer.js
@@ -22,8 +22,7 @@ arr2[1] = 6000;
assert.deepStrictEqual(arr_buf, ar_buf);
-// Checks for calling Buffer.byteLength on a SharedArrayBuffer
-
+// Checks for calling Buffer.byteLength on a SharedArrayBuffer.
assert.strictEqual(Buffer.byteLength(sab), sab.byteLength);
-Buffer.from({ buffer: sab });
+Buffer.from({ buffer: sab }); // Should not throw.
diff --git a/test/parallel/test-buffer-slice.js b/test/parallel/test-buffer-slice.js
index b55d082783..6175370a9b 100644
--- a/test/parallel/test-buffer-slice.js
+++ b/test/parallel/test-buffer-slice.js
@@ -77,9 +77,8 @@ expectedSameBufs.forEach(([buf1, buf2]) => {
const utf16Buf = Buffer.from('0123456789', 'utf16le');
assert.deepStrictEqual(utf16Buf.slice(0, 6), Buffer.from('012', 'utf16le'));
-// try to slice a zero length Buffer
-// see https://github.com/joyent/node/issues/5881
-Buffer.alloc(0).slice(0, 1);
+// Try to slice a zero length Buffer.
+// See https://github.com/joyent/node/issues/5881
assert.strictEqual(Buffer.alloc(0).slice(0, 1).length, 0);
{
diff --git a/test/parallel/test-child-process-spawn-typeerror.js b/test/parallel/test-child-process-spawn-typeerror.js
index 25ae7df7aa..2a2c1de277 100644
--- a/test/parallel/test-child-process-spawn-typeerror.js
+++ b/test/parallel/test-child-process-spawn-typeerror.js
@@ -40,13 +40,13 @@ assert.throws(function() {
child.on('error', common.mustNotCall());
}, TypeError);
-// verify that valid argument combinations do not throw
+// Verify that valid argument combinations do not throw.
spawn(cmd);
spawn(cmd, []);
spawn(cmd, {});
spawn(cmd, [], {});
-// verify that invalid argument combinations throw
+// Verify that invalid argument combinations throw.
assert.throws(function() {
spawn();
}, invalidArgTypeError);
@@ -76,7 +76,7 @@ assert.throws(function() {
spawn(cmd, [], 1);
}, invalidArgTypeError);
-// Argument types for combinatorics
+// Argument types for combinatorics.
const a = [];
const o = {};
function c() {}
@@ -94,7 +94,7 @@ spawn(cmd, a);
spawn(cmd, a, o);
spawn(cmd, o);
-// Variants of undefined as explicit 'no argument' at a position
+// Variants of undefined as explicit 'no argument' at a position.
spawn(cmd, u, o);
spawn(cmd, a, u);
@@ -105,7 +105,7 @@ assert.throws(function() { spawn(cmd, s); }, invalidArgTypeError);
assert.throws(function() { spawn(cmd, a, s); }, invalidArgTypeError);
-// verify that execFile has same argument parsing behavior as spawn
+// Verify that execFile has same argument parsing behavior as spawn.
//
// function execFile(file=f [,args=a] [, options=o] [, callback=c]) has valid
// combinations:
@@ -126,7 +126,7 @@ execFile(cmd, o);
execFile(cmd, o, c);
execFile(cmd, c);
-// Variants of undefined as explicit 'no argument' at a position
+// Variants of undefined as explicit 'no argument' at a position.
execFile(cmd, u, o, c);
execFile(cmd, a, u, c);
execFile(cmd, a, o, u);
@@ -148,9 +148,9 @@ execFile(cmd, o, n);
execFile(cmd, c, u);
execFile(cmd, c, n);
-// string is invalid in arg position (this may seem strange, but is
+// String is invalid in arg position (this may seem strange, but is
// consistent across node API, cf. `net.createServer('not options', 'not
-// callback')`
+// callback')`.
assert.throws(function() { execFile(cmd, s, o, c); }, invalidArgValueError);
assert.throws(function() { execFile(cmd, a, s, c); }, invalidArgValueError);
assert.throws(function() { execFile(cmd, a, o, s); }, invalidArgValueError);
@@ -162,10 +162,10 @@ assert.throws(function() { execFile(cmd, a, u, s); }, invalidArgValueError);
assert.throws(function() { execFile(cmd, a, n, s); }, invalidArgValueError);
assert.throws(function() { execFile(cmd, u, o, s); }, invalidArgValueError);
assert.throws(function() { execFile(cmd, n, o, s); }, invalidArgValueError);
-execFile(cmd, c, s);
+execFile(cmd, c, s); // Should not throw.
-// verify that fork has same argument parsing behavior as spawn
+// Verify that fork has same argument parsing behavior as spawn.
//
// function fork(file=f [,args=a] [, options=o]) has valid combinations:
// (f)
diff --git a/test/parallel/test-console-async-write-error.js b/test/parallel/test-console-async-write-error.js
index 139c02d64b..be76c89832 100644
--- a/test/parallel/test-console-async-write-error.js
+++ b/test/parallel/test-console-async-write-error.js
@@ -11,6 +11,5 @@ for (const method of ['dir', 'log', 'warn']) {
});
const c = new Console(out, out, true);
-
- c[method]('abc');
+ c[method]('abc'); // Should not throw.
}
diff --git a/test/parallel/test-console-instance.js b/test/parallel/test-console-instance.js
index aa35afc648..2fd07ac412 100644
--- a/test/parallel/test-console-instance.js
+++ b/test/parallel/test-console-instance.js
@@ -28,15 +28,15 @@ const Console = require('console').Console;
const out = new Stream();
const err = new Stream();
-// ensure the Console instance doesn't write to the
-// process' "stdout" or "stderr" streams
+// Ensure the Console instance doesn't write to the
+// process' "stdout" or "stderr" streams.
process.stdout.write = process.stderr.write = common.mustNotCall();
-// make sure that the "Console" function exists
+// Make sure that the "Console" function exists.
assert.strictEqual('function', typeof Console);
-// make sure that the Console constructor throws
-// when not given a writable stream instance
+// Make sure that the Console constructor throws
+// when not given a writable stream instance.
common.expectsError(
() => { new Console(); },
{
@@ -46,7 +46,7 @@ common.expectsError(
}
);
-// Console constructor should throw if stderr exists but is not writable
+// Console constructor should throw if stderr exists but is not writable.
common.expectsError(
() => {
out.write = () => {};
@@ -77,7 +77,7 @@ out.write = common.mustCall((d) => {
c.dir({ foo: 1 });
-// ensure that the console functions are bound to the console instance
+// Ensure that the console functions are bound to the console instance.
let called = 0;
out.write = common.mustCall((d) => {
called++;
@@ -86,7 +86,7 @@ out.write = common.mustCall((d) => {
[1, 2, 3].forEach(c.log);
-// Console() detects if it is called without `new` keyword
+// Console() detects if it is called without `new` keyword.
Console(out, err);
// Instance that does not ignore the stream errors.
diff --git a/test/parallel/test-console-is-a-namespace.js b/test/parallel/test-console-is-a-namespace.js
index 152f9dab7b..95c652abdd 100644
--- a/test/parallel/test-console-is-a-namespace.js
+++ b/test/parallel/test-console-is-a-namespace.js
@@ -5,7 +5,7 @@ require('../common');
const { test, assert_equals, assert_true, assert_false } =
require('../common/wpt');
-global.console = global.console;
+global.console = global.console; // Should not throw.
const self = global;
diff --git a/test/parallel/test-console-sync-write-error.js b/test/parallel/test-console-sync-write-error.js
index 4d6c52e0da..bf916ff5b8 100644
--- a/test/parallel/test-console-sync-write-error.js
+++ b/test/parallel/test-console-sync-write-error.js
@@ -12,8 +12,7 @@ for (const method of ['dir', 'log', 'warn']) {
});
const c = new Console(out, out, true);
-
- c[method]('abc');
+ c[method]('abc'); // Should not throw.
}
{
@@ -24,8 +23,7 @@ for (const method of ['dir', 'log', 'warn']) {
});
const c = new Console(out, out, true);
-
- c[method]('abc');
+ c[method]('abc'); // Should not throw.
}
{
@@ -36,7 +34,6 @@ for (const method of ['dir', 'log', 'warn']) {
});
const c = new Console(out, out, true);
-
- c[method]('abc');
+ c[method]('abc'); // Should not throw.
}
}
diff --git a/test/parallel/test-crypto-padding.js b/test/parallel/test-crypto-padding.js
index ae85f7d2c3..00b600efb7 100644
--- a/test/parallel/test-crypto-padding.js
+++ b/test/parallel/test-crypto-padding.js
@@ -29,11 +29,7 @@ const crypto = require('crypto');
crypto.DEFAULT_ENCODING = 'buffer';
-
-/*
- * Input data
- */
-
+// Input data.
const ODD_LENGTH_PLAIN = 'Hello node world!';
const EVEN_LENGTH_PLAIN = 'Hello node world!AbC09876dDeFgHi';
@@ -42,10 +38,7 @@ const IV_PLAIN = 'blahFizz2011Buzz';
const CIPHER_NAME = 'aes-128-cbc';
-
-/*
- * Expected result data
- */
+// Expected result data.
// echo -n 'Hello node world!' | \
// openssl enc -aes-128-cbc -e -K 5333632e722e652e742e4b2e652e5921 \
@@ -67,10 +60,7 @@ const EVEN_LENGTH_ENCRYPTED_NOPAD =
'7f57859550d4d2fdb9806da2a750461ab46e71b3d78ebe2d9684dfc87f7575b9';
-/*
- * Helper wrappers
- */
-
+// Helper wrappers.
function enc(plain, pad) {
const encrypt = crypto.createCipheriv(CIPHER_NAME, KEY_PLAIN, IV_PLAIN);
encrypt.setAutoPadding(pad);
@@ -87,16 +77,12 @@ function dec(encd, pad) {
return plain;
}
-
-/*
- * Test encryption
- */
-
+// Test encryption
assert.strictEqual(enc(ODD_LENGTH_PLAIN, true), ODD_LENGTH_ENCRYPTED);
assert.strictEqual(enc(EVEN_LENGTH_PLAIN, true), EVEN_LENGTH_ENCRYPTED);
assert.throws(function() {
- // input must have block length %
+ // Input must have block length %.
enc(ODD_LENGTH_PLAIN, false);
}, /data not multiple of block length/);
@@ -104,24 +90,20 @@ assert.strictEqual(
enc(EVEN_LENGTH_PLAIN, false), EVEN_LENGTH_ENCRYPTED_NOPAD
);
-
-/*
- * Test decryption
- */
-
+// Test decryption.
assert.strictEqual(dec(ODD_LENGTH_ENCRYPTED, true), ODD_LENGTH_PLAIN);
assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED, true), EVEN_LENGTH_PLAIN);
-// returns including original padding
+// Returns including original padding.
assert.strictEqual(dec(ODD_LENGTH_ENCRYPTED, false).length, 32);
assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED, false).length, 48);
assert.throws(function() {
- // must have at least 1 byte of padding (PKCS):
+ // Must have at least 1 byte of padding (PKCS):
assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED_NOPAD, true), EVEN_LENGTH_PLAIN);
}, /bad decrypt/);
-// no-pad encrypted string should return the same:
+// No-pad encrypted string should return the same:
assert.strictEqual(
dec(EVEN_LENGTH_ENCRYPTED_NOPAD, false), EVEN_LENGTH_PLAIN
);
diff --git a/test/parallel/test-crypto-pbkdf2.js b/test/parallel/test-crypto-pbkdf2.js
index 646ecd5ea2..c72551016d 100644
--- a/test/parallel/test-crypto-pbkdf2.js
+++ b/test/parallel/test-crypto-pbkdf2.js
@@ -100,9 +100,7 @@ common.expectsError(
// Should not get FATAL ERROR with empty password and salt
// https://github.com/nodejs/node/issues/8571
-crypto.pbkdf2('', '', 1, 32, 'sha256', common.mustCall((e) => {
- assert.ifError(e);
-}));
+crypto.pbkdf2('', '', 1, 32, 'sha256', common.mustCall(assert.ifError));
common.expectsError(
() => crypto.pbkdf2('password', 'salt', 8, 8, common.mustNotCall()),
diff --git a/test/parallel/test-crypto-rsa-dsa.js b/test/parallel/test-crypto-rsa-dsa.js
index 5a6ecdd66f..744dc5657b 100644
--- a/test/parallel/test-crypto-rsa-dsa.js
+++ b/test/parallel/test-crypto-rsa-dsa.js
@@ -256,7 +256,6 @@ const input = 'I AM THE WALRUS';
// against
const sign = crypto.createSign('SHA1');
sign.update(input);
-
const signOptions = { key: dsaKeyPemEncrypted, passphrase: 'password' };
const signature = sign.sign(signOptions, 'hex');
diff --git a/test/parallel/test-domain-load-after-set-uncaught-exception-capture.js b/test/parallel/test-domain-load-after-set-uncaught-exception-capture.js
index c2fa523cc1..697d4d3080 100644
--- a/test/parallel/test-domain-load-after-set-uncaught-exception-capture.js
+++ b/test/parallel/test-domain-load-after-set-uncaught-exception-capture.js
@@ -13,5 +13,4 @@ common.expectsError(
);
process.setUncaughtExceptionCaptureCallback(null);
-
-require('domain');
+require('domain'); // Should not throw.
diff --git a/test/parallel/test-fs-access.js b/test/parallel/test-fs-access.js
index 551272e72d..aacf3f1848 100644
--- a/test/parallel/test-fs-access.js
+++ b/test/parallel/test-fs-access.js
@@ -118,8 +118,8 @@ common.expectsError(
type: TypeError
});
+// Regular access should not throw.
fs.accessSync(__filename);
-
const mode = fs.F_OK | fs.R_OK | fs.W_OK;
fs.accessSync(readWriteFile, mode);
diff --git a/test/parallel/test-fs-buffer.js b/test/parallel/test-fs-buffer.js
index 2d0bc2a557..c4ab80a429 100644
--- a/test/parallel/test-fs-buffer.js
+++ b/test/parallel/test-fs-buffer.js
@@ -9,17 +9,13 @@ const path = require('path');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-fs.access(Buffer.from(tmpdir.path), common.mustCall((err) => {
- assert.ifError(err);
-}));
+fs.access(Buffer.from(tmpdir.path), common.mustCall(assert.ifError));
const buf = Buffer.from(path.join(tmpdir.path, 'a.txt'));
fs.open(buf, 'w+', common.mustCall((err, fd) => {
assert.ifError(err);
assert(fd);
- fs.close(fd, common.mustCall((err) => {
- assert.ifError(err);
- }));
+ fs.close(fd, common.mustCall(assert.ifError));
}));
common.expectsError(
diff --git a/test/parallel/test-fs-read-stream-throw-type-error.js b/test/parallel/test-fs-read-stream-throw-type-error.js
index b01a0a588f..c2b0d5452c 100644
--- a/test/parallel/test-fs-read-stream-throw-type-error.js
+++ b/test/parallel/test-fs-read-stream-throw-type-error.js
@@ -4,7 +4,7 @@ const fixtures = require('../common/fixtures');
const fs = require('fs');
const example = fixtures.path('x.txt');
-
+// Should not throw.
fs.createReadStream(example, undefined);
fs.createReadStream(example, null);
fs.createReadStream(example, 'utf8');
diff --git a/test/parallel/test-fs-write-stream-throw-type-error.js b/test/parallel/test-fs-write-stream-throw-type-error.js
index 553d399e23..c80f647b3d 100644
--- a/test/parallel/test-fs-write-stream-throw-type-error.js
+++ b/test/parallel/test-fs-write-stream-throw-type-error.js
@@ -8,7 +8,7 @@ const tmpdir = require('../common/tmpdir');
const example = path.join(tmpdir.path, 'dummy');
tmpdir.refresh();
-
+// Should not throw.
fs.createWriteStream(example, undefined);
fs.createWriteStream(example, null);
fs.createWriteStream(example, 'utf8');
diff --git a/test/parallel/test-http-invalidheaderfield.js b/test/parallel/test-http-invalidheaderfield.js
index 528fc82586..01315ba690 100644
--- a/test/parallel/test-http-invalidheaderfield.js
+++ b/test/parallel/test-http-invalidheaderfield.js
@@ -35,6 +35,7 @@ server.listen(0, function() {
}
);
+ // Should not throw.
const options = {
port: server.address().port,
headers: { 'testing_123': 123 }
diff --git a/test/parallel/test-http2-binding.js b/test/parallel/test-http2-binding.js
index 1b8501dcbe..f267e2e6c1 100644
--- a/test/parallel/test-http2-binding.js
+++ b/test/parallel/test-http2-binding.js
@@ -5,8 +5,6 @@ if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
-process.binding('http2');
-
const binding = process.binding('http2');
const http2 = require('http2');
diff --git a/test/parallel/test-http2-client-rststream-before-connect.js b/test/parallel/test-http2-client-rststream-before-connect.js
index 177b13a16e..10d7520ac1 100644
--- a/test/parallel/test-http2-client-rststream-before-connect.js
+++ b/test/parallel/test-http2-client-rststream-before-connect.js
@@ -19,10 +19,10 @@ server.listen(0, common.mustCall(() => {
req.close(1);
assert.strictEqual(req.closed, true);
- // make sure that destroy is called
+ // Make sure that destroy is called.
req._destroy = common.mustCall(req._destroy.bind(req));
- // second call doesn't do anything
+ // Second call doesn't do anything.
req.close(8);
req.on('close', common.mustCall((code) => {
diff --git a/test/parallel/test-http2-compat-serverresponse-statuscode.js b/test/parallel/test-http2-compat-serverresponse-statuscode.js
index 4c51616ef6..dd92db8d96 100644
--- a/test/parallel/test-http2-compat-serverresponse-statuscode.js
+++ b/test/parallel/test-http2-compat-serverresponse-statuscode.js
@@ -27,6 +27,7 @@ server.listen(0, common.mustCall(function() {
assert.strictEqual(response.statusCode, expectedDefaultStatusCode);
+ // Setting the response.statusCode should not throw.
response.statusCode = realStatusCodes.ok;
response.statusCode = realStatusCodes.multipleChoices;
response.statusCode = realStatusCodes.badRequest;
diff --git a/test/parallel/test-http2-getpackedsettings.js b/test/parallel/test-http2-getpackedsettings.js
index b02d6b4933..56b9632113 100644
--- a/test/parallel/test-http2-getpackedsettings.js
+++ b/test/parallel/test-http2-getpackedsettings.js
@@ -26,6 +26,7 @@ assert.deepStrictEqual(val, check);
['maxHeaderListSize', 0],
['maxHeaderListSize', 2 ** 32 - 1]
].forEach((i) => {
+ // Valid options should not throw.
http2.getPackedSettings({ [i[0]]: i[1] });
});
@@ -85,7 +86,7 @@ http2.getPackedSettings({ enablePush: false });
assert.deepStrictEqual(packed, check);
}
-// check for not passing settings
+// Check for not passing settings.
{
const packed = http2.getPackedSettings();
assert.strictEqual(packed.length, 0);
@@ -143,7 +144,7 @@ http2.getPackedSettings({ enablePush: false });
assert.strictEqual(settings.enablePush, true);
}
-//check for what happens if passing {validate: true} and no errors happen
+// Verify that passing {validate: true} does not throw.
{
const packed = Buffer.from([
0x00, 0x01, 0x00, 0x00, 0x00, 0x64, 0x00, 0x03, 0x00, 0x00,
@@ -154,7 +155,7 @@ http2.getPackedSettings({ enablePush: false });
http2.getUnpackedSettings(packed, { validate: true });
}
-// check for maxFrameSize failing the max number
+// Check for maxFrameSize failing the max number.
{
const packed = Buffer.from([0x00, 0x05, 0x01, 0x00, 0x00, 0x00]);
@@ -167,7 +168,7 @@ http2.getPackedSettings({ enablePush: false });
});
}
-// check for maxConcurrentStreams failing the max number
+// Check for maxConcurrentStreams failing the max number.
{
const packed = Buffer.from([0x00, 0x03, 0xFF, 0xFF, 0xFF, 0xFF]);
diff --git a/test/parallel/test-http2-server-startup.js b/test/parallel/test-http2-server-startup.js
index 12b9cd72cb..4ebcc21c27 100644
--- a/test/parallel/test-http2-server-startup.js
+++ b/test/parallel/test-http2-server-startup.js
@@ -19,20 +19,20 @@ const options = {
cert: commonFixtures.readKey('agent2-cert.pem')
};
-// There should not be any throws
+// There should not be any throws.
const serverTLS = http2.createSecureServer(options, () => {});
serverTLS.listen(0, common.mustCall(() => serverTLS.close()));
-// There should not be an error event reported either
+// There should not be an error event reported either.
serverTLS.on('error', common.mustNotCall());
const server = http2.createServer(options, common.mustNotCall());
server.listen(0, common.mustCall(() => server.close()));
-// There should not be an error event reported either
+// There should not be an error event reported either.
server.on('error', common.mustNotCall());
-// Test the plaintext server socket timeout
+// Test the plaintext server socket timeout.
{
let client;
const server = http2.createServer();
@@ -48,7 +48,7 @@ server.on('error', common.mustNotCall());
}));
}
-// Test the secure server socket timeout
+// Test the secure server socket timeout.
{
let client;
const server = http2.createSecureServer(options);
diff --git a/test/parallel/test-http2-socket-proxy.js b/test/parallel/test-http2-socket-proxy.js
index 751cacf8df..71429b3db2 100644
--- a/test/parallel/test-http2-socket-proxy.js
+++ b/test/parallel/test-http2-socket-proxy.js
@@ -51,6 +51,7 @@ server.on('stream', common.mustCall(function(stream, headers) {
common.expectsError(() => (socket.resume = undefined), errMsg);
common.expectsError(() => (socket.write = undefined), errMsg);
+ // Resetting the socket listeners to their own value should not throw.
socket.on = socket.on;
socket.once = socket.once;
diff --git a/test/parallel/test-http2-withflag.js b/test/parallel/test-http2-withflag.js
deleted file mode 100644
index 3cc5c69c68..0000000000
--- a/test/parallel/test-http2-withflag.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-
-const common = require('../common');
-if (!common.hasCrypto)
- common.skip('missing crypto');
-
-require('http2');
diff --git a/test/parallel/test-https-agent-constructor.js b/test/parallel/test-https-agent-constructor.js
index 571160bbb8..69156ba0f6 100644
--- a/test/parallel/test-https-agent-constructor.js
+++ b/test/parallel/test-https-agent-constructor.js
@@ -6,5 +6,4 @@ if (!common.hasCrypto)
const assert = require('assert');
const https = require('https');
-https.Agent();
assert.ok(https.Agent() instanceof https.Agent);
diff --git a/test/parallel/test-icu-punycode.js b/test/parallel/test-icu-punycode.js
index 3ca30a6d16..82c1528798 100644
--- a/test/parallel/test-icu-punycode.js
+++ b/test/parallel/test-icu-punycode.js
@@ -34,12 +34,12 @@ const wptToASCIITests = require('../fixtures/url-toascii.js');
if (output === null) {
assert.throws(() => icu.toASCII(input),
errMessage, `ToASCII ${caseComment}`);
- icu.toASCII(input, true);
+ icu.toASCII(input, true); // Should not throw.
} else {
assert.strictEqual(icu.toASCII(input), output, `ToASCII ${caseComment}`);
assert.strictEqual(icu.toASCII(input, true), output,
`ToASCII ${caseComment} in lenient mode`);
}
- icu.toUnicode(input);
+ icu.toUnicode(input); // Should not throw.
}
}
diff --git a/test/parallel/test-internal-fs.js b/test/parallel/test-internal-fs.js
index 3f270f93d5..9bc0a98b09 100644
--- a/test/parallel/test-internal-fs.js
+++ b/test/parallel/test-internal-fs.js
@@ -4,8 +4,10 @@
const common = require('../common');
const fs = require('internal/fs');
+// Valid encodings and no args should not throw.
fs.assertEncoding();
fs.assertEncoding('utf8');
+
common.expectsError(
() => fs.assertEncoding('foo'),
{ code: 'ERR_INVALID_OPT_VALUE_ENCODING', type: TypeError }
diff --git a/test/parallel/test-internal-util-decorate-error-stack.js b/test/parallel/test-internal-util-decorate-error-stack.js
index 25141b5ea7..9d20374409 100644
--- a/test/parallel/test-internal-util-decorate-error-stack.js
+++ b/test/parallel/test-internal-util-decorate-error-stack.js
@@ -12,12 +12,13 @@ const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol'];
const decorateErrorStack = internalUtil.decorateErrorStack;
+// Verify that decorateErrorStack does not throw with non-objects.
decorateErrorStack();
decorateErrorStack(null);
decorateErrorStack(1);
decorateErrorStack(true);
-// Verify that a stack property is not added to non-Errors
+// Verify that a stack property is not added to non-Errors.
const obj = {};
decorateErrorStack(obj);
assert.strictEqual(obj.stack, undefined);
@@ -46,12 +47,12 @@ try {
assert(typeof err, 'object');
checkStack(err.stack);
-// Verify that the stack is only decorated once
+// Verify that the stack is only decorated once.
decorateErrorStack(err);
decorateErrorStack(err);
checkStack(err.stack);
-// Verify that the stack is only decorated once for uncaught exceptions
+// Verify that the stack is only decorated once for uncaught exceptions.
const args = [
'-e',
`require('${badSyntaxPath}')`
@@ -59,14 +60,14 @@ const args = [
const result = spawnSync(process.argv[0], args, { encoding: 'utf8' });
checkStack(result.stderr);
-// Verify that the stack is unchanged when there is no arrow message
+// Verify that the stack is unchanged when there is no arrow message.
err = new Error('foo');
let originalStack = err.stack;
decorateErrorStack(err);
assert.strictEqual(originalStack, err.stack);
// Verify that the arrow message is added to the start of the stack when it
-// exists
+// exists.
const arrowMessage = 'arrow_message';
err = new Error('foo');
originalStack = err.stack;
diff --git a/test/parallel/test-module-symlinked-peer-modules.js b/test/parallel/test-module-symlinked-peer-modules.js
index d6494da8a9..003bf1a49b 100644
--- a/test/parallel/test-module-symlinked-peer-modules.js
+++ b/test/parallel/test-module-symlinked-peer-modules.js
@@ -59,4 +59,4 @@ fs.writeFileSync(path.join(moduleB, 'package.json'),
fs.writeFileSync(path.join(moduleB, 'index.js'),
'module.exports = 1;', 'utf8');
-require(path.join(app, 'index'));
+require(path.join(app, 'index')); // Should not throw.
diff --git a/test/parallel/test-net-after-close.js b/test/parallel/test-net-after-close.js
index 23e265c09a..0750ba0f43 100644
--- a/test/parallel/test-net-after-close.js
+++ b/test/parallel/test-net-after-close.js
@@ -34,6 +34,8 @@ server.listen(0, common.mustCall(function() {
c.on('close', common.mustCall(function() {
console.error('connection closed');
assert.strictEqual(c._handle, null);
+ // Calling functions / accessing properties of a closed socket should not
+ // throw.
c.setNoDelay();
c.setKeepAlive();
c.bufferSize;
diff --git a/test/parallel/test-net-during-close.js b/test/parallel/test-net-during-close.js
index 11c3dab00f..7bceb64041 100644
--- a/test/parallel/test-net-during-close.js
+++ b/test/parallel/test-net-during-close.js
@@ -30,11 +30,11 @@ const server = net.createServer(function(socket) {
server.listen(0, common.mustCall(function() {
const client = net.createConnection(this.address().port);
server.close();
- // server connection event has not yet fired
- // client is still attempting to connect
+ // Server connection event has not yet fired client is still attempting to
+ // connect. Accessing properties should not throw in this case.
client.remoteAddress;
client.remoteFamily;
client.remotePort;
- // exit now, do not wait for the client error event
+ // Exit now, do not wait for the client error event.
process.exit(0);
}));
diff --git a/test/parallel/test-performance.js b/test/parallel/test-performance.js
index 9b6f2fe957..a8ea38997f 100644
--- a/test/parallel/test-performance.js
+++ b/test/parallel/test-performance.js
@@ -64,7 +64,7 @@ assert.strictEqual(typeof performance.timeOrigin, 'number');
{
performance.mark('A');
[undefined, null, 'foo', 'initialize', 1].forEach((i) => {
- performance.measure('test', i, 'A');
+ performance.measure('test', i, 'A'); // Should not throw.
});
[undefined, null, 'foo', 1].forEach((i) => {
diff --git a/test/parallel/test-process-geteuid-getegid.js b/test/parallel/test-process-geteuid-getegid.js
index 96e8765eb9..41e37874a4 100644
--- a/test/parallel/test-process-geteuid-getegid.js
+++ b/test/parallel/test-process-geteuid-getegid.js
@@ -21,6 +21,7 @@ assert.throws(() => {
// If we're not running as super user...
if (process.getuid() !== 0) {
+ // Should not throw.
process.getegid();
process.geteuid();
diff --git a/test/parallel/test-process-setuid-setgid.js b/test/parallel/test-process-setuid-setgid.js
index 0060e3b1ca..41fef8c9c8 100644
--- a/test/parallel/test-process-setuid-setgid.js
+++ b/test/parallel/test-process-setuid-setgid.js
@@ -39,6 +39,7 @@ assert.throws(() => {
// If we're not running as super user...
if (process.getuid() !== 0) {
+ // Should not throw.
process.getgid();
process.getuid();
diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js
index 25d3774528..0dd66d0eb8 100644
--- a/test/parallel/test-querystring.js
+++ b/test/parallel/test-querystring.js
@@ -300,7 +300,7 @@ assert.strictEqual('foo=', qs.stringify({ foo: Infinity }));
assert.strictEqual(f, 'a=b&q=x%3Dy%26y%3Dz');
}
-qs.parse(undefined);
+qs.parse(undefined); // Should not throw.
// nested in colon
{
diff --git a/test/parallel/test-readline-csi.js b/test/parallel/test-readline-csi.js
index 54ca6bde97..f5c2d3044c 100644
--- a/test/parallel/test-readline-csi.js
+++ b/test/parallel/test-readline-csi.js
@@ -61,6 +61,7 @@ assert.deepStrictEqual(writable.data, CSI.kClearLine);
assert.deepStrictEqual(writable.data, set[2]);
});
+// Undefined or null as stream should not throw.
readline.cursorTo(null);
readline.cursorTo();
diff --git a/test/parallel/test-stream-writable-null.js b/test/parallel/test-stream-writable-null.js
index 706141821b..63e122a3b4 100644
--- a/test/parallel/test-stream-writable-null.js
+++ b/test/parallel/test-stream-writable-null.js
@@ -27,13 +27,9 @@ common.expectsError(
}
);
-{
- const m = new MyWritable({ objectMode: true }).on('error', (e) => {
- assert.ok(e);
- });
- m.write(null, (err) => {
- assert.ok(err);
- });
+{ // Should not throw.
+ const m = new MyWritable({ objectMode: true }).on('error', assert);
+ m.write(null, assert);
}
common.expectsError(
@@ -47,25 +43,19 @@ common.expectsError(
}
);
-{
- const m = new MyWritable().on('error', (e) => {
- assert.ok(e);
- });
- m.write(false, (err) => {
- assert.ok(err);
- });
+{ // Should not throw.
+ const m = new MyWritable().on('error', assert);
+ m.write(false, assert);
}
-{
+{ // Should not throw.
const m = new MyWritable({ objectMode: true });
- m.write(false, (err) => assert.ifError(err));
+ m.write(false, assert.ifError);
}
-{
+{ // Should not throw.
const m = new MyWritable({ objectMode: true }).on('error', (e) => {
assert.ifError(e || new Error('should not get here'));
});
- m.write(false, (err) => {
- assert.ifError(err);
- });
+ m.write(false, assert.ifError);
}
diff --git a/test/parallel/test-timers-unref.js b/test/parallel/test-timers-unref.js
index d8624d8d9c..8c4891f1ed 100644
--- a/test/parallel/test-timers-unref.js
+++ b/test/parallel/test-timers-unref.js
@@ -30,6 +30,7 @@ let checks = 0;
const LONG_TIME = 10 * 1000;
const SHORT_TIME = 100;
+// Should not throw.
setTimeout(() => {}, 10).unref().ref().unref();
setInterval(() => {}, 10).unref().ref().unref();
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js
index 4f717e2d6b..49ef4e0ecd 100644
--- a/test/parallel/test-util-inspect.js
+++ b/test/parallel/test-util-inspect.js
@@ -146,7 +146,7 @@ for (const showHidden of [true, false]) {
' y: 1337 }');
}
-// Now do the same checks but from a different context
+// Now do the same checks but from a different context.
for (const showHidden of [true, false]) {
const ab = vm.runInNewContext('new ArrayBuffer(4)');
const dv = vm.runInNewContext('new DataView(ab, 1, 2)', { ab });
@@ -211,7 +211,7 @@ for (const showHidden of [true, false]) {
);
});
-// Now check that declaring a TypedArray in a different context works the same
+// Now check that declaring a TypedArray in a different context works the same.
[ Float32Array,
Float64Array,
Int16Array,
@@ -252,7 +252,7 @@ assert.strictEqual(
}), { showHidden: true }),
'{ visible: 1, [hidden]: 2 }'
);
-// Objects without prototype
+// Objects without prototype.
assert.strictEqual(
util.inspect(Object.create(null, {
name: { value: 'Tim', enumerable: true },
@@ -269,7 +269,7 @@ assert.strictEqual(
'{ name: \'Tim\' }'
);
-// Dynamic properties
+// Dynamic properties.
{
assert.strictEqual(
util.inspect({ get readonly() {} }),
@@ -289,7 +289,7 @@ assert.strictEqual(
assert.strictEqual(util.inspect(value), '{ a: [Circular] }');
}
-// Array with dynamic properties
+// Array with dynamic properties.
{
const value = [1, 2, 3];
Object.defineProperty(
@@ -312,7 +312,7 @@ assert.strictEqual(
'[ 1, 2, 3, growingLength: [Getter], \'-1\': -1 ]');
}
-// Array with inherited number properties
+// Array with inherited number properties.
{
class CustomArray extends Array {}
CustomArray.prototype[5] = 'foo';
@@ -320,7 +320,7 @@ assert.strictEqual(
assert.strictEqual(util.inspect(arr), 'CustomArray [ <50 empty items> ]');
}
-// Array with extra properties
+// Array with extra properties.
{
const arr = [1, 2, 3, , ];
arr.foo = 'bar';
@@ -352,10 +352,10 @@ assert.strictEqual(
assert.strictEqual(util.inspect(arr3), "[ '-1': -1 ]");
}
-// Indices out of bounds
+// Indices out of bounds.
{
const arr = [];
- arr[2 ** 32] = true; // not a valid array index
+ arr[2 ** 32] = true; // Not a valid array index.
assert.strictEqual(util.inspect(arr), "[ '4294967296': true ]");
arr[0] = true;
arr[10] = true;
@@ -375,28 +375,28 @@ assert.strictEqual(
].join('\n '));
}
-// Function with properties
+// Function with properties.
{
const value = () => {};
value.aprop = 42;
assert.strictEqual(util.inspect(value), '{ [Function: value] aprop: 42 }');
}
-// Anonymous function with properties
+// Anonymous function with properties.
{
const value = (() => function() {})();
value.aprop = 42;
assert.strictEqual(util.inspect(value), '{ [Function] aprop: 42 }');
}
-// Regular expressions with properties
+// Regular expressions with properties.
{
const value = /123/ig;
value.aprop = 42;
assert.strictEqual(util.inspect(value), '{ /123/gi aprop: 42 }');
}
-// Dates with properties
+// Dates with properties.
{
const value = new Date('Sun, 14 Feb 2010 11:48:40 GMT');
value.aprop = 42;
@@ -404,7 +404,7 @@ assert.strictEqual(
'{ 2010-02-14T11:48:40.000Z aprop: 42 }');
}
-// test the internal isDate implementation
+// Test the internal isDate implementation.
{
const Date2 = vm.runInNewContext('Date');
const d = new Date2();
@@ -414,13 +414,13 @@ assert.strictEqual(
assert.strictEqual(orig, after);
}
-// test positive/negative zero
+// Test positive/negative zero.
assert.strictEqual(util.inspect(0), '0');
assert.strictEqual(util.inspect(-0), '-0');
-// edge case from check
+// Edge case from check.
assert.strictEqual(util.inspect(-5e-324), '-5e-324');
-// test for sparse array
+// Test for sparse array.
{
const a = ['foo', 'bar', 'baz'];
assert.strictEqual(util.inspect(a), '[ \'foo\', \'bar\', \'baz\' ]');
@@ -444,7 +444,7 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
);
}
-// test for Array constructor in different context
+// Test for Array constructor in different context.
{
const map = new Map();
map.set(1, 2);
@@ -457,7 +457,7 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
assert.strictEqual(util.inspect(valsOutput), '[ [ 1, 2 ] ]');
}
-// test for other constructors in different context
+// Test for other constructors in different context.
{
let obj = vm.runInNewContext('(function(){return {}})()', {});
assert.strictEqual(util.inspect(obj), '{}');
@@ -469,7 +469,7 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
assert.strictEqual(util.inspect(obj), 'Promise { <pending> }');
}
-// test for property descriptors
+// Test for property descriptors.
{
const getter = Object.create(null, {
a: {
@@ -495,7 +495,7 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
);
}
-// exceptions should print the error message, not '{}'
+// Exceptions should print the error message, not '{}'.
{
const errors = [];
errors.push(new Error());
@@ -516,7 +516,7 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
assert(ex.includes('[message]'));
}
-// Doesn't capture stack trace
+// Doesn't capture stack trace.
{
function BadCustomError(msg) {
Error.call(this);
@@ -533,7 +533,6 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
}
// GH-1941
-// should not throw:
assert.strictEqual(util.inspect(Object.create(Date.prototype)), 'Date {}');
// GH-1944
@@ -543,20 +542,20 @@ assert.strictEqual(util.inspect(Object.create(Date.prototype)), 'Date {}');
util.inspect(d);
}
+// Should not throw.
{
const d = new Date();
d.toISOString = null;
util.inspect(d);
}
+// Should not throw.
const r = /regexp/;
r.toString = null;
util.inspect(r);
-// bug with user-supplied inspect function returns non-string
-util.inspect([{
- inspect: () => 123
-}]);
+// Bug with user-supplied inspect function returns non-string.
+util.inspect([{ inspect: () => 123 }]);
// GH-2225
{
@@ -592,7 +591,7 @@ util.inspect([{
);
}
-// util.inspect.styles and util.inspect.colors
+// Test util.inspect.styles and util.inspect.colors.
{
function testColorStyle(style, input, implicit) {
const colorName = util.inspect.styles[style];
@@ -619,12 +618,10 @@ util.inspect([{
testColorStyle('regexp', /regexp/);
}
-// an object with "hasOwnProperty" overwritten should not throw
-util.inspect({
- hasOwnProperty: null
-});
+// An object with "hasOwnProperty" overwritten should not throw.
+util.inspect({ hasOwnProperty: null });
-// new API, accepts an "options" object
+// New API, accepts an "options" object.
{
const subject = { foo: 'bar', hello: 31, a: { b: { c: { d: 0 } } } };
Object.defineProperty(subject, 'hidden', { enumerable: false, value: null });
@@ -664,7 +661,7 @@ util.inspect({
}
{
- // "customInspect" option can enable/disable calling inspect() on objects
+ // "customInspect" option can enable/disable calling inspect() on objects.
const subject = { inspect: () => 123 };
assert.strictEqual(
@@ -684,7 +681,7 @@ util.inspect({
true
);
- // custom inspect() functions should be able to return other Objects
+ // Custom inspect() functions should be able to return other Objects.
subject.inspect = () => ({ foo: 'bar' });
assert.strictEqual(util.inspect(subject), '{ foo: \'bar\' }');
@@ -697,7 +694,7 @@ util.inspect({
}
{
- // "customInspect" option can enable/disable calling [util.inspect.custom]()
+ // "customInspect" option can enable/disable calling [util.inspect.custom]().
const subject = { [util.inspect.custom]: () => 123 };
assert.strictEqual(
@@ -709,7 +706,7 @@ util.inspect({
false
);
- // a custom [util.inspect.custom]() should be able to return other Objects
+ // A custom [util.inspect.custom]() should be able to return other Objects.
subject[util.inspect.custom] = () => ({ foo: 'bar' });
assert.strictEqual(util.inspect(subject), '{ foo: \'bar\' }');
@@ -722,7 +719,7 @@ util.inspect({
}
{
- // [util.inspect.custom] takes precedence over inspect
+ // [util.inspect.custom] takes precedence over inspect.
const subject = {
[util.inspect.custom]() { return 123; },
inspect() { return 456; }
@@ -757,7 +754,7 @@ util.inspect({
`{ a: 123,\n [Symbol(${UIC})]: [Function: [${UIC}]] }`);
}
-// util.inspect with "colors" option should produce as many lines as without it
+// util.inspect with "colors" option should produce as many lines as without it.
{
function testLines(input) {
const countLines = (str) => (str.match(/\n/g) || []).length;
@@ -781,7 +778,7 @@ util.inspect({
});
}
-// test boxed primitives output the correct values
+// Test boxed primitives output the correct values.
assert.strictEqual(util.inspect(new String('test')), '[String: \'test\']');
assert.strictEqual(
util.inspect(Object(Symbol('test'))),
@@ -794,7 +791,7 @@ assert.strictEqual(util.inspect(new Number(-0)), '[Number: -0]');
assert.strictEqual(util.inspect(new Number(-1.1)), '[Number: -1.1]');
assert.strictEqual(util.inspect(new Number(13.37)), '[Number: 13.37]');
-// test boxed primitives with own properties
+// Test boxed primitives with own properties.
{
const str = new String('baz');
str.foo = 'bar';
@@ -809,7 +806,7 @@ assert.strictEqual(util.inspect(new Number(13.37)), '[Number: 13.37]');
assert.strictEqual(util.inspect(num), '{ [Number: 13.37] foo: \'bar\' }');
}
-// test es6 Symbol
+// Test es6 Symbol.
if (typeof Symbol !== 'undefined') {
assert.strictEqual(util.inspect(Symbol()), 'Symbol()');
assert.strictEqual(util.inspect(Symbol(123)), 'Symbol(123)');
@@ -845,7 +842,7 @@ if (typeof Symbol !== 'undefined') {
'[ 1, 2, 3, [Symbol(symbol)]: 42 ]');
}
-// test Set
+// Test Set.
{
assert.strictEqual(util.inspect(new Set()), 'Set {}');
assert.strictEqual(util.inspect(new Set([1, 2, 3])), 'Set { 1, 2, 3 }');
@@ -857,14 +854,14 @@ if (typeof Symbol !== 'undefined') {
);
}
-// Test circular Set
+// Test circular Set.
{
const set = new Set();
set.add(set);
assert.strictEqual(util.inspect(set), 'Set { [Circular] }');
}
-// test Map
+// Test Map.
{
assert.strictEqual(util.inspect(new Map()), 'Map {}');
assert.strictEqual(util.inspect(new Map([[1, 'a'], [2, 'b'], [3, 'c']])),
@@ -875,7 +872,7 @@ if (typeof Symbol !== 'undefined') {
'Map { \'foo\' => null, [size]: 1, bar: 42 }');
}
-// Test circular Map
+// Test circular Map.
{
const map = new Map();
map.set(map, 'map');
@@ -887,14 +884,14 @@ if (typeof Symbol !== 'undefined') {
assert.strictEqual(util.inspect(map), "Map { 'map' => [Circular] }");
}
-// test Promise
+// Test Promise.
{
const resolved = Promise.resolve(3);
assert.strictEqual(util.inspect(resolved), 'Promise { 3 }');
const rejected = Promise.reject(3);
assert.strictEqual(util.inspect(rejected), 'Promise { <rejected> 3 }');
- // squelch UnhandledPromiseRejection
+ // Squelch UnhandledPromiseRejection.
rejected.catch(() => {});
const pending = new Promise(() => {});
@@ -916,33 +913,33 @@ if (typeof Symbol !== 'undefined') {
global.Promise = oldPromise;
}
-// Test Map iterators
+// Test Map iterators.
{
const map = new Map([['foo', 'bar']]);
assert.strictEqual(util.inspect(map.keys()), '[Map Iterator] { \'foo\' }');
assert.strictEqual(util.inspect(map.values()), '[Map Iterator] { \'bar\' }');
assert.strictEqual(util.inspect(map.entries()),
'[Map Iterator] { [ \'foo\', \'bar\' ] }');
- // make sure the iterator doesn't get consumed
+ // Make sure the iterator doesn't get consumed.
const keys = map.keys();
assert.strictEqual(util.inspect(keys), '[Map Iterator] { \'foo\' }');
assert.strictEqual(util.inspect(keys), '[Map Iterator] { \'foo\' }');
}
-// Test Set iterators
+// Test Set iterators.
{
const aSet = new Set([1, 3]);
assert.strictEqual(util.inspect(aSet.keys()), '[Set Iterator] { 1, 3 }');
assert.strictEqual(util.inspect(aSet.values()), '[Set Iterator] { 1, 3 }');
assert.strictEqual(util.inspect(aSet.entries()),
'[Set Iterator] { [ 1, 1 ], [ 3, 3 ] }');
- // make sure the iterator doesn't get consumed
+ // Make sure the iterator doesn't get consumed.
const keys = aSet.keys();
assert.strictEqual(util.inspect(keys), '[Set Iterator] { 1, 3 }');
assert.strictEqual(util.inspect(keys), '[Set Iterator] { 1, 3 }');
}
-// Test alignment of items in container
+// Test alignment of items in container.
// Assumes that the first numeric character is the start of an item.
{
function checkAlignment(container) {
@@ -977,7 +974,7 @@ if (typeof Symbol !== 'undefined') {
}
-// Test display of constructors
+// Test display of constructors.
{
class ObjectSubclass {}
class ArraySubclass extends Array {}
@@ -1003,7 +1000,7 @@ if (typeof Symbol !== 'undefined') {
);
}
-// Empty and circular before depth
+// Empty and circular before depth.
{
const arr = [[[[]]]];
assert.strictEqual(util.inspect(arr, { depth: 2 }), '[ [ [ [] ] ] ]');
@@ -1099,14 +1096,14 @@ if (typeof Symbol !== 'undefined') {
assert.strictEqual(twoLines, '{ foo: \'abc\',\n bar: \'xyz\' }');
}
-// util.inspect.defaultOptions tests
+// util.inspect.defaultOptions tests.
{
const arr = new Array(101).fill();
const obj = { a: { a: { a: { a: 1 } } } };
const oldOptions = Object.assign({}, util.inspect.defaultOptions);
- // Set single option through property assignment
+ // Set single option through property assignment.
util.inspect.defaultOptions.maxArrayLength = null;
assert(!/1 more item/.test(util.inspect(arr)));
util.inspect.defaultOptions.maxArrayLength = oldOptions.maxArrayLength;
@@ -1120,7 +1117,7 @@ if (typeof Symbol !== 'undefined') {
JSON.stringify(oldOptions)
);
- // Set multiple options through object assignment
+ // Set multiple options through object assignment.
util.inspect.defaultOptions = { maxArrayLength: null, depth: 2 };
assert(!/1 more item/.test(util.inspect(arr)));
assert(/Object/.test(util.inspect(obj)));
diff --git a/test/parallel/test-vm-create-context-arg.js b/test/parallel/test-vm-create-context-arg.js
index f549715381..2bcdc8573f 100644
--- a/test/parallel/test-vm-create-context-arg.js
+++ b/test/parallel/test-vm-create-context-arg.js
@@ -28,6 +28,7 @@ assert.throws(function() {
vm.createContext('string is not supported');
}, /^TypeError: sandbox must be an object$/);
+// Should not throw.
vm.createContext({ a: 1 });
vm.createContext([0, 1, 2, 3]);
diff --git a/test/parallel/test-vm-cross-context.js b/test/parallel/test-vm-cross-context.js
index 785cc9d7bd..b7cf1309d3 100644
--- a/test/parallel/test-vm-cross-context.js
+++ b/test/parallel/test-vm-cross-context.js
@@ -25,4 +25,5 @@ require('../common');
const vm = require('vm');
const ctx = vm.createContext(global);
+// Should not throw.
vm.runInContext('!function() { var x = console.log; }()', ctx);
diff --git a/test/pummel/test-fs-largefile.js b/test/pummel/test-fs-largefile.js
index 369f831192..2e9dda0495 100644
--- a/test/pummel/test-fs-largefile.js
+++ b/test/pummel/test-fs-largefile.js
@@ -44,6 +44,7 @@ assert.strictEqual(readBuf.toString(), message);
fs.readSync(fd, readBuf, 0, 1, 0);
assert.strictEqual(readBuf[0], 0);
+// Verify that floating point positions do not throw.
fs.writeSync(fd, writeBuf, 0, writeBuf.length, 42.000001);
fs.close(fd);
diff --git a/test/pummel/test-fs-watch-file.js b/test/pummel/test-fs-watch-file.js
index 62abf0c18f..e9d208778f 100644
--- a/test/pummel/test-fs-watch-file.js
+++ b/test/pummel/test-fs-watch-file.js
@@ -68,6 +68,7 @@ assert.throws(
}
);
+// Does not throw.
fs.watchFile(filepathOne, function() {
fs.unwatchFile(filepathOne);
++watchSeenOne;
@@ -91,7 +92,7 @@ assert.throws(
}
);
-{
+{ // Does not throw.
function a() {
fs.unwatchFile(filepathTwo, a);
++watchSeenTwo;
@@ -108,7 +109,7 @@ setTimeout(function() {
fs.writeFileSync(filepathTwoAbs, 'pardner');
}, 1000);
-{
+{ // Does not throw.
function b() {
fs.unwatchFile(filenameThree, b);
++watchSeenThree;
@@ -130,7 +131,7 @@ setTimeout(function() {
fs.writeFileSync(filenameFour, 'hey');
}, 500);
-{
+{ // Does not throw.
function a() {
++watchSeenFour;
assert.strictEqual(1, watchSeenFour);
diff --git a/test/sequential/test-inspector-module.js b/test/sequential/test-inspector-module.js
index 5b793bf3b4..f97d712979 100644
--- a/test/sequential/test-inspector-module.js
+++ b/test/sequential/test-inspector-module.js
@@ -56,4 +56,5 @@ common.expectsError(
);
session.disconnect();
+// Calling disconnect twice should not throw.
session.disconnect();