summaryrefslogtreecommitdiff
path: root/test/parallel
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-02-09 02:32:04 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-02-16 16:53:47 +0100
commitcaee112e52b64f4bc1118c4a5fa5ad7b4211efea (patch)
tree7b60b49da3f863917a23ebc94c00bf2f13cc1348 /test/parallel
parent4d3c3f039af08b954fbbba1e9a50979ffc98592b (diff)
downloadandroid-node-v8-caee112e52b64f4bc1118c4a5fa5ad7b4211efea.tar.gz
android-node-v8-caee112e52b64f4bc1118c4a5fa5ad7b4211efea.tar.bz2
android-node-v8-caee112e52b64f4bc1118c4a5fa5ad7b4211efea.zip
test: remove assert.doesNotThrow()
There is actually no reason to use `assert.doesNotThrow()` in the tests. If a test throws, just let the error bubble up right away instead of first catching it and then rethrowing it. PR-URL: https://github.com/nodejs/node/pull/18669 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/parallel')
-rw-r--r--test/parallel/test-assert-checktag.js8
-rw-r--r--test/parallel/test-assert-deep.js111
-rw-r--r--test/parallel/test-assert-if-error.js6
-rw-r--r--test/parallel/test-assert.js32
-rw-r--r--test/parallel/test-buffer-alloc.js30
-rw-r--r--test/parallel/test-buffer-bad-overload.js8
-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-inspect.js6
-rw-r--r--test/parallel/test-buffer-read.js6
-rw-r--r--test/parallel/test-buffer-sharedarraybuffer.js2
-rw-r--r--test/parallel/test-buffer-slice.js2
-rw-r--r--test/parallel/test-child-process-detached.js4
-rw-r--r--test/parallel/test-child-process-spawn-typeerror.js109
-rw-r--r--test/parallel/test-console-async-write-error.js5
-rw-r--r--test/parallel/test-console-instance.js4
-rw-r--r--test/parallel/test-console-is-a-namespace.js5
-rw-r--r--test/parallel/test-console-sync-write-error.js13
-rw-r--r--test/parallel/test-console.js28
-rw-r--r--test/parallel/test-crypto-binary-default.js4
-rw-r--r--test/parallel/test-crypto-cipher-decipher.js12
-rw-r--r--test/parallel/test-crypto-dh-odd-key.js2
-rw-r--r--test/parallel/test-crypto-dh.js4
-rw-r--r--test/parallel/test-crypto-padding.js26
-rw-r--r--test/parallel/test-crypto-pbkdf2.js8
-rw-r--r--test/parallel/test-crypto-rsa-dsa.js13
-rw-r--r--test/parallel/test-crypto.js4
-rw-r--r--test/parallel/test-dgram-createSocket-type.js6
-rw-r--r--test/parallel/test-dns-lookup.js86
-rw-r--r--test/parallel/test-dns.js53
-rw-r--r--test/parallel/test-domain-load-after-set-uncaught-exception-capture.js3
-rw-r--r--test/parallel/test-event-emitter-remove-all-listeners.js2
-rw-r--r--test/parallel/test-fs-access.js11
-rw-r--r--test/parallel/test-fs-buffer.js22
-rw-r--r--test/parallel/test-fs-exists.js6
-rw-r--r--test/parallel/test-fs-make-callback.js3
-rw-r--r--test/parallel/test-fs-makeStatsCallback.js5
-rw-r--r--test/parallel/test-fs-mkdtemp.js4
-rw-r--r--test/parallel/test-fs-options-immutable.js63
-rw-r--r--test/parallel/test-fs-read-stream-throw-type-error.js17
-rw-r--r--test/parallel/test-fs-timestamp-parsing-error.js3
-rw-r--r--test/parallel/test-fs-write-stream-throw-type-error.js20
-rw-r--r--test/parallel/test-http-client-reject-unexpected-agent.js2
-rw-r--r--test/parallel/test-http-header-read.js6
-rw-r--r--test/parallel/test-http-hostname-typechecking.js7
-rw-r--r--test/parallel/test-http-invalidheaderfield.js22
-rw-r--r--test/parallel/test-http-response-add-header-after-sent.js5
-rw-r--r--test/parallel/test-http-response-remove-header-after-sent.js5
-rw-r--r--test/parallel/test-http2-binding.js2
-rw-r--r--test/parallel/test-http2-client-rststream-before-connect.js2
-rw-r--r--test/parallel/test-http2-compat-serverrequest-pause.js4
-rw-r--r--test/parallel/test-http2-compat-serverrequest-settimeout.js5
-rw-r--r--test/parallel/test-http2-compat-serverresponse-destroy.js5
-rw-r--r--test/parallel/test-http2-compat-serverresponse-headers-after-destroy.js8
-rw-r--r--test/parallel/test-http2-compat-serverresponse-settimeout.js5
-rw-r--r--test/parallel/test-http2-compat-serverresponse-statuscode.js10
-rw-r--r--test/parallel/test-http2-compat-socket.js2
-rw-r--r--test/parallel/test-http2-connect.js24
-rw-r--r--test/parallel/test-http2-getpackedsettings.js10
-rw-r--r--test/parallel/test-http2-server-startup.js25
-rw-r--r--test/parallel/test-http2-session-settings.js4
-rw-r--r--test/parallel/test-http2-socket-proxy.js4
-rw-r--r--test/parallel/test-http2-util-asserts.js5
-rw-r--r--test/parallel/test-http2-withflag.js3
-rw-r--r--test/parallel/test-https-agent-constructor.js2
-rw-r--r--test/parallel/test-https-options-boolean-check.js19
-rw-r--r--test/parallel/test-icu-punycode.js5
-rw-r--r--test/parallel/test-internal-errors.js46
-rw-r--r--test/parallel/test-internal-fs.js5
-rw-r--r--test/parallel/test-internal-util-assertCrypto.js2
-rw-r--r--test/parallel/test-internal-util-decorate-error-stack.js10
-rw-r--r--test/parallel/test-module-symlinked-peer-modules.js5
-rw-r--r--test/parallel/test-net-after-close.js18
-rw-r--r--test/parallel/test-net-connect-options-port.js21
-rw-r--r--test/parallel/test-net-during-close.js9
-rw-r--r--test/parallel/test-net-options-lookup.js5
-rw-r--r--test/parallel/test-net-server-call-listen-multiple-times.js15
-rw-r--r--test/parallel/test-net-socket-timeout.js4
-rw-r--r--test/parallel/test-performance.js2
-rw-r--r--test/parallel/test-performanceobserver.js10
-rw-r--r--test/parallel/test-process-binding.js8
-rw-r--r--test/parallel/test-process-emitwarning.js2
-rw-r--r--test/parallel/test-process-env-symbols.js2
-rw-r--r--test/parallel/test-process-geteuid-getegid.js6
-rw-r--r--test/parallel/test-process-setuid-setgid.js6
-rw-r--r--test/parallel/test-querystring.js4
-rw-r--r--test/parallel/test-readline-csi.js12
-rw-r--r--test/parallel/test-readline-interface.js23
-rw-r--r--test/parallel/test-regress-GH-6235.js5
-rw-r--r--test/parallel/test-repl-null.js6
-rw-r--r--test/parallel/test-repl-throw-null-or-undefined.js15
-rw-r--r--test/parallel/test-stdio-closed.js2
-rw-r--r--test/parallel/test-stream-writable-null.js17
-rw-r--r--test/parallel/test-timers-clear-null-does-not-throw-error.js19
-rw-r--r--test/parallel/test-timers-unref.js10
-rw-r--r--test/parallel/test-tls-client-abort.js8
-rw-r--r--test/parallel/test-tls-client-abort2.js5
-rw-r--r--test/parallel/test-tls-legacy-deprecated.js3
-rw-r--r--test/parallel/test-tls-options-boolean-check.js13
-rw-r--r--test/parallel/test-util-inspect-proxy.js2
-rw-r--r--test/parallel/test-util-inspect.js32
-rw-r--r--test/parallel/test-uv-errno.js14
-rw-r--r--test/parallel/test-vm-access-process-env.js8
-rw-r--r--test/parallel/test-vm-create-context-arg.js14
-rw-r--r--test/parallel/test-vm-cross-context.js5
-rw-r--r--test/parallel/test-vm-proxy-failure-CP.js3
-rw-r--r--test/parallel/test-whatwg-encoding-textdecoder.js14
-rw-r--r--test/parallel/test-whatwg-encoding-textencoder.js6
-rw-r--r--test/parallel/test-zlib-close-after-error.js2
-rw-r--r--test/parallel/test-zlib-deflate-constructors.js24
-rw-r--r--test/parallel/test-zlib-flush-flags.js9
-rw-r--r--test/parallel/test-zlib-invalid-input.js8
-rw-r--r--test/parallel/test-zlib-truncated.js12
-rw-r--r--test/parallel/test-zlib.js4
114 files changed, 526 insertions, 900 deletions
diff --git a/test/parallel/test-assert-checktag.js b/test/parallel/test-assert-checktag.js
index c4823243e7..632bfa03c6 100644
--- a/test/parallel/test-assert-checktag.js
+++ b/test/parallel/test-assert-checktag.js
@@ -30,8 +30,8 @@ function re(literals, ...values) {
FakeDate.prototype = Date.prototype;
const fake = new FakeDate();
- assert.doesNotThrow(() => assert.deepEqual(date, fake));
- assert.doesNotThrow(() => assert.deepEqual(fake, date));
+ assert.deepEqual(date, fake);
+ assert.deepEqual(fake, date);
// For deepStrictEqual we check the runtime type,
// then reveal the fakeness of the fake date
@@ -47,7 +47,7 @@ function re(literals, ...values) {
for (const prop of Object.keys(global)) {
fakeGlobal[prop] = global[prop];
}
- assert.doesNotThrow(() => assert.deepEqual(fakeGlobal, global));
+ assert.deepEqual(fakeGlobal, global);
// Message will be truncated anyway, don't validate
assert.throws(() => assert.deepStrictEqual(fakeGlobal, global),
assert.AssertionError);
@@ -59,7 +59,7 @@ function re(literals, ...values) {
for (const prop of Object.keys(process)) {
fakeProcess[prop] = process[prop];
}
- assert.doesNotThrow(() => assert.deepEqual(fakeProcess, process));
+ assert.deepEqual(fakeProcess, process);
// Message will be truncated anyway, don't validate
assert.throws(() => assert.deepStrictEqual(fakeProcess, process),
assert.AssertionError);
diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js
index 1fad9f4051..53a00c6899 100644
--- a/test/parallel/test-assert-deep.js
+++ b/test/parallel/test-assert-deep.js
@@ -34,7 +34,7 @@ const buf = Buffer.from(arr);
// They have different [[Prototype]]
assert.throws(() => assert.deepStrictEqual(arr, buf),
re`${arr} deepStrictEqual ${buf}`);
-assert.doesNotThrow(() => assert.deepEqual(arr, buf));
+assert.deepEqual(arr, buf);
{
const buf2 = Buffer.from(arr);
@@ -42,7 +42,7 @@ assert.doesNotThrow(() => assert.deepEqual(arr, buf));
assert.throws(() => assert.deepStrictEqual(buf2, buf),
re`${buf2} deepStrictEqual ${buf}`);
- assert.doesNotThrow(() => assert.deepEqual(buf2, buf));
+ assert.deepEqual(buf2, buf);
}
{
@@ -50,7 +50,7 @@ assert.doesNotThrow(() => assert.deepEqual(arr, buf));
arr2.prop = 5;
assert.throws(() => assert.deepStrictEqual(arr, arr2),
re`${arr} deepStrictEqual ${arr2}`);
- assert.doesNotThrow(() => assert.deepEqual(arr, arr2));
+ assert.deepEqual(arr, arr2);
}
const date = new Date('2016');
@@ -66,8 +66,8 @@ const date2 = new MyDate('2016');
// deepEqual returns true as long as the time are the same,
// but deepStrictEqual checks own properties
-assert.doesNotThrow(() => assert.deepEqual(date, date2));
-assert.doesNotThrow(() => assert.deepEqual(date2, date));
+assert.deepEqual(date, date2);
+assert.deepEqual(date2, date);
assert.throws(() => assert.deepStrictEqual(date, date2),
re`${date} deepStrictEqual ${date2}`);
assert.throws(() => assert.deepStrictEqual(date2, date),
@@ -85,7 +85,7 @@ const re2 = new MyRegExp('test');
// deepEqual returns true as long as the regexp-specific properties
// are the same, but deepStrictEqual checks all properties
-assert.doesNotThrow(() => assert.deepEqual(re1, re2));
+assert.deepEqual(re1, re2);
assert.throws(() => assert.deepStrictEqual(re1, re2),
re`${re1} deepStrictEqual ${re2}`);
@@ -148,11 +148,11 @@ function assertNotDeepOrStrict(a, b, err) {
}
function assertOnlyDeepEqual(a, b, err) {
- assert.doesNotThrow(() => assert.deepEqual(a, b));
+ assert.deepEqual(a, b);
assert.throws(() => assert.deepStrictEqual(a, b), err ||
re`${a} deepStrictEqual ${b}`);
- assert.doesNotThrow(() => assert.deepEqual(b, a));
+ assert.deepEqual(b, a);
assert.throws(() => assert.deepStrictEqual(b, a), err ||
re`${b} deepStrictEqual ${a}`);
}
@@ -492,10 +492,9 @@ assertOnlyDeepEqual([1, , , 3], [1, , , 3, , , ]);
// Handle NaN
assert.throws(() => { assert.deepEqual(NaN, NaN); }, assert.AssertionError);
-assert.doesNotThrow(() => { assert.deepStrictEqual(NaN, NaN); });
-assert.doesNotThrow(() => { assert.deepStrictEqual({ a: NaN }, { a: NaN }); });
-assert.doesNotThrow(
- () => { assert.deepStrictEqual([ 1, 2, NaN, 4 ], [ 1, 2, NaN, 4 ]); });
+{ assert.deepStrictEqual(NaN, NaN); }
+{ assert.deepStrictEqual({ a: NaN }, { a: NaN }); }
+assert.deepStrictEqual([ 1, 2, NaN, 4 ], [ 1, 2, NaN, 4 ]);
// Handle boxed primitives
{
@@ -547,9 +546,7 @@ assertDeepAndStrictEqual(-0, -0);
assertDeepAndStrictEqual(a, b);
}
-assert.doesNotThrow(
- () => assert.deepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14)),
- 'deepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14))');
+assert.deepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14));
assert.throws(() => assert.deepEqual(new Date(), new Date(2000, 3, 14)),
AssertionError,
@@ -561,16 +558,13 @@ assert.throws(
'notDeepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14))'
);
-assert.doesNotThrow(
- () => assert.notDeepEqual(new Date(), new Date(2000, 3, 14)),
- 'notDeepEqual(new Date(), new Date(2000, 3, 14))'
-);
+assert.notDeepEqual(new Date(), new Date(2000, 3, 14));
-assert.doesNotThrow(() => assert.deepEqual(/a/, /a/));
-assert.doesNotThrow(() => assert.deepEqual(/a/g, /a/g));
-assert.doesNotThrow(() => assert.deepEqual(/a/i, /a/i));
-assert.doesNotThrow(() => assert.deepEqual(/a/m, /a/m));
-assert.doesNotThrow(() => assert.deepEqual(/a/igm, /a/igm));
+assert.deepEqual(/a/, /a/);
+assert.deepEqual(/a/g, /a/g);
+assert.deepEqual(/a/i, /a/i);
+assert.deepEqual(/a/m, /a/m);
+assert.deepEqual(/a/igm, /a/igm);
assert.throws(() => assert.deepEqual(/ab/, /a/),
{
code: 'ERR_ASSERTION',
@@ -605,23 +599,23 @@ assert.throws(() => assert.deepEqual(/a/igm, /a/im),
{
const re1 = /a/g;
re1.lastIndex = 3;
- assert.doesNotThrow(() => assert.deepEqual(re1, /a/g));
+ assert.deepEqual(re1, /a/g);
}
-assert.doesNotThrow(() => assert.deepEqual(4, '4'), 'deepEqual(4, \'4\')');
-assert.doesNotThrow(() => assert.deepEqual(true, 1), 'deepEqual(true, 1)');
+assert.deepEqual(4, '4');
+assert.deepEqual(true, 1);
assert.throws(() => assert.deepEqual(4, '5'),
AssertionError,
'deepEqual( 4, \'5\')');
// Having the same number of owned properties && the same set of keys.
-assert.doesNotThrow(() => assert.deepEqual({ a: 4 }, { a: 4 }));
-assert.doesNotThrow(() => assert.deepEqual({ a: 4, b: '2' }, { a: 4, b: '2' }));
-assert.doesNotThrow(() => assert.deepEqual([4], ['4']));
+assert.deepEqual({ a: 4 }, { a: 4 });
+assert.deepEqual({ a: 4, b: '2' }, { a: 4, b: '2' });
+assert.deepEqual([4], ['4']);
assert.throws(
() => assert.deepEqual({ a: 4 }, { a: 4, b: true }), AssertionError);
-assert.doesNotThrow(() => assert.deepEqual(['a'], { 0: 'a' }));
-assert.doesNotThrow(() => assert.deepEqual({ a: 4, b: '1' }, { b: '1', a: 4 }));
+assert.deepEqual(['a'], { 0: 'a' });
+assert.deepEqual({ a: 4, b: '1' }, { b: '1', a: 4 });
const a1 = [1, 2, 3];
const a2 = [1, 2, 3];
a1.a = 'test';
@@ -630,7 +624,7 @@ a2.b = true;
a2.a = 'test';
assert.throws(() => assert.deepEqual(Object.keys(a1), Object.keys(a2)),
AssertionError);
-assert.doesNotThrow(() => assert.deepEqual(a1, a2));
+assert.deepEqual(a1, a2);
// Having an identical prototype property.
const nbRoot = {
@@ -654,11 +648,11 @@ nameBuilder2.prototype = nbRoot;
const nb1 = new nameBuilder('Ryan', 'Dahl');
let nb2 = new nameBuilder2('Ryan', 'Dahl');
-assert.doesNotThrow(() => assert.deepEqual(nb1, nb2));
+assert.deepEqual(nb1, nb2);
nameBuilder2.prototype = Object;
nb2 = new nameBuilder2('Ryan', 'Dahl');
-assert.doesNotThrow(() => assert.deepEqual(nb1, nb2));
+assert.deepEqual(nb1, nb2);
// Primitives and object.
assert.throws(() => assert.deepEqual(null, {}), AssertionError);
@@ -670,21 +664,15 @@ assert.throws(() => assert.deepEqual(true, {}), AssertionError);
assert.throws(() => assert.deepEqual(Symbol(), {}), AssertionError);
// Primitive wrappers and object.
-assert.doesNotThrow(() => assert.deepEqual(new String('a'), ['a']),
- AssertionError);
-assert.doesNotThrow(() => assert.deepEqual(new String('a'), { 0: 'a' }),
- AssertionError);
-assert.doesNotThrow(() => assert.deepEqual(new Number(1), {}), AssertionError);
-assert.doesNotThrow(() => assert.deepEqual(new Boolean(true), {}),
- AssertionError);
+assert.deepEqual(new String('a'), ['a']);
+assert.deepEqual(new String('a'), { 0: 'a' });
+assert.deepEqual(new Number(1), {});
+assert.deepEqual(new Boolean(true), {});
// Same number of keys but different key names.
assert.throws(() => assert.deepEqual({ a: 1 }, { b: 1 }), AssertionError);
-assert.doesNotThrow(
- () => assert.deepStrictEqual(new Date(2000, 3, 14), new Date(2000, 3, 14)),
- 'deepStrictEqual(new Date(2000, 3, 14), new Date(2000, 3, 14))'
-);
+assert.deepStrictEqual(new Date(2000, 3, 14), new Date(2000, 3, 14));
assert.throws(
() => assert.deepStrictEqual(new Date(), new Date(2000, 3, 14)),
@@ -698,16 +686,13 @@ assert.throws(
'notDeepStrictEqual(new Date(2000, 3, 14), new Date(2000, 3, 14))'
);
-assert.doesNotThrow(
- () => assert.notDeepStrictEqual(new Date(), new Date(2000, 3, 14)),
- 'notDeepStrictEqual(new Date(), new Date(2000, 3, 14))'
-);
+assert.notDeepStrictEqual(new Date(), new Date(2000, 3, 14));
-assert.doesNotThrow(() => assert.deepStrictEqual(/a/, /a/));
-assert.doesNotThrow(() => assert.deepStrictEqual(/a/g, /a/g));
-assert.doesNotThrow(() => assert.deepStrictEqual(/a/i, /a/i));
-assert.doesNotThrow(() => assert.deepStrictEqual(/a/m, /a/m));
-assert.doesNotThrow(() => assert.deepStrictEqual(/a/igm, /a/igm));
+assert.deepStrictEqual(/a/, /a/);
+assert.deepStrictEqual(/a/g, /a/g);
+assert.deepStrictEqual(/a/i, /a/i);
+assert.deepStrictEqual(/a/m, /a/m);
+assert.deepStrictEqual(/a/igm, /a/igm);
assert.throws(
() => assert.deepStrictEqual(/ab/, /a/),
{
@@ -747,7 +732,7 @@ assert.throws(
{
const re1 = /a/;
re1.lastIndex = 3;
- assert.doesNotThrow(() => assert.deepStrictEqual(re1, /a/));
+ assert.deepStrictEqual(re1, /a/);
}
assert.throws(() => assert.deepStrictEqual(4, '4'),
@@ -763,9 +748,8 @@ assert.throws(() => assert.deepStrictEqual(4, '5'),
'deepStrictEqual(4, \'5\')');
// Having the same number of owned properties && the same set of keys.
-assert.doesNotThrow(() => assert.deepStrictEqual({ a: 4 }, { a: 4 }));
-assert.doesNotThrow(
- () => assert.deepStrictEqual({ a: 4, b: '2' }, { a: 4, b: '2' }));
+assert.deepStrictEqual({ a: 4 }, { a: 4 });
+assert.deepStrictEqual({ a: 4, b: '2' }, { a: 4, b: '2' });
assert.throws(() => assert.deepStrictEqual([4], ['4']),
{
code: 'ERR_ASSERTION',
@@ -787,14 +771,13 @@ assert.throws(() => assert.deepStrictEqual(['a'], { 0: 'a' }),
/* eslint-enable */
-assert.doesNotThrow(
- () => assert.deepStrictEqual({ a: 4, b: '1' }, { b: '1', a: 4 }));
+assert.deepStrictEqual({ a: 4, b: '1' }, { b: '1', a: 4 });
assert.throws(
() => assert.deepStrictEqual([0, 1, 2, 'a', 'b'], [0, 1, 2, 'b', 'a']),
AssertionError);
-assert.doesNotThrow(() => assert.deepStrictEqual(a1, a2));
+assert.deepStrictEqual(a1, a2);
// Prototype check.
function Constructor1(first, last) {
@@ -815,7 +798,7 @@ assert.throws(() => assert.deepStrictEqual(obj1, obj2), AssertionError);
Constructor2.prototype = Constructor1.prototype;
obj2 = new Constructor2('Ryan', 'Dahl');
-assert.doesNotThrow(() => assert.deepStrictEqual(obj1, obj2));
+assert.deepStrictEqual(obj1, obj2);
// primitives
assert.throws(() => assert.deepStrictEqual(4, '4'), AssertionError);
@@ -824,7 +807,7 @@ assert.throws(() => assert.deepStrictEqual(Symbol(), Symbol()),
AssertionError);
const s = Symbol();
-assert.doesNotThrow(() => assert.deepStrictEqual(s, s));
+assert.deepStrictEqual(s, s);
// Primitives and object.
assert.throws(() => assert.deepStrictEqual(null, {}), AssertionError);
diff --git a/test/parallel/test-assert-if-error.js b/test/parallel/test-assert-if-error.js
index 3b070aac08..df464d513d 100644
--- a/test/parallel/test-assert-if-error.js
+++ b/test/parallel/test-assert-if-error.js
@@ -67,9 +67,9 @@ assert.throws(
}
);
-assert.doesNotThrow(() => { assert.ifError(null); });
-assert.doesNotThrow(() => { assert.ifError(); });
-assert.doesNotThrow(() => { assert.ifError(undefined); });
+assert.ifError(null);
+assert.ifError();
+assert.ifError(undefined);
// https://github.com/nodejs/node-v0.x-archive/issues/2893
{
diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js
index c120f47302..331ac63c47 100644
--- a/test/parallel/test-assert.js
+++ b/test/parallel/test-assert.js
@@ -38,32 +38,22 @@ assert.ok(a.AssertionError.prototype instanceof Error,
'a.AssertionError instanceof Error');
assert.throws(() => a(false), a.AssertionError, 'ok(false)');
-
-assert.doesNotThrow(() => a(true), a.AssertionError, 'ok(true)');
-
-assert.doesNotThrow(() => a('test', 'ok(\'test\')'));
-
assert.throws(() => a.ok(false), a.AssertionError, 'ok(false)');
-assert.doesNotThrow(() => a.ok(true), a.AssertionError, 'ok(true)');
-
-assert.doesNotThrow(() => a.ok('test'), 'ok(\'test\')');
+a(true);
+a('test', 'ok(\'test\')');
+a.ok(true);
+a.ok('test');
assert.throws(() => a.equal(true, false),
a.AssertionError, 'equal(true, false)');
-assert.doesNotThrow(() => a.equal(null, null), 'equal(null, null)');
-
-assert.doesNotThrow(() => a.equal(undefined, undefined),
- 'equal(undefined, undefined)');
-
-assert.doesNotThrow(() => a.equal(null, undefined), 'equal(null, undefined)');
-
-assert.doesNotThrow(() => a.equal(true, true), 'equal(true, true)');
-
-assert.doesNotThrow(() => a.equal(2, '2'), 'equal(2, \'2\')');
-
-assert.doesNotThrow(() => a.notEqual(true, false), 'notEqual(true, false)');
+a.equal(null, null);
+a.equal(undefined, undefined);
+a.equal(null, undefined);
+a.equal(true, true);
+a.equal(2, '2');
+a.notEqual(true, false);
assert.throws(() => a.notEqual(true, true),
a.AssertionError, 'notEqual(true, true)');
@@ -77,7 +67,7 @@ assert.throws(() => a.strictEqual(null, undefined),
assert.throws(() => a.notStrictEqual(2, 2),
a.AssertionError, 'notStrictEqual(2, 2)');
-assert.doesNotThrow(() => a.notStrictEqual(2, '2'), 'notStrictEqual(2, \'2\')');
+a.notStrictEqual(2, '2');
// Testing the throwing.
function thrower(errorConstructor) {
diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js
index 58792788d6..9714fcb485 100644
--- a/test/parallel/test-buffer-alloc.js
+++ b/test/parallel/test-buffer-alloc.js
@@ -63,16 +63,16 @@ assert.throws(() => b.write('test', 'utf8', 0),
// try to create 0-length buffers
-assert.doesNotThrow(() => Buffer.from(''));
-assert.doesNotThrow(() => Buffer.from('', 'ascii'));
-assert.doesNotThrow(() => Buffer.from('', 'latin1'));
-assert.doesNotThrow(() => Buffer.alloc(0));
-assert.doesNotThrow(() => Buffer.allocUnsafe(0));
-assert.doesNotThrow(() => new Buffer(''));
-assert.doesNotThrow(() => new Buffer('', 'ascii'));
-assert.doesNotThrow(() => new Buffer('', 'latin1'));
-assert.doesNotThrow(() => new Buffer('', 'binary'));
-assert.doesNotThrow(() => Buffer(0));
+Buffer.from('');
+Buffer.from('', 'ascii');
+Buffer.from('', 'latin1');
+Buffer.alloc(0);
+Buffer.allocUnsafe(0);
+new Buffer('');
+new Buffer('', 'ascii');
+new Buffer('', 'latin1');
+new Buffer('', 'binary');
+Buffer(0);
// try to write a 0-length string beyond the end of b
assert.throws(() => b.write('', 2048), RangeError);
@@ -109,7 +109,7 @@ b.copy(Buffer.alloc(1), 0, 2048, 2048);
// Offset points to the end of the buffer
// (see https://github.com/nodejs/node/issues/8127).
-assert.doesNotThrow(() => Buffer.alloc(1).write('', 1, 0));
+Buffer.alloc(1).write('', 1, 0);
// ASCII slice test
{
@@ -963,7 +963,7 @@ assert.strictEqual(SlowBuffer.prototype.offset, undefined);
Buffer.from(''));
// Check pool offset after that by trying to write string into the pool.
- assert.doesNotThrow(() => Buffer.from('abc'));
+ Buffer.from('abc');
}
@@ -993,12 +993,12 @@ common.expectsError(() => {
}
// Regression test
-assert.doesNotThrow(() => Buffer.from(new ArrayBuffer()));
+Buffer.from(new ArrayBuffer());
// Test that ArrayBuffer from a different context is detected correctly
const arrayBuf = vm.runInNewContext('new ArrayBuffer()');
-assert.doesNotThrow(() => Buffer.from(arrayBuf));
-assert.doesNotThrow(() => Buffer.from({ buffer: arrayBuf }));
+Buffer.from(arrayBuf);
+Buffer.from({ buffer: arrayBuf });
assert.throws(() => Buffer.alloc({ valueOf: () => 1 }),
/"size" argument must be of type number/);
diff --git a/test/parallel/test-buffer-bad-overload.js b/test/parallel/test-buffer-bad-overload.js
index b442a3e8a2..ec2703341b 100644
--- a/test/parallel/test-buffer-bad-overload.js
+++ b/test/parallel/test-buffer-bad-overload.js
@@ -2,9 +2,7 @@
const common = require('../common');
const assert = require('assert');
-assert.doesNotThrow(function() {
- Buffer.allocUnsafe(10);
-});
+Buffer.allocUnsafe(10);
const err = common.expectsError({
code: 'ERR_INVALID_ARG_TYPE',
@@ -16,6 +14,4 @@ assert.throws(function() {
Buffer.from(10, 'hex');
}, err);
-assert.doesNotThrow(function() {
- Buffer.from('deadbeaf', 'hex');
-});
+Buffer.from('deadbeaf', 'hex');
diff --git a/test/parallel/test-buffer-constants.js b/test/parallel/test-buffer-constants.js
index 820c8dc993..dbb6186b6d 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$/);
-assert.doesNotThrow(() => ' '.repeat(MAX_STRING_LENGTH));
+' '.repeat(MAX_STRING_LENGTH);
// 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 1b10dadb5b..324613a04f 100644
--- a/test/parallel/test-buffer-copy.js
+++ b/test/parallel/test-buffer-copy.js
@@ -93,7 +93,7 @@ bb.fill('hello crazy world');
// try to copy from before the beginning of b
-assert.doesNotThrow(() => { b.copy(c, 0, 100, 10); });
+b.copy(c, 0, 100, 10);
// copy throws at negative sourceStart
assert.throws(function() {
diff --git a/test/parallel/test-buffer-inspect.js b/test/parallel/test-buffer-inspect.js
index 6890e27a3f..aa703db67d 100644
--- a/test/parallel/test-buffer-inspect.js
+++ b/test/parallel/test-buffer-inspect.js
@@ -51,10 +51,8 @@ assert.strictEqual(util.inspect(s), expected);
buffer.INSPECT_MAX_BYTES = Infinity;
-assert.doesNotThrow(function() {
- assert.strictEqual(util.inspect(b), expected);
- assert.strictEqual(util.inspect(s), expected);
-});
+assert.strictEqual(util.inspect(b), expected);
+assert.strictEqual(util.inspect(s), expected);
b.inspect = undefined;
assert.strictEqual(util.inspect(b), expected);
diff --git a/test/parallel/test-buffer-read.js b/test/parallel/test-buffer-read.js
index 8f42542c15..ccde2cc3a2 100644
--- a/test/parallel/test-buffer-read.js
+++ b/test/parallel/test-buffer-read.js
@@ -15,11 +15,7 @@ function read(buff, funx, args, expected) {
}
);
- assert.doesNotThrow(
- () => assert.strictEqual(buff[funx](...args, true), expected),
- 'noAssert does not change return value for valid ranges'
- );
-
+ assert.strictEqual(buff[funx](...args, true), expected);
}
// testing basic functionality of readDoubleBE() and readDoubleLE()
diff --git a/test/parallel/test-buffer-sharedarraybuffer.js b/test/parallel/test-buffer-sharedarraybuffer.js
index 4485aa8cfc..536c393936 100644
--- a/test/parallel/test-buffer-sharedarraybuffer.js
+++ b/test/parallel/test-buffer-sharedarraybuffer.js
@@ -26,4 +26,4 @@ assert.deepStrictEqual(arr_buf, ar_buf);
assert.strictEqual(Buffer.byteLength(sab), sab.byteLength);
-assert.doesNotThrow(() => Buffer.from({ buffer: sab }));
+Buffer.from({ buffer: sab });
diff --git a/test/parallel/test-buffer-slice.js b/test/parallel/test-buffer-slice.js
index 8f764da09d..b55d082783 100644
--- a/test/parallel/test-buffer-slice.js
+++ b/test/parallel/test-buffer-slice.js
@@ -79,7 +79,7 @@ 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
-assert.doesNotThrow(() => Buffer.alloc(0).slice(0, 1));
+Buffer.alloc(0).slice(0, 1);
assert.strictEqual(Buffer.alloc(0).slice(0, 1).length, 0);
{
diff --git a/test/parallel/test-child-process-detached.js b/test/parallel/test-child-process-detached.js
index f53983c29e..8242536d1f 100644
--- a/test/parallel/test-child-process-detached.js
+++ b/test/parallel/test-child-process-detached.js
@@ -39,7 +39,5 @@ process.on('exit', function() {
assert.throws(function() {
process.kill(child.pid);
}, /^Error: kill ESRCH$/);
- assert.doesNotThrow(function() {
- process.kill(persistentPid);
- });
+ process.kill(persistentPid);
});
diff --git a/test/parallel/test-child-process-spawn-typeerror.js b/test/parallel/test-child-process-spawn-typeerror.js
index b62470ecc8..25ae7df7aa 100644
--- a/test/parallel/test-child-process-spawn-typeerror.js
+++ b/test/parallel/test-child-process-spawn-typeerror.js
@@ -41,21 +41,10 @@ assert.throws(function() {
}, TypeError);
// verify that valid argument combinations do not throw
-assert.doesNotThrow(function() {
- spawn(cmd);
-});
-
-assert.doesNotThrow(function() {
- spawn(cmd, []);
-});
-
-assert.doesNotThrow(function() {
- spawn(cmd, {});
-});
-
-assert.doesNotThrow(function() {
- spawn(cmd, [], {});
-});
+spawn(cmd);
+spawn(cmd, []);
+spawn(cmd, {});
+spawn(cmd, [], {});
// verify that invalid argument combinations throw
assert.throws(function() {
@@ -100,14 +89,14 @@ const n = null;
// (f, a)
// (f, a, o)
// (f, o)
-assert.doesNotThrow(function() { spawn(cmd); });
-assert.doesNotThrow(function() { spawn(cmd, a); });
-assert.doesNotThrow(function() { spawn(cmd, a, o); });
-assert.doesNotThrow(function() { spawn(cmd, o); });
+spawn(cmd);
+spawn(cmd, a);
+spawn(cmd, a, o);
+spawn(cmd, o);
// Variants of undefined as explicit 'no argument' at a position
-assert.doesNotThrow(function() { spawn(cmd, u, o); });
-assert.doesNotThrow(function() { spawn(cmd, a, u); });
+spawn(cmd, u, o);
+spawn(cmd, a, u);
assert.throws(function() { spawn(cmd, n, o); }, invalidArgTypeError);
assert.throws(function() { spawn(cmd, a, n); }, invalidArgTypeError);
@@ -128,36 +117,36 @@ assert.throws(function() { spawn(cmd, a, s); }, invalidArgTypeError);
// (f, o)
// (f, o, c)
// (f, c)
-assert.doesNotThrow(function() { execFile(cmd); });
-assert.doesNotThrow(function() { execFile(cmd, a); });
-assert.doesNotThrow(function() { execFile(cmd, a, o); });
-assert.doesNotThrow(function() { execFile(cmd, a, o, c); });
-assert.doesNotThrow(function() { execFile(cmd, a, c); });
-assert.doesNotThrow(function() { execFile(cmd, o); });
-assert.doesNotThrow(function() { execFile(cmd, o, c); });
-assert.doesNotThrow(function() { execFile(cmd, c); });
+execFile(cmd);
+execFile(cmd, a);
+execFile(cmd, a, o);
+execFile(cmd, a, o, c);
+execFile(cmd, a, c);
+execFile(cmd, o);
+execFile(cmd, o, c);
+execFile(cmd, c);
// Variants of undefined as explicit 'no argument' at a position
-assert.doesNotThrow(function() { execFile(cmd, u, o, c); });
-assert.doesNotThrow(function() { execFile(cmd, a, u, c); });
-assert.doesNotThrow(function() { execFile(cmd, a, o, u); });
-assert.doesNotThrow(function() { execFile(cmd, n, o, c); });
-assert.doesNotThrow(function() { execFile(cmd, a, n, c); });
-assert.doesNotThrow(function() { execFile(cmd, a, o, n); });
-assert.doesNotThrow(function() { execFile(cmd, u, u, u); });
-assert.doesNotThrow(function() { execFile(cmd, u, u, c); });
-assert.doesNotThrow(function() { execFile(cmd, u, o, u); });
-assert.doesNotThrow(function() { execFile(cmd, a, u, u); });
-assert.doesNotThrow(function() { execFile(cmd, n, n, n); });
-assert.doesNotThrow(function() { execFile(cmd, n, n, c); });
-assert.doesNotThrow(function() { execFile(cmd, n, o, n); });
-assert.doesNotThrow(function() { execFile(cmd, a, n, n); });
-assert.doesNotThrow(function() { execFile(cmd, a, u); });
-assert.doesNotThrow(function() { execFile(cmd, a, n); });
-assert.doesNotThrow(function() { execFile(cmd, o, u); });
-assert.doesNotThrow(function() { execFile(cmd, o, n); });
-assert.doesNotThrow(function() { execFile(cmd, c, u); });
-assert.doesNotThrow(function() { execFile(cmd, c, n); });
+execFile(cmd, u, o, c);
+execFile(cmd, a, u, c);
+execFile(cmd, a, o, u);
+execFile(cmd, n, o, c);
+execFile(cmd, a, n, c);
+execFile(cmd, a, o, n);
+execFile(cmd, u, u, u);
+execFile(cmd, u, u, c);
+execFile(cmd, u, o, u);
+execFile(cmd, a, u, u);
+execFile(cmd, n, n, n);
+execFile(cmd, n, n, c);
+execFile(cmd, n, o, n);
+execFile(cmd, a, n, n);
+execFile(cmd, a, u);
+execFile(cmd, a, n);
+execFile(cmd, o, u);
+execFile(cmd, o, n);
+execFile(cmd, c, u);
+execFile(cmd, c, n);
// string is invalid in arg position (this may seem strange, but is
// consistent across node API, cf. `net.createServer('not options', 'not
@@ -173,7 +162,7 @@ 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);
-assert.doesNotThrow(function() { execFile(cmd, c, s); });
+execFile(cmd, c, s);
// verify that fork has same argument parsing behavior as spawn
@@ -183,16 +172,16 @@ assert.doesNotThrow(function() { execFile(cmd, c, s); });
// (f, a)
// (f, a, o)
// (f, o)
-assert.doesNotThrow(function() { fork(empty); });
-assert.doesNotThrow(function() { fork(empty, a); });
-assert.doesNotThrow(function() { fork(empty, a, o); });
-assert.doesNotThrow(function() { fork(empty, o); });
-assert.doesNotThrow(function() { fork(empty, u, u); });
-assert.doesNotThrow(function() { fork(empty, u, o); });
-assert.doesNotThrow(function() { fork(empty, a, u); });
-assert.doesNotThrow(function() { fork(empty, n, n); });
-assert.doesNotThrow(function() { fork(empty, n, o); });
-assert.doesNotThrow(function() { fork(empty, a, n); });
+fork(empty);
+fork(empty, a);
+fork(empty, a, o);
+fork(empty, o);
+fork(empty, u, u);
+fork(empty, u, o);
+fork(empty, a, u);
+fork(empty, n, n);
+fork(empty, n, o);
+fork(empty, a, n);
assert.throws(function() { fork(empty, s); }, invalidArgValueError);
assert.throws(function() { fork(empty, a, s); }, invalidArgValueError);
diff --git a/test/parallel/test-console-async-write-error.js b/test/parallel/test-console-async-write-error.js
index 63e8bfbc88..139c02d64b 100644
--- a/test/parallel/test-console-async-write-error.js
+++ b/test/parallel/test-console-async-write-error.js
@@ -2,7 +2,6 @@
const common = require('../common');
const { Console } = require('console');
const { Writable } = require('stream');
-const assert = require('assert');
for (const method of ['dir', 'log', 'warn']) {
const out = new Writable({
@@ -13,7 +12,5 @@ for (const method of ['dir', 'log', 'warn']) {
const c = new Console(out, out, true);
- assert.doesNotThrow(() => {
- c[method]('abc');
- });
+ c[method]('abc');
}
diff --git a/test/parallel/test-console-instance.js b/test/parallel/test-console-instance.js
index 7e931e0d3b..aa35afc648 100644
--- a/test/parallel/test-console-instance.js
+++ b/test/parallel/test-console-instance.js
@@ -87,9 +87,7 @@ out.write = common.mustCall((d) => {
[1, 2, 3].forEach(c.log);
// Console() detects if it is called without `new` keyword
-assert.doesNotThrow(() => {
- Console(out, err);
-});
+Console(out, err);
// Instance that does not ignore the stream errors.
const c2 = new Console(out, err, false);
diff --git a/test/parallel/test-console-is-a-namespace.js b/test/parallel/test-console-is-a-namespace.js
index 617e334a83..152f9dab7b 100644
--- a/test/parallel/test-console-is-a-namespace.js
+++ b/test/parallel/test-console-is-a-namespace.js
@@ -2,13 +2,10 @@
require('../common');
-const assert = require('assert');
const { test, assert_equals, assert_true, assert_false } =
require('../common/wpt');
-assert.doesNotThrow(() => {
- global.console = global.console;
-});
+global.console = global.console;
const self = global;
diff --git a/test/parallel/test-console-sync-write-error.js b/test/parallel/test-console-sync-write-error.js
index fb350d463b..4d6c52e0da 100644
--- a/test/parallel/test-console-sync-write-error.js
+++ b/test/parallel/test-console-sync-write-error.js
@@ -2,7 +2,6 @@
const common = require('../common');
const { Console } = require('console');
const { Writable } = require('stream');
-const assert = require('assert');
for (const method of ['dir', 'log', 'warn']) {
{
@@ -14,9 +13,7 @@ for (const method of ['dir', 'log', 'warn']) {
const c = new Console(out, out, true);
- assert.doesNotThrow(() => {
- c[method]('abc');
- });
+ c[method]('abc');
}
{
@@ -28,9 +25,7 @@ for (const method of ['dir', 'log', 'warn']) {
const c = new Console(out, out, true);
- assert.doesNotThrow(() => {
- c[method]('abc');
- });
+ c[method]('abc');
}
{
@@ -42,8 +37,6 @@ for (const method of ['dir', 'log', 'warn']) {
const c = new Console(out, out, true);
- assert.doesNotThrow(() => {
- c[method]('abc');
- });
+ c[method]('abc');
}
}
diff --git a/test/parallel/test-console.js b/test/parallel/test-console.js
index b789d05ee2..4bde18d888 100644
--- a/test/parallel/test-console.js
+++ b/test/parallel/test-console.js
@@ -29,18 +29,14 @@ assert.ok(process.stderr.writable);
assert.strictEqual(typeof process.stdout.fd, 'number');
assert.strictEqual(typeof process.stderr.fd, 'number');
-assert.doesNotThrow(function() {
- process.once('warning', common.mustCall((warning) => {
- assert(/no such label/.test(warning.message));
- }));
+process.once('warning', common.mustCall((warning) => {
+ assert(/no such label/.test(warning.message));
+}));
- console.timeEnd('no such label');
-});
+console.timeEnd('no such label');
-assert.doesNotThrow(function() {
- console.time('label');
- console.timeEnd('label');
-});
+console.time('label');
+console.timeEnd('label');
// Check that the `Error` is a `TypeError` but do not check the message as it
// will be different in different JavaScript engines.
@@ -140,15 +136,11 @@ console.timeEnd();
console.time(NaN);
console.timeEnd(NaN);
-assert.doesNotThrow(() => {
- console.assert(false, '%s should', 'console.assert', 'not throw');
- assert.strictEqual(errStrings[errStrings.length - 1],
- 'Assertion failed: console.assert should not throw\n');
-});
+console.assert(false, '%s should', 'console.assert', 'not throw');
+assert.strictEqual(errStrings[errStrings.length - 1],
+ 'Assertion failed: console.assert should not throw\n');
-assert.doesNotThrow(() => {
- console.assert(true, 'this should not throw');
-});
+console.assert(true, 'this should not throw');
assert.strictEqual(strings.length, process.stdout.writeTimes);
assert.strictEqual(errStrings.length, process.stderr.writeTimes);
diff --git a/test/parallel/test-crypto-binary-default.js b/test/parallel/test-crypto-binary-default.js
index ad11b59f09..a20a8d89e7 100644
--- a/test/parallel/test-crypto-binary-default.js
+++ b/test/parallel/test-crypto-binary-default.js
@@ -46,9 +46,7 @@ const rsaPubPem = fixtures.readSync('test_rsa_pubkey.pem', 'ascii');
const rsaKeyPem = fixtures.readSync('test_rsa_privkey.pem', 'ascii');
// PFX tests
-assert.doesNotThrow(function() {
- tls.createSecureContext({ pfx: certPfx, passphrase: 'sample' });
-});
+tls.createSecureContext({ pfx: certPfx, passphrase: 'sample' });
assert.throws(function() {
tls.createSecureContext({ pfx: certPfx });
diff --git a/test/parallel/test-crypto-cipher-decipher.js b/test/parallel/test-crypto-cipher-decipher.js
index e17ff23834..b34f43377c 100644
--- a/test/parallel/test-crypto-cipher-decipher.js
+++ b/test/parallel/test-crypto-cipher-decipher.js
@@ -201,18 +201,18 @@ testCipher2(Buffer.from('0123456789abcdef'));
let decipher = crypto.createDecipher('aes192', key);
let txt;
- assert.doesNotThrow(() => txt = decipher.update(ciph, 'base64', 'ucs2'));
- assert.doesNotThrow(() => txt += decipher.final('ucs2'));
+ txt = decipher.update(ciph, 'base64', 'ucs2');
+ txt += decipher.final('ucs2');
assert.strictEqual(txt, plaintext);
decipher = crypto.createDecipher('aes192', key);
- assert.doesNotThrow(() => txt = decipher.update(ciph, 'base64', 'ucs-2'));
- assert.doesNotThrow(() => txt += decipher.final('ucs-2'));
+ txt = decipher.update(ciph, 'base64', 'ucs-2');
+ txt += decipher.final('ucs-2');
assert.strictEqual(txt, plaintext);
decipher = crypto.createDecipher('aes192', key);
- assert.doesNotThrow(() => txt = decipher.update(ciph, 'base64', 'utf-16le'));
- assert.doesNotThrow(() => txt += decipher.final('utf-16le'));
+ txt = decipher.update(ciph, 'base64', 'utf-16le');
+ txt += decipher.final('utf-16le');
assert.strictEqual(txt, plaintext);
}
diff --git a/test/parallel/test-crypto-dh-odd-key.js b/test/parallel/test-crypto-dh-odd-key.js
index 449c482d35..d5410daca6 100644
--- a/test/parallel/test-crypto-dh-odd-key.js
+++ b/test/parallel/test-crypto-dh-odd-key.js
@@ -37,7 +37,7 @@ function test() {
// FIPS requires a length of at least 1024
if (!common.hasFipsCrypto) {
- assert.doesNotThrow(function() { test(); });
+ test();
} else {
assert.throws(function() { test(); }, /key size too small/);
}
diff --git a/test/parallel/test-crypto-dh.js b/test/parallel/test-crypto-dh.js
index bb3f0044f8..6b2b8faa36 100644
--- a/test/parallel/test-crypto-dh.js
+++ b/test/parallel/test-crypto-dh.js
@@ -371,9 +371,7 @@ if (availableCurves.has('prime256v1') && availableHashes.has('sha256')) {
'AwEHoUQDQgAEurOxfSxmqIRYzJVagdZfMMSjRNNhB8i3mXyIMq704m2m52FdfKZ2\n' +
'pQhByd5eyj3lgZ7m7jbchtdgyOF8Io/1ng==\n' +
'-----END EC PRIVATE KEY-----';
- assert.doesNotThrow(() => {
- crypto.createSign('SHA256').sign(ecPrivateKey);
- });
+ crypto.createSign('SHA256').sign(ecPrivateKey);
}
// invalid test: curve argument is undefined
diff --git a/test/parallel/test-crypto-padding.js b/test/parallel/test-crypto-padding.js
index 6ad504d12c..ae85f7d2c3 100644
--- a/test/parallel/test-crypto-padding.js
+++ b/test/parallel/test-crypto-padding.js
@@ -100,11 +100,9 @@ assert.throws(function() {
enc(ODD_LENGTH_PLAIN, false);
}, /data not multiple of block length/);
-assert.doesNotThrow(function() {
- assert.strictEqual(
- enc(EVEN_LENGTH_PLAIN, false), EVEN_LENGTH_ENCRYPTED_NOPAD
- );
-});
+assert.strictEqual(
+ enc(EVEN_LENGTH_PLAIN, false), EVEN_LENGTH_ENCRYPTED_NOPAD
+);
/*
@@ -114,20 +112,16 @@ assert.doesNotThrow(function() {
assert.strictEqual(dec(ODD_LENGTH_ENCRYPTED, true), ODD_LENGTH_PLAIN);
assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED, true), EVEN_LENGTH_PLAIN);
-assert.doesNotThrow(function() {
- // returns including original padding
- assert.strictEqual(dec(ODD_LENGTH_ENCRYPTED, false).length, 32);
- assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED, false).length, 48);
-});
+// 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):
assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED_NOPAD, true), EVEN_LENGTH_PLAIN);
}, /bad decrypt/);
-assert.doesNotThrow(function() {
- // no-pad encrypted string should return the same:
- assert.strictEqual(
- dec(EVEN_LENGTH_ENCRYPTED_NOPAD, false), EVEN_LENGTH_PLAIN
- );
-});
+// 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 3576b69301..646ecd5ea2 100644
--- a/test/parallel/test-crypto-pbkdf2.js
+++ b/test/parallel/test-crypto-pbkdf2.js
@@ -100,11 +100,9 @@ common.expectsError(
// Should not get FATAL ERROR with empty password and salt
// https://github.com/nodejs/node/issues/8571
-assert.doesNotThrow(() => {
- crypto.pbkdf2('', '', 1, 32, 'sha256', common.mustCall((e) => {
- assert.ifError(e);
- }));
-});
+crypto.pbkdf2('', '', 1, 32, 'sha256', common.mustCall((e) => {
+ assert.ifError(e);
+}));
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 e0aa1ef872..5a6ecdd66f 100644
--- a/test/parallel/test-crypto-rsa-dsa.js
+++ b/test/parallel/test-crypto-rsa-dsa.js
@@ -153,10 +153,8 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
// Test RSA key signing/verification with encrypted key
rsaSign = crypto.createSign('SHA1');
rsaSign.update(rsaPubPem);
-assert.doesNotThrow(() => {
- const signOptions = { key: rsaKeyPemEncrypted, passphrase: 'password' };
- rsaSignature = rsaSign.sign(signOptions, 'hex');
-});
+const signOptions = { key: rsaKeyPemEncrypted, passphrase: 'password' };
+rsaSignature = rsaSign.sign(signOptions, 'hex');
assert.strictEqual(rsaSignature, expectedSignature);
rsaVerify = crypto.createVerify('SHA1');
@@ -259,11 +257,8 @@ const input = 'I AM THE WALRUS';
const sign = crypto.createSign('SHA1');
sign.update(input);
- let signature;
- assert.doesNotThrow(() => {
- const signOptions = { key: dsaKeyPemEncrypted, passphrase: 'password' };
- signature = sign.sign(signOptions, 'hex');
- });
+ const signOptions = { key: dsaKeyPemEncrypted, passphrase: 'password' };
+ const signature = sign.sign(signOptions, 'hex');
const verify = crypto.createVerify('SHA1');
verify.update(input);
diff --git a/test/parallel/test-crypto.js b/test/parallel/test-crypto.js
index 1156fe688c..1fc3db7482 100644
--- a/test/parallel/test-crypto.js
+++ b/test/parallel/test-crypto.js
@@ -56,9 +56,7 @@ assert.throws(function() {
});
// PFX tests
-assert.doesNotThrow(function() {
- tls.createSecureContext({ pfx: certPfx, passphrase: 'sample' });
-});
+tls.createSecureContext({ pfx: certPfx, passphrase: 'sample' });
assert.throws(function() {
tls.createSecureContext({ pfx: certPfx });
diff --git a/test/parallel/test-dgram-createSocket-type.js b/test/parallel/test-dgram-createSocket-type.js
index 19f4dad920..9c5a20eaab 100644
--- a/test/parallel/test-dgram-createSocket-type.js
+++ b/test/parallel/test-dgram-createSocket-type.js
@@ -34,10 +34,8 @@ invalidTypes.forEach((invalidType) => {
// Error must not be thrown with valid types
validTypes.forEach((validType) => {
- assert.doesNotThrow(() => {
- const socket = dgram.createSocket(validType);
- socket.close();
- });
+ const socket = dgram.createSocket(validType);
+ socket.close();
});
// Ensure buffer sizes can be set
diff --git a/test/parallel/test-dns-lookup.js b/test/parallel/test-dns-lookup.js
index 516f6ac0c1..d006355742 100644
--- a/test/parallel/test-dns-lookup.js
+++ b/test/parallel/test-dns-lookup.js
@@ -53,55 +53,47 @@ common.expectsError(() => {
message: 'The value "20" is invalid for option "family"'
});
-assert.doesNotThrow(() => {
- dns.lookup(false, {
- hints: 0,
- family: 0,
- all: true
- }, common.mustCall((error, result, addressType) => {
- assert.ifError(error);
- assert.deepStrictEqual(result, []);
- assert.strictEqual(addressType, undefined);
- }));
-});
+dns.lookup(false, {
+ hints: 0,
+ family: 0,
+ all: true
+}, common.mustCall((error, result, addressType) => {
+ assert.ifError(error);
+ assert.deepStrictEqual(result, []);
+ assert.strictEqual(addressType, undefined);
+}));
-assert.doesNotThrow(() => {
- dns.lookup('127.0.0.1', {
- hints: 0,
- family: 4,
- all: true
- }, common.mustCall((error, result, addressType) => {
- assert.ifError(error);
- assert.deepStrictEqual(result, [{
- address: '127.0.0.1',
- family: 4
- }]);
- assert.strictEqual(addressType, undefined);
- }));
-});
+dns.lookup('127.0.0.1', {
+ hints: 0,
+ family: 4,
+ all: true
+}, common.mustCall((error, result, addressType) => {
+ assert.ifError(error);
+ assert.deepStrictEqual(result, [{
+ address: '127.0.0.1',
+ family: 4
+ }]);
+ assert.strictEqual(addressType, undefined);
+}));
-assert.doesNotThrow(() => {
- dns.lookup('127.0.0.1', {
- hints: 0,
- family: 4,
- all: false
- }, common.mustCall((error, result, addressType) => {
- assert.ifError(error);
- assert.deepStrictEqual(result, '127.0.0.1');
- assert.strictEqual(addressType, 4);
- }));
-});
+dns.lookup('127.0.0.1', {
+ hints: 0,
+ family: 4,
+ all: false
+}, common.mustCall((error, result, addressType) => {
+ assert.ifError(error);
+ assert.deepStrictEqual(result, '127.0.0.1');
+ assert.strictEqual(addressType, 4);
+}));
-assert.doesNotThrow(() => {
- let tickValue = 0;
+let tickValue = 0;
- dns.lookup('example.com', common.mustCall((error, result, addressType) => {
- assert(error);
- assert.strictEqual(tickValue, 1);
- assert.strictEqual(error.code, 'ENOENT');
- }));
+dns.lookup('example.com', common.mustCall((error, result, addressType) => {
+ assert(error);
+ assert.strictEqual(tickValue, 1);
+ assert.strictEqual(error.code, 'ENOENT');
+}));
- // Make sure that the error callback is called
- // on next tick.
- tickValue = 1;
-});
+// Make sure that the error callback is called
+// on next tick.
+tickValue = 1;
diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js
index dba14b397b..839d434f9e 100644
--- a/test/parallel/test-dns.js
+++ b/test/parallel/test-dns.js
@@ -29,7 +29,7 @@ const existing = dns.getServers();
assert(existing.length > 0);
// Verify that setServers() handles arrays with holes and other oddities
-assert.doesNotThrow(() => {
+{
const servers = [];
servers[0] = '127.0.0.1';
@@ -37,9 +37,9 @@ assert.doesNotThrow(() => {
dns.setServers(servers);
assert.deepStrictEqual(dns.getServers(), ['127.0.0.1', '0.0.0.0']);
-});
+}
-assert.doesNotThrow(() => {
+{
const servers = ['127.0.0.1', '192.168.1.1'];
servers[3] = '127.1.0.1';
@@ -60,13 +60,13 @@ assert.doesNotThrow(() => {
'192.168.1.1',
'0.0.0.0'
]);
-});
+}
const goog = [
'8.8.8.8',
'8.8.4.4',
];
-assert.doesNotThrow(() => dns.setServers(goog));
+dns.setServers(goog);
assert.deepStrictEqual(dns.getServers(), goog);
common.expectsError(() => dns.setServers(['foobar']), {
code: 'ERR_INVALID_IP_ADDRESS',
@@ -84,7 +84,7 @@ const goog6 = [
'2001:4860:4860::8888',
'2001:4860:4860::8844',
];
-assert.doesNotThrow(() => dns.setServers(goog6));
+dns.setServers(goog6);
assert.deepStrictEqual(dns.getServers(), goog6);
goog6.push('4.4.4.4');
@@ -106,7 +106,7 @@ const portsExpected = [
dns.setServers(ports);
assert.deepStrictEqual(dns.getServers(), portsExpected);
-assert.doesNotThrow(() => dns.setServers([]));
+dns.setServers([]);
assert.deepStrictEqual(dns.getServers(), []);
common.expectsError(() => {
@@ -146,16 +146,11 @@ common.expectsError(() => {
assert.strictEqual(family, 4);
};
- assert.doesNotThrow(() => dns.lookup('', common.mustCall(checkCallback)));
-
- assert.doesNotThrow(() => dns.lookup(null, common.mustCall(checkCallback)));
-
- assert.doesNotThrow(() => dns.lookup(undefined,
- common.mustCall(checkCallback)));
-
- assert.doesNotThrow(() => dns.lookup(0, common.mustCall(checkCallback)));
-
- assert.doesNotThrow(() => dns.lookup(NaN, common.mustCall(checkCallback)));
+ dns.lookup('', common.mustCall(checkCallback));
+ dns.lookup(null, common.mustCall(checkCallback));
+ dns.lookup(undefined, common.mustCall(checkCallback));
+ dns.lookup(0, common.mustCall(checkCallback));
+ dns.lookup(NaN, common.mustCall(checkCallback));
}
/*
@@ -186,24 +181,18 @@ common.expectsError(() => dns.lookup('nodejs.org', 4), {
type: TypeError
});
-assert.doesNotThrow(() => dns.lookup('', { family: 4, hints: 0 },
- common.mustCall()));
+dns.lookup('', { family: 4, hints: 0 }, common.mustCall());
-assert.doesNotThrow(() => {
- dns.lookup('', {
- family: 6,
- hints: dns.ADDRCONFIG
- }, common.mustCall());
-});
+dns.lookup('', {
+ family: 6,
+ hints: dns.ADDRCONFIG
+}, common.mustCall());
-assert.doesNotThrow(() => dns.lookup('', { hints: dns.V4MAPPED },
- common.mustCall()));
+dns.lookup('', { hints: dns.V4MAPPED }, common.mustCall());
-assert.doesNotThrow(() => {
- dns.lookup('', {
- hints: dns.ADDRCONFIG | dns.V4MAPPED
- }, common.mustCall());
-});
+dns.lookup('', {
+ hints: dns.ADDRCONFIG | dns.V4MAPPED
+}, common.mustCall());
common.expectsError(() => dns.lookupService('0.0.0.0'), {
code: 'ERR_MISSING_ARGS',
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 9e438368d6..c2fa523cc1 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
@@ -1,6 +1,5 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
process.setUncaughtExceptionCaptureCallback(common.mustNotCall());
@@ -15,4 +14,4 @@ common.expectsError(
process.setUncaughtExceptionCaptureCallback(null);
-assert.doesNotThrow(() => require('domain'));
+require('domain');
diff --git a/test/parallel/test-event-emitter-remove-all-listeners.js b/test/parallel/test-event-emitter-remove-all-listeners.js
index 6ab277ce4e..3dfe65a8b4 100644
--- a/test/parallel/test-event-emitter-remove-all-listeners.js
+++ b/test/parallel/test-event-emitter-remove-all-listeners.js
@@ -81,7 +81,7 @@ function expect(expected) {
// Check for regression where removeAllListeners() throws when
// there exists a 'removeListener' listener, but there exists
// no listeners for the provided event type.
- assert.doesNotThrow(ee.removeAllListeners.bind(ee, 'foo'));
+ ee.removeAllListeners.bind(ee, 'foo');
}
{
diff --git a/test/parallel/test-fs-access.js b/test/parallel/test-fs-access.js
index 94031c2cbc..551272e72d 100644
--- a/test/parallel/test-fs-access.js
+++ b/test/parallel/test-fs-access.js
@@ -118,15 +118,10 @@ common.expectsError(
type: TypeError
});
-assert.doesNotThrow(() => {
- fs.accessSync(__filename);
-});
+fs.accessSync(__filename);
-assert.doesNotThrow(() => {
- const mode = fs.F_OK | fs.R_OK | fs.W_OK;
-
- fs.accessSync(readWriteFile, mode);
-});
+const mode = fs.F_OK | fs.R_OK | fs.W_OK;
+fs.accessSync(readWriteFile, mode);
assert.throws(
() => { fs.accessSync(doesNotExist); },
diff --git a/test/parallel/test-fs-buffer.js b/test/parallel/test-fs-buffer.js
index bb10c164da..2d0bc2a557 100644
--- a/test/parallel/test-fs-buffer.js
+++ b/test/parallel/test-fs-buffer.js
@@ -9,22 +9,18 @@ const path = require('path');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-assert.doesNotThrow(() => {
- fs.access(Buffer.from(tmpdir.path), common.mustCall((err) => {
- assert.ifError(err);
- }));
-});
+fs.access(Buffer.from(tmpdir.path), common.mustCall((err) => {
+ assert.ifError(err);
+}));
-assert.doesNotThrow(() => {
- const buf = Buffer.from(path.join(tmpdir.path, 'a.txt'));
- fs.open(buf, 'w+', common.mustCall((err, fd) => {
+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);
- assert(fd);
- fs.close(fd, common.mustCall((err) => {
- assert.ifError(err);
- }));
}));
-});
+}));
common.expectsError(
() => {
diff --git a/test/parallel/test-fs-exists.js b/test/parallel/test-fs-exists.js
index c52679764b..0304ca2fb6 100644
--- a/test/parallel/test-fs-exists.js
+++ b/test/parallel/test-fs-exists.js
@@ -27,9 +27,9 @@ const { URL } = require('url');
const f = __filename;
// Only warnings are emitted when the callback is invalid
-assert.doesNotThrow(() => fs.exists(f));
-assert.doesNotThrow(() => fs.exists());
-assert.doesNotThrow(() => fs.exists(f, {}));
+fs.exists(f);
+fs.exists();
+fs.exists(f, {});
fs.exists(f, common.mustCall(function(y) {
assert.strictEqual(y, true);
diff --git a/test/parallel/test-fs-make-callback.js b/test/parallel/test-fs-make-callback.js
index ca948ede18..9d4a6121a3 100644
--- a/test/parallel/test-fs-make-callback.js
+++ b/test/parallel/test-fs-make-callback.js
@@ -1,6 +1,5 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const fs = require('fs');
const callbackThrowValues = [null, true, false, 0, 1, 'foo', /foo/, [], {}];
@@ -20,7 +19,7 @@ function testMakeCallback(cb) {
common.expectWarning('DeprecationWarning', warn);
// Passing undefined/nothing calls rethrow() internally, which emits a warning
-assert.doesNotThrow(testMakeCallback());
+testMakeCallback()();
function invalidCallbackThrowsTests() {
callbackThrowValues.forEach((value) => {
diff --git a/test/parallel/test-fs-makeStatsCallback.js b/test/parallel/test-fs-makeStatsCallback.js
index 0982fcc3c7..ec03b593fa 100644
--- a/test/parallel/test-fs-makeStatsCallback.js
+++ b/test/parallel/test-fs-makeStatsCallback.js
@@ -1,6 +1,5 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const fs = require('fs');
const callbackThrowValues = [null, true, false, 0, 1, 'foo', /foo/, [], {}];
const warn = 'Calling an asynchronous function without callback is deprecated.';
@@ -15,10 +14,10 @@ function testMakeStatsCallback(cb) {
common.expectWarning('DeprecationWarning', warn);
// Verify the case where a callback function is provided
-assert.doesNotThrow(testMakeStatsCallback(common.mustCall()));
+testMakeStatsCallback(common.mustCall())();
// Passing undefined/nothing calls rethrow() internally, which emits a warning
-assert.doesNotThrow(testMakeStatsCallback());
+testMakeStatsCallback()();
function invalidCallbackThrowsTests() {
callbackThrowValues.forEach((value) => {
diff --git a/test/parallel/test-fs-mkdtemp.js b/test/parallel/test-fs-mkdtemp.js
index b27ab86417..27e2f1c08c 100644
--- a/test/parallel/test-fs-mkdtemp.js
+++ b/test/parallel/test-fs-mkdtemp.js
@@ -32,5 +32,5 @@ fs.mkdtemp(path.join(tmpdir.path, 'bar.'), {}, common.mustCall(handler));
// Making sure that not passing a callback doesn't crash, as a default function
// is passed internally.
-assert.doesNotThrow(() => fs.mkdtemp(path.join(tmpdir.path, 'bar-')));
-assert.doesNotThrow(() => fs.mkdtemp(path.join(tmpdir.path, 'bar-'), {}));
+fs.mkdtemp(path.join(tmpdir.path, 'bar-'));
+fs.mkdtemp(path.join(tmpdir.path, 'bar-'), {});
diff --git a/test/parallel/test-fs-options-immutable.js b/test/parallel/test-fs-options-immutable.js
index ca5079b07d..3555c82f19 100644
--- a/test/parallel/test-fs-options-immutable.js
+++ b/test/parallel/test-fs-options-immutable.js
@@ -17,19 +17,11 @@ const options = Object.freeze({});
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-{
- assert.doesNotThrow(() =>
- fs.readFile(__filename, options, common.mustCall(errHandler))
- );
- assert.doesNotThrow(() => fs.readFileSync(__filename, options));
-}
+fs.readFile(__filename, options, common.mustCall(errHandler));
+fs.readFileSync(__filename, options);
-{
- assert.doesNotThrow(() =>
- fs.readdir(__dirname, options, common.mustCall(errHandler))
- );
- assert.doesNotThrow(() => fs.readdirSync(__dirname, options));
-}
+fs.readdir(__dirname, options, common.mustCall(errHandler));
+fs.readdirSync(__dirname, options);
if (common.canCreateSymLink()) {
const sourceFile = path.resolve(tmpdir.path, 'test-readlink');
@@ -38,63 +30,46 @@ if (common.canCreateSymLink()) {
fs.writeFileSync(sourceFile, '');
fs.symlinkSync(sourceFile, linkFile);
- assert.doesNotThrow(() =>
- fs.readlink(linkFile, options, common.mustCall(errHandler))
- );
- assert.doesNotThrow(() => fs.readlinkSync(linkFile, options));
+ fs.readlink(linkFile, options, common.mustCall(errHandler));
+ fs.readlinkSync(linkFile, options);
}
{
const fileName = path.resolve(tmpdir.path, 'writeFile');
- assert.doesNotThrow(() => fs.writeFileSync(fileName, 'ABCD', options));
- assert.doesNotThrow(() =>
- fs.writeFile(fileName, 'ABCD', options, common.mustCall(errHandler))
- );
+ fs.writeFileSync(fileName, 'ABCD', options);
+ fs.writeFile(fileName, 'ABCD', options, common.mustCall(errHandler));
}
{
const fileName = path.resolve(tmpdir.path, 'appendFile');
- assert.doesNotThrow(() => fs.appendFileSync(fileName, 'ABCD', options));
- assert.doesNotThrow(() =>
- fs.appendFile(fileName, 'ABCD', options, common.mustCall(errHandler))
- );
+ fs.appendFileSync(fileName, 'ABCD', options);
+ fs.appendFile(fileName, 'ABCD', options, common.mustCall(errHandler));
}
{
- let watch;
- assert.doesNotThrow(() => {
- watch = fs.watch(__filename, options, common.mustNotCall());
- });
+ const watch = fs.watch(__filename, options, common.mustNotCall());
watch.close();
}
{
- assert.doesNotThrow(
- () => fs.watchFile(__filename, options, common.mustNotCall())
- );
+ fs.watchFile(__filename, options, common.mustNotCall());
fs.unwatchFile(__filename);
}
{
- assert.doesNotThrow(() => fs.realpathSync(__filename, options));
- assert.doesNotThrow(() =>
- fs.realpath(__filename, options, common.mustCall(errHandler))
- );
+ fs.realpathSync(__filename, options);
+ fs.realpath(__filename, options, common.mustCall(errHandler));
}
{
const tempFileName = path.resolve(tmpdir.path, 'mkdtemp-');
- assert.doesNotThrow(() => fs.mkdtempSync(tempFileName, options));
- assert.doesNotThrow(() =>
- fs.mkdtemp(tempFileName, options, common.mustCall(errHandler))
- );
+ fs.mkdtempSync(tempFileName, options);
+ fs.mkdtemp(tempFileName, options, common.mustCall(errHandler));
}
{
const fileName = path.resolve(tmpdir.path, 'streams');
- assert.doesNotThrow(() => {
- fs.WriteStream(fileName, options).once('open', common.mustCall(() => {
- assert.doesNotThrow(() => fs.ReadStream(fileName, options));
- }));
- });
+ fs.WriteStream(fileName, options).once('open', common.mustCall(() => {
+ fs.ReadStream(fileName, options);
+ }));
}
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 26fd47372e..b01a0a588f 100644
--- a/test/parallel/test-fs-read-stream-throw-type-error.js
+++ b/test/parallel/test-fs-read-stream-throw-type-error.js
@@ -1,23 +1,14 @@
'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
-const assert = require('assert');
const fs = require('fs');
const example = fixtures.path('x.txt');
-assert.doesNotThrow(function() {
- fs.createReadStream(example, undefined);
-});
-assert.doesNotThrow(function() {
- fs.createReadStream(example, null);
-});
-assert.doesNotThrow(function() {
- fs.createReadStream(example, 'utf8');
-});
-assert.doesNotThrow(function() {
- fs.createReadStream(example, { encoding: 'utf8' });
-});
+fs.createReadStream(example, undefined);
+fs.createReadStream(example, null);
+fs.createReadStream(example, 'utf8');
+fs.createReadStream(example, { encoding: 'utf8' });
const createReadStreamErr = (path, opt) => {
common.expectsError(
diff --git a/test/parallel/test-fs-timestamp-parsing-error.js b/test/parallel/test-fs-timestamp-parsing-error.js
index a0dac1bf6d..4456a86830 100644
--- a/test/parallel/test-fs-timestamp-parsing-error.js
+++ b/test/parallel/test-fs-timestamp-parsing-error.js
@@ -1,7 +1,6 @@
'use strict';
const common = require('../common');
const fs = require('fs');
-const assert = require('assert');
[Infinity, -Infinity, NaN].forEach((input) => {
common.expectsError(
@@ -25,5 +24,5 @@ common.expectsError(
const okInputs = [1, -1, '1', '-1', Date.now()];
okInputs.forEach((input) => {
- assert.doesNotThrow(() => fs._toUnixTimestamp(input));
+ fs._toUnixTimestamp(input);
});
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 73312afa6b..553d399e23 100644
--- a/test/parallel/test-fs-write-stream-throw-type-error.js
+++ b/test/parallel/test-fs-write-stream-throw-type-error.js
@@ -1,6 +1,5 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const fs = require('fs');
const path = require('path');
@@ -10,21 +9,10 @@ const example = path.join(tmpdir.path, 'dummy');
tmpdir.refresh();
-assert.doesNotThrow(() => {
- fs.createWriteStream(example, undefined);
-});
-
-assert.doesNotThrow(() => {
- fs.createWriteStream(example, null);
-});
-
-assert.doesNotThrow(() => {
- fs.createWriteStream(example, 'utf8');
-});
-
-assert.doesNotThrow(() => {
- fs.createWriteStream(example, { encoding: 'utf8' });
-});
+fs.createWriteStream(example, undefined);
+fs.createWriteStream(example, null);
+fs.createWriteStream(example, 'utf8');
+fs.createWriteStream(example, { encoding: 'utf8' });
const createWriteStreamErr = (path, opt) => {
common.expectsError(
diff --git a/test/parallel/test-http-client-reject-unexpected-agent.js b/test/parallel/test-http-client-reject-unexpected-agent.js
index 407084c030..50e5d2b57a 100644
--- a/test/parallel/test-http-client-reject-unexpected-agent.js
+++ b/test/parallel/test-http-client-reject-unexpected-agent.js
@@ -59,7 +59,7 @@ server.listen(0, baseOptions.host, common.mustCall(function() {
});
acceptableAgentOptions.forEach((agent) => {
- assert.doesNotThrow(() => createRequest(agent));
+ createRequest(agent);
});
}));
diff --git a/test/parallel/test-http-header-read.js b/test/parallel/test-http-header-read.js
index dcdabb12d8..0cc7b5cae1 100644
--- a/test/parallel/test-http-header-read.js
+++ b/test/parallel/test-http-header-read.js
@@ -37,11 +37,7 @@ const s = http.createServer(function(req, res) {
res.end('hello world\n');
// This checks that after the headers have been sent, getHeader works
// and does not throw an exception (Issue 752)
- assert.doesNotThrow(
- function() {
- assert.strictEqual(plain, res.getHeader(contentType));
- }
- );
+ assert.strictEqual(plain, res.getHeader(contentType));
});
s.listen(0, runTest);
diff --git a/test/parallel/test-http-hostname-typechecking.js b/test/parallel/test-http-hostname-typechecking.js
index 12fe72005a..72440391fa 100644
--- a/test/parallel/test-http-hostname-typechecking.js
+++ b/test/parallel/test-http-hostname-typechecking.js
@@ -1,7 +1,6 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const http = require('http');
// All of these values should cause http.request() to throw synchronously
@@ -36,8 +35,6 @@ vals.forEach((v) => {
// Only testing for 'hostname' validation so ignore connection errors.
const dontCare = () => {};
['', undefined, null].forEach((v) => {
- assert.doesNotThrow(() => {
- http.request({ hostname: v }).on('error', dontCare).end();
- http.request({ host: v }).on('error', dontCare).end();
- });
+ http.request({ hostname: v }).on('error', dontCare).end();
+ http.request({ host: v }).on('error', dontCare).end();
});
diff --git a/test/parallel/test-http-invalidheaderfield.js b/test/parallel/test-http-invalidheaderfield.js
index 9e844e8a42..528fc82586 100644
--- a/test/parallel/test-http-invalidheaderfield.js
+++ b/test/parallel/test-http-invalidheaderfield.js
@@ -9,9 +9,7 @@ const ee = new EventEmitter();
let count = 3;
const server = http.createServer(function(req, res) {
- assert.doesNotThrow(function() {
- res.setHeader('testing_123', 123);
- });
+ res.setHeader('testing_123', 123);
assert.throws(function() {
res.setHeader('testing 123', 123);
}, TypeError);
@@ -37,17 +35,13 @@ server.listen(0, function() {
}
);
- assert.doesNotThrow(
- function() {
- const options = {
- port: server.address().port,
- headers: { 'testing_123': 123 }
- };
- http.get(options, function() {
- ee.emit('done');
- });
- }, TypeError
- );
+ const options = {
+ port: server.address().port,
+ headers: { 'testing_123': 123 }
+ };
+ http.get(options, function() {
+ ee.emit('done');
+ });
});
ee.on('done', function() {
diff --git a/test/parallel/test-http-response-add-header-after-sent.js b/test/parallel/test-http-response-add-header-after-sent.js
index 8329d3ea7e..a4d3f629e2 100644
--- a/test/parallel/test-http-response-add-header-after-sent.js
+++ b/test/parallel/test-http-response-add-header-after-sent.js
@@ -1,12 +1,9 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const http = require('http');
const server = http.createServer((req, res) => {
- assert.doesNotThrow(() => {
- res.setHeader('header1', 1);
- });
+ res.setHeader('header1', 1);
res.write('abc');
common.expectsError(
() => res.setHeader('header2', 2),
diff --git a/test/parallel/test-http-response-remove-header-after-sent.js b/test/parallel/test-http-response-remove-header-after-sent.js
index e6adffc144..52acd3d105 100644
--- a/test/parallel/test-http-response-remove-header-after-sent.js
+++ b/test/parallel/test-http-response-remove-header-after-sent.js
@@ -1,12 +1,9 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const http = require('http');
const server = http.createServer((req, res) => {
- assert.doesNotThrow(() => {
- res.removeHeader('header1', 1);
- });
+ res.removeHeader('header1', 1);
res.write('abc');
common.expectsError(
() => res.removeHeader('header2', 2),
diff --git a/test/parallel/test-http2-binding.js b/test/parallel/test-http2-binding.js
index 8935e569f5..1b8501dcbe 100644
--- a/test/parallel/test-http2-binding.js
+++ b/test/parallel/test-http2-binding.js
@@ -5,7 +5,7 @@ if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
-assert.doesNotThrow(() => process.binding('http2'));
+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 b0faaa5de2..177b13a16e 100644
--- a/test/parallel/test-http2-client-rststream-before-connect.js
+++ b/test/parallel/test-http2-client-rststream-before-connect.js
@@ -23,7 +23,7 @@ server.listen(0, common.mustCall(() => {
req._destroy = common.mustCall(req._destroy.bind(req));
// second call doesn't do anything
- assert.doesNotThrow(() => req.close(8));
+ req.close(8);
req.on('close', common.mustCall((code) => {
assert.strictEqual(req.destroyed, true);
diff --git a/test/parallel/test-http2-compat-serverrequest-pause.js b/test/parallel/test-http2-compat-serverrequest-pause.js
index 62a23997c7..9c81e8ff61 100644
--- a/test/parallel/test-http2-compat-serverrequest-pause.js
+++ b/test/parallel/test-http2-compat-serverrequest-pause.js
@@ -28,8 +28,8 @@ server.on('request', common.mustCall((req, res) => {
// shouldn't throw if underlying Http2Stream no longer exists
res.on('finish', common.mustCall(() => process.nextTick(() => {
- assert.doesNotThrow(() => req.pause());
- assert.doesNotThrow(() => req.resume());
+ req.pause();
+ req.resume();
})));
}));
diff --git a/test/parallel/test-http2-compat-serverrequest-settimeout.js b/test/parallel/test-http2-compat-serverrequest-settimeout.js
index f718916180..81184d7075 100644
--- a/test/parallel/test-http2-compat-serverrequest-settimeout.js
+++ b/test/parallel/test-http2-compat-serverrequest-settimeout.js
@@ -3,7 +3,6 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
-const assert = require('assert');
const http2 = require('http2');
const msecs = common.platformTimeout(1);
@@ -16,9 +15,7 @@ server.on('request', (req, res) => {
res.on('finish', common.mustCall(() => {
req.setTimeout(msecs, common.mustNotCall());
process.nextTick(() => {
- assert.doesNotThrow(
- () => req.setTimeout(msecs, common.mustNotCall())
- );
+ req.setTimeout(msecs, common.mustNotCall());
server.close();
});
}));
diff --git a/test/parallel/test-http2-compat-serverresponse-destroy.js b/test/parallel/test-http2-compat-serverresponse-destroy.js
index 5421473784..f890346dbf 100644
--- a/test/parallel/test-http2-compat-serverresponse-destroy.js
+++ b/test/parallel/test-http2-compat-serverresponse-destroy.js
@@ -3,7 +3,6 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
-const assert = require('assert');
const http2 = require('http2');
const Countdown = require('../common/countdown');
@@ -22,9 +21,9 @@ const server = http2.createServer(common.mustCall((req, res) => {
res.on('error', common.mustNotCall());
res.on('finish', common.mustCall(() => {
- assert.doesNotThrow(() => res.destroy(nextError));
+ res.destroy(nextError);
process.nextTick(() => {
- assert.doesNotThrow(() => res.destroy(nextError));
+ res.destroy(nextError);
});
}));
diff --git a/test/parallel/test-http2-compat-serverresponse-headers-after-destroy.js b/test/parallel/test-http2-compat-serverresponse-headers-after-destroy.js
index 99e3ccc948..206bd1c9d4 100644
--- a/test/parallel/test-http2-compat-serverresponse-headers-after-destroy.js
+++ b/test/parallel/test-http2-compat-serverresponse-headers-after-destroy.js
@@ -15,12 +15,12 @@ server.listen(0, common.mustCall(function() {
server.once('request', common.mustCall(function(request, response) {
response.on('finish', common.mustCall(() => {
assert.strictEqual(response.headersSent, false);
- assert.doesNotThrow(() => response.setHeader('test', 'value'));
- assert.doesNotThrow(() => response.removeHeader('test', 'value'));
+ response.setHeader('test', 'value');
+ response.removeHeader('test', 'value');
process.nextTick(() => {
- assert.doesNotThrow(() => response.setHeader('test', 'value'));
- assert.doesNotThrow(() => response.removeHeader('test', 'value'));
+ response.setHeader('test', 'value');
+ response.removeHeader('test', 'value');
server.close();
});
diff --git a/test/parallel/test-http2-compat-serverresponse-settimeout.js b/test/parallel/test-http2-compat-serverresponse-settimeout.js
index bb09633727..220a84a754 100644
--- a/test/parallel/test-http2-compat-serverresponse-settimeout.js
+++ b/test/parallel/test-http2-compat-serverresponse-settimeout.js
@@ -3,7 +3,6 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
-const assert = require('assert');
const http2 = require('http2');
const msecs = common.platformTimeout(1);
@@ -16,9 +15,7 @@ server.on('request', (req, res) => {
res.on('finish', common.mustCall(() => {
res.setTimeout(msecs, common.mustNotCall());
process.nextTick(() => {
- assert.doesNotThrow(
- () => res.setTimeout(msecs, common.mustNotCall())
- );
+ res.setTimeout(msecs, common.mustNotCall());
server.close();
});
}));
diff --git a/test/parallel/test-http2-compat-serverresponse-statuscode.js b/test/parallel/test-http2-compat-serverresponse-statuscode.js
index ecb6da5df6..4c51616ef6 100644
--- a/test/parallel/test-http2-compat-serverresponse-statuscode.js
+++ b/test/parallel/test-http2-compat-serverresponse-statuscode.js
@@ -27,12 +27,10 @@ server.listen(0, common.mustCall(function() {
assert.strictEqual(response.statusCode, expectedDefaultStatusCode);
- assert.doesNotThrow(function() {
- response.statusCode = realStatusCodes.ok;
- response.statusCode = realStatusCodes.multipleChoices;
- response.statusCode = realStatusCodes.badRequest;
- response.statusCode = realStatusCodes.internalServerError;
- });
+ response.statusCode = realStatusCodes.ok;
+ response.statusCode = realStatusCodes.multipleChoices;
+ response.statusCode = realStatusCodes.badRequest;
+ response.statusCode = realStatusCodes.internalServerError;
common.expectsError(function() {
response.statusCode = realStatusCodes.continue;
diff --git a/test/parallel/test-http2-compat-socket.js b/test/parallel/test-http2-compat-socket.js
index a54909d3c1..498677af6e 100644
--- a/test/parallel/test-http2-compat-socket.js
+++ b/test/parallel/test-http2-compat-socket.js
@@ -49,7 +49,7 @@ server.on('request', common.mustCall(function(request, response) {
request.on('end', common.mustCall(() => {
assert.strictEqual(request.socket.readable, false);
- assert.doesNotThrow(() => response.socket.destroy());
+ response.socket.destroy();
}));
response.on('finish', common.mustCall(() => {
assert.ok(request.socket);
diff --git a/test/parallel/test-http2-connect.js b/test/parallel/test-http2-connect.js
index 894c51fe3d..9b628db5ae 100644
--- a/test/parallel/test-http2-connect.js
+++ b/test/parallel/test-http2-connect.js
@@ -3,7 +3,6 @@
const { mustCall, hasCrypto, skip, expectsError } = require('../common');
if (!hasCrypto)
skip('missing crypto');
-const { doesNotThrow, throws } = require('assert');
const { createServer, connect } = require('http2');
{
const server = createServer();
@@ -13,10 +12,11 @@ const { createServer, connect } = require('http2');
const listener = () => mustCall();
const clients = new Set();
- doesNotThrow(() => clients.add(connect(authority)));
- doesNotThrow(() => clients.add(connect(authority, options)));
- doesNotThrow(() => clients.add(connect(authority, options, listener())));
- doesNotThrow(() => clients.add(connect(authority, listener())));
+ // Should not throw.
+ clients.add(connect(authority));
+ clients.add(connect(authority, options));
+ clients.add(connect(authority, options, listener()));
+ clients.add(connect(authority, listener()));
for (const client of clients) {
client.once('connect', mustCall((headers) => {
@@ -33,20 +33,18 @@ const { createServer, connect } = require('http2');
// check for https as protocol
{
const authority = 'https://localhost';
- doesNotThrow(() => {
- // A socket error may or may not be reported, keep this as a non-op
- // instead of a mustCall or mustNotCall
- connect(authority).on('error', () => {});
- });
+ // A socket error may or may not be reported, keep this as a non-op
+ // instead of a mustCall or mustNotCall
+ connect(authority).on('error', () => {});
}
// check for error for an invalid protocol (not http or https)
{
const authority = 'ssh://localhost';
- throws(() => {
+ expectsError(() => {
connect(authority);
- }, expectsError({
+ }, {
code: 'ERR_HTTP2_UNSUPPORTED_PROTOCOL',
type: Error
- }));
+ });
}
diff --git a/test/parallel/test-http2-getpackedsettings.js b/test/parallel/test-http2-getpackedsettings.js
index 9ae2512b2c..b02d6b4933 100644
--- a/test/parallel/test-http2-getpackedsettings.js
+++ b/test/parallel/test-http2-getpackedsettings.js
@@ -26,11 +26,11 @@ assert.deepStrictEqual(val, check);
['maxHeaderListSize', 0],
['maxHeaderListSize', 2 ** 32 - 1]
].forEach((i) => {
- assert.doesNotThrow(() => http2.getPackedSettings({ [i[0]]: i[1] }));
+ http2.getPackedSettings({ [i[0]]: i[1] });
});
-assert.doesNotThrow(() => http2.getPackedSettings({ enablePush: true }));
-assert.doesNotThrow(() => http2.getPackedSettings({ enablePush: false }));
+http2.getPackedSettings({ enablePush: true });
+http2.getPackedSettings({ enablePush: false });
[
['headerTableSize', -1],
@@ -151,9 +151,7 @@ assert.doesNotThrow(() => http2.getPackedSettings({ enablePush: false }));
0x00, 0x00, 0x00, 0x64, 0x00, 0x06, 0x00, 0x00, 0x00, 0x64,
0x00, 0x02, 0x00, 0x00, 0x00, 0x01]);
- assert.doesNotThrow(() => {
- http2.getUnpackedSettings(packed, { validate: true });
- });
+ http2.getUnpackedSettings(packed, { validate: true });
}
// check for maxFrameSize failing the max number
diff --git a/test/parallel/test-http2-server-startup.js b/test/parallel/test-http2-server-startup.js
index 0731b83a20..12b9cd72cb 100644
--- a/test/parallel/test-http2-server-startup.js
+++ b/test/parallel/test-http2-server-startup.js
@@ -10,7 +10,6 @@ const commonFixtures = require('../common/fixtures');
if (!common.hasCrypto)
common.skip('missing crypto');
-const assert = require('assert');
const http2 = require('http2');
const tls = require('tls');
const net = require('net');
@@ -21,25 +20,17 @@ const options = {
};
// There should not be any throws
-assert.doesNotThrow(() => {
+const serverTLS = http2.createSecureServer(options, () => {});
+serverTLS.listen(0, common.mustCall(() => serverTLS.close()));
- const serverTLS = http2.createSecureServer(options, () => {});
+// There should not be an error event reported either
+serverTLS.on('error', common.mustNotCall());
- serverTLS.listen(0, common.mustCall(() => serverTLS.close()));
+const server = http2.createServer(options, common.mustNotCall());
+server.listen(0, common.mustCall(() => server.close()));
- // There should not be an error event reported either
- serverTLS.on('error', common.mustNotCall());
-});
-
-// There should not be any throws
-assert.doesNotThrow(() => {
- const server = http2.createServer(options, common.mustNotCall());
-
- server.listen(0, common.mustCall(() => server.close()));
-
- // There should not be an error event reported either
- server.on('error', common.mustNotCall());
-});
+// There should not be an error event reported either
+server.on('error', common.mustNotCall());
// Test the plaintext server socket timeout
{
diff --git a/test/parallel/test-http2-session-settings.js b/test/parallel/test-http2-session-settings.js
index 75fcc19421..6061808082 100644
--- a/test/parallel/test-http2-session-settings.js
+++ b/test/parallel/test-http2-session-settings.js
@@ -76,9 +76,7 @@ server.listen(
// State will only be valid after connect event is emitted
req.on('ready', common.mustCall(() => {
- assert.doesNotThrow(() => {
- client.settings({ maxHeaderListSize: 1 }, common.mustCall());
- });
+ client.settings({ maxHeaderListSize: 1 }, common.mustCall());
// Verify valid error ranges
[
diff --git a/test/parallel/test-http2-socket-proxy.js b/test/parallel/test-http2-socket-proxy.js
index 1ca34eb451..751cacf8df 100644
--- a/test/parallel/test-http2-socket-proxy.js
+++ b/test/parallel/test-http2-socket-proxy.js
@@ -51,8 +51,8 @@ server.on('stream', common.mustCall(function(stream, headers) {
common.expectsError(() => (socket.resume = undefined), errMsg);
common.expectsError(() => (socket.write = undefined), errMsg);
- assert.doesNotThrow(() => (socket.on = socket.on));
- assert.doesNotThrow(() => (socket.once = socket.once));
+ socket.on = socket.on;
+ socket.once = socket.once;
stream.respond();
diff --git a/test/parallel/test-http2-util-asserts.js b/test/parallel/test-http2-util-asserts.js
index 1e7a0113f4..bfed09de4f 100644
--- a/test/parallel/test-http2-util-asserts.js
+++ b/test/parallel/test-http2-util-asserts.js
@@ -2,7 +2,6 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const {
assertIsObject,
assertWithinRange,
@@ -15,7 +14,7 @@ const {
new Date(),
new (class Foo {})()
].forEach((i) => {
- assert.doesNotThrow(() => assertIsObject(i, 'foo', 'Object'));
+ assertIsObject(i, 'foo', 'Object');
});
[
@@ -34,7 +33,7 @@ const {
});
});
-assert.doesNotThrow(() => assertWithinRange('foo', 1, 0, 2));
+assertWithinRange('foo', 1, 0, 2);
common.expectsError(() => assertWithinRange('foo', 1, 2, 3),
{
diff --git a/test/parallel/test-http2-withflag.js b/test/parallel/test-http2-withflag.js
index 0a01efc517..3cc5c69c68 100644
--- a/test/parallel/test-http2-withflag.js
+++ b/test/parallel/test-http2-withflag.js
@@ -3,6 +3,5 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
-const assert = require('assert');
-assert.doesNotThrow(() => require('http2'));
+require('http2');
diff --git a/test/parallel/test-https-agent-constructor.js b/test/parallel/test-https-agent-constructor.js
index 29bb9eaa98..571160bbb8 100644
--- a/test/parallel/test-https-agent-constructor.js
+++ b/test/parallel/test-https-agent-constructor.js
@@ -6,5 +6,5 @@ if (!common.hasCrypto)
const assert = require('assert');
const https = require('https');
-assert.doesNotThrow(() => { https.Agent(); });
+https.Agent();
assert.ok(https.Agent() instanceof https.Agent);
diff --git a/test/parallel/test-https-options-boolean-check.js b/test/parallel/test-https-options-boolean-check.js
index 04baf403df..fa223aa887 100644
--- a/test/parallel/test-https-options-boolean-check.js
+++ b/test/parallel/test-https-options-boolean-check.js
@@ -6,7 +6,6 @@ const fixtures = require('../common/fixtures');
if (!common.hasCrypto)
common.skip('missing crypto');
-const assert = require('assert');
const https = require('https');
function toArrayBuffer(buf) {
@@ -65,11 +64,9 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
[[{ pem: keyBuff }], false],
[[{ pem: keyBuff }, { pem: keyBuff }], false]
].forEach((params) => {
- assert.doesNotThrow(() => {
- https.createServer({
- key: params[0],
- cert: params[1]
- });
+ https.createServer({
+ key: params[0],
+ cert: params[1]
});
});
@@ -124,12 +121,10 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
[keyBuff, certBuff, caArrDataView],
[keyBuff, certBuff, false],
].forEach((params) => {
- assert.doesNotThrow(() => {
- https.createServer({
- key: params[0],
- cert: params[1],
- ca: params[2]
- });
+ https.createServer({
+ key: params[0],
+ cert: params[1],
+ ca: params[2]
});
});
diff --git a/test/parallel/test-icu-punycode.js b/test/parallel/test-icu-punycode.js
index 7abcae4617..3ca30a6d16 100644
--- a/test/parallel/test-icu-punycode.js
+++ b/test/parallel/test-icu-punycode.js
@@ -34,13 +34,12 @@ const wptToASCIITests = require('../fixtures/url-toascii.js');
if (output === null) {
assert.throws(() => icu.toASCII(input),
errMessage, `ToASCII ${caseComment}`);
- assert.doesNotThrow(() => icu.toASCII(input, true),
- `ToASCII ${caseComment} in lenient mode`);
+ icu.toASCII(input, true);
} else {
assert.strictEqual(icu.toASCII(input), output, `ToASCII ${caseComment}`);
assert.strictEqual(icu.toASCII(input, true), output,
`ToASCII ${caseComment} in lenient mode`);
}
- assert.doesNotThrow(() => icu.toUnicode(input), `ToUnicode ${caseComment}`);
+ icu.toUnicode(input);
}
}
diff --git a/test/parallel/test-internal-errors.js b/test/parallel/test-internal-errors.js
index 67c1cd1d2f..cdac396082 100644
--- a/test/parallel/test-internal-errors.js
+++ b/test/parallel/test-internal-errors.js
@@ -138,36 +138,24 @@ common.expectsError(
message: invalidKey('true')
});
-
// Tests for common.expectsError
-assert.doesNotThrow(() => {
- common.expectsError(() => {
- throw new errors.TypeError('TEST_ERROR_1', 'a');
- }, { code: 'TEST_ERROR_1' });
-});
-
-assert.doesNotThrow(() => {
- common.expectsError(() => {
- throw new errors.TypeError('TEST_ERROR_1', 'a');
- }, { code: 'TEST_ERROR_1',
- type: TypeError,
- message: /^Error for testing/ });
-});
-
-assert.doesNotThrow(() => {
- common.expectsError(() => {
- throw new errors.TypeError('TEST_ERROR_1', 'a');
- }, { code: 'TEST_ERROR_1', type: TypeError });
-});
-
-assert.doesNotThrow(() => {
- common.expectsError(() => {
- throw new errors.TypeError('TEST_ERROR_1', 'a');
- }, {
- code: 'TEST_ERROR_1',
- type: TypeError,
- message: 'Error for testing purposes: a'
- });
+common.expectsError(() => {
+ throw new errors.TypeError('TEST_ERROR_1', 'a');
+}, { code: 'TEST_ERROR_1' });
+common.expectsError(() => {
+ throw new errors.TypeError('TEST_ERROR_1', 'a');
+}, { code: 'TEST_ERROR_1',
+ type: TypeError,
+ message: /^Error for testing/ });
+common.expectsError(() => {
+ throw new errors.TypeError('TEST_ERROR_1', 'a');
+}, { code: 'TEST_ERROR_1', type: TypeError });
+common.expectsError(() => {
+ throw new errors.TypeError('TEST_ERROR_1', 'a');
+}, {
+ code: 'TEST_ERROR_1',
+ type: TypeError,
+ message: 'Error for testing purposes: a'
});
common.expectsError(() => {
diff --git a/test/parallel/test-internal-fs.js b/test/parallel/test-internal-fs.js
index fe6c50194d..3f270f93d5 100644
--- a/test/parallel/test-internal-fs.js
+++ b/test/parallel/test-internal-fs.js
@@ -2,11 +2,10 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const fs = require('internal/fs');
-assert.doesNotThrow(() => fs.assertEncoding());
-assert.doesNotThrow(() => fs.assertEncoding('utf8'));
+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-assertCrypto.js b/test/parallel/test-internal-util-assertCrypto.js
index d01eab3a23..035519c9c9 100644
--- a/test/parallel/test-internal-util-assertCrypto.js
+++ b/test/parallel/test-internal-util-assertCrypto.js
@@ -11,5 +11,5 @@ if (!process.versions.openssl) {
});
assert.throws(() => util.assertCrypto(), expectedError);
} else {
- assert.doesNotThrow(() => util.assertCrypto());
+ util.assertCrypto();
}
diff --git a/test/parallel/test-internal-util-decorate-error-stack.js b/test/parallel/test-internal-util-decorate-error-stack.js
index b5670135a0..25141b5ea7 100644
--- a/test/parallel/test-internal-util-decorate-error-stack.js
+++ b/test/parallel/test-internal-util-decorate-error-stack.js
@@ -12,12 +12,10 @@ const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol'];
const decorateErrorStack = internalUtil.decorateErrorStack;
-assert.doesNotThrow(function() {
- decorateErrorStack();
- decorateErrorStack(null);
- decorateErrorStack(1);
- decorateErrorStack(true);
-});
+decorateErrorStack();
+decorateErrorStack(null);
+decorateErrorStack(1);
+decorateErrorStack(true);
// Verify that a stack property is not added to non-Errors
const obj = {};
diff --git a/test/parallel/test-module-symlinked-peer-modules.js b/test/parallel/test-module-symlinked-peer-modules.js
index f93dea720f..d6494da8a9 100644
--- a/test/parallel/test-module-symlinked-peer-modules.js
+++ b/test/parallel/test-module-symlinked-peer-modules.js
@@ -11,7 +11,6 @@
const common = require('../common');
const fs = require('fs');
const path = require('path');
-const assert = require('assert');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
@@ -60,6 +59,4 @@ fs.writeFileSync(path.join(moduleB, 'package.json'),
fs.writeFileSync(path.join(moduleB, 'index.js'),
'module.exports = 1;', 'utf8');
-assert.doesNotThrow(() => {
- require(path.join(app, 'index'));
-});
+require(path.join(app, 'index'));
diff --git a/test/parallel/test-net-after-close.js b/test/parallel/test-net-after-close.js
index 1594d36f90..23e265c09a 100644
--- a/test/parallel/test-net-after-close.js
+++ b/test/parallel/test-net-after-close.js
@@ -34,16 +34,14 @@ server.listen(0, common.mustCall(function() {
c.on('close', common.mustCall(function() {
console.error('connection closed');
assert.strictEqual(c._handle, null);
- assert.doesNotThrow(function() {
- c.setNoDelay();
- c.setKeepAlive();
- c.bufferSize;
- c.pause();
- c.resume();
- c.address();
- c.remoteAddress;
- c.remotePort;
- });
+ c.setNoDelay();
+ c.setKeepAlive();
+ c.bufferSize;
+ c.pause();
+ c.resume();
+ c.address();
+ c.remoteAddress;
+ c.remotePort;
server.close();
}));
}));
diff --git a/test/parallel/test-net-connect-options-port.js b/test/parallel/test-net-connect-options-port.js
index 8152424c52..ea3fadf721 100644
--- a/test/parallel/test-net-connect-options-port.js
+++ b/test/parallel/test-net-connect-options-port.js
@@ -171,27 +171,26 @@ function canConnect(port) {
// connect(port, cb) and connect(port)
const portArgBlocks = doConnect([port], noop);
for (const block of portArgBlocks) {
- assert.doesNotThrow(block, `${block.name}(${port})`);
+ block();
}
// connect(port, host, cb) and connect(port, host)
const portHostArgBlocks = doConnect([port, 'localhost'], noop);
for (const block of portHostArgBlocks) {
- assert.doesNotThrow(block, `${block.name}(${port})`);
+ block();
}
// connect({port}, cb) and connect({port})
const portOptBlocks = doConnect([{ port }], noop);
for (const block of portOptBlocks) {
- assert.doesNotThrow(block, `${block.name}({port: ${port}})`);
+ block();
}
// connect({port, host}, cb) and connect({port, host})
const portHostOptBlocks = doConnect([{ port: port, host: 'localhost' }],
noop);
for (const block of portHostOptBlocks) {
- assert.doesNotThrow(block,
- `${block.name}({port: ${port}, host: 'localhost'})`);
+ block();
}
}
@@ -205,25 +204,19 @@ function asyncFailToConnect(port) {
// connect(port, cb) and connect(port)
const portArgBlocks = doConnect([port], dont);
for (const block of portArgBlocks) {
- assert.doesNotThrow(function() {
- block().on('error', onError());
- }, `${block.name}(${port})`);
+ block().on('error', onError());
}
// connect({port}, cb) and connect({port})
const portOptBlocks = doConnect([{ port }], dont);
for (const block of portOptBlocks) {
- assert.doesNotThrow(function() {
- block().on('error', onError());
- }, `${block.name}({port: ${port}})`);
+ block().on('error', onError());
}
// connect({port, host}, cb) and connect({port, host})
const portHostOptBlocks = doConnect([{ port: port, host: 'localhost' }],
dont);
for (const block of portHostOptBlocks) {
- assert.doesNotThrow(function() {
- block().on('error', onError());
- }, `${block.name}({port: ${port}, host: 'localhost'})`);
+ block().on('error', onError());
}
}
diff --git a/test/parallel/test-net-during-close.js b/test/parallel/test-net-during-close.js
index a85863955e..11c3dab00f 100644
--- a/test/parallel/test-net-during-close.js
+++ b/test/parallel/test-net-during-close.js
@@ -21,7 +21,6 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const net = require('net');
const server = net.createServer(function(socket) {
@@ -33,11 +32,9 @@ server.listen(0, common.mustCall(function() {
server.close();
// server connection event has not yet fired
// client is still attempting to connect
- assert.doesNotThrow(function() {
- client.remoteAddress;
- client.remoteFamily;
- client.remotePort;
- });
+ client.remoteAddress;
+ client.remoteFamily;
+ client.remotePort;
// exit now, do not wait for the client error event
process.exit(0);
}));
diff --git a/test/parallel/test-net-options-lookup.js b/test/parallel/test-net-options-lookup.js
index 0551a24114..0b4e18f12f 100644
--- a/test/parallel/test-net-options-lookup.js
+++ b/test/parallel/test-net-options-lookup.js
@@ -1,6 +1,5 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const net = require('net');
['foobar', 1, {}, []].forEach((input) => connectThrows(input));
@@ -30,7 +29,5 @@ function connectDoesNotThrow(input) {
lookup: input
};
- assert.doesNotThrow(() => {
- net.connect(opts);
- });
+ net.connect(opts);
}
diff --git a/test/parallel/test-net-server-call-listen-multiple-times.js b/test/parallel/test-net-server-call-listen-multiple-times.js
index 05099dadc8..4b1a8d0733 100644
--- a/test/parallel/test-net-server-call-listen-multiple-times.js
+++ b/test/parallel/test-net-server-call-listen-multiple-times.js
@@ -1,7 +1,6 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const net = require('net');
// First test. Check that after error event you can listen right away.
@@ -16,12 +15,10 @@ const net = require('net');
}));
server.on('error', common.mustCall((e) => {
- assert.doesNotThrow(
- () => server.listen(common.mustCall(() => {
- dummyServer.close();
- server.close();
- }))
- );
+ server.listen(common.mustCall(() => {
+ dummyServer.close();
+ server.close();
+ }));
}));
}
@@ -44,8 +41,6 @@ const net = require('net');
server.listen(common.mustCall(() => {
server.close();
- assert.doesNotThrow(
- () => server.listen(common.mustCall(() => server.close()))
- );
+ server.listen(common.mustCall(() => server.close()));
}));
}
diff --git a/test/parallel/test-net-socket-timeout.js b/test/parallel/test-net-socket-timeout.js
index 178e2d994d..2826b1dd76 100644
--- a/test/parallel/test-net-socket-timeout.js
+++ b/test/parallel/test-net-socket-timeout.js
@@ -46,9 +46,7 @@ for (let i = 0; i < badRangeDelays.length; i++) {
}
for (let i = 0; i < validDelays.length; i++) {
- assert.doesNotThrow(function() {
- s.setTimeout(validDelays[i], () => {});
- });
+ s.setTimeout(validDelays[i], () => {});
}
const server = net.Server();
diff --git a/test/parallel/test-performance.js b/test/parallel/test-performance.js
index ba15479050..9b6f2fe957 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) => {
- assert.doesNotThrow(() => performance.measure('test', i, 'A'));
+ performance.measure('test', i, 'A');
});
[undefined, null, 'foo', 1].forEach((i) => {
diff --git a/test/parallel/test-performanceobserver.js b/test/parallel/test-performanceobserver.js
index 779e9740d7..196675d1f5 100644
--- a/test/parallel/test-performanceobserver.js
+++ b/test/parallel/test-performanceobserver.js
@@ -77,7 +77,7 @@ assert.strictEqual(counts[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION], 0);
countdown.dec();
}
assert.strictEqual(counts[NODE_PERFORMANCE_ENTRY_TYPE_MARK], 1);
- assert.doesNotThrow(() => observer.observe({ entryTypes: ['mark'] }));
+ observer.observe({ entryTypes: ['mark'] });
assert.strictEqual(counts[NODE_PERFORMANCE_ENTRY_TYPE_MARK], 2);
performance.mark('test1');
performance.mark('test2');
@@ -125,13 +125,9 @@ assert.strictEqual(counts[NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION], 0);
}
}
- assert.doesNotThrow(() => {
- observer.observe({ entryTypes: ['mark', 'measure'], buffered: true });
- });
+ observer.observe({ entryTypes: ['mark', 'measure'], buffered: true });
// Do this twice to make sure it doesn't throw
- assert.doesNotThrow(() => {
- observer.observe({ entryTypes: ['mark', 'measure'], buffered: true });
- });
+ observer.observe({ entryTypes: ['mark', 'measure'], buffered: true });
// Even tho we called twice, count should be 1
assert.strictEqual(counts[NODE_PERFORMANCE_ENTRY_TYPE_MARK], 2);
performance.mark('test1');
diff --git a/test/parallel/test-process-binding.js b/test/parallel/test-process-binding.js
index 475891aa5d..3715826bb2 100644
--- a/test/parallel/test-process-binding.js
+++ b/test/parallel/test-process-binding.js
@@ -9,10 +9,4 @@ assert.throws(
/No such module: test/
);
-assert.doesNotThrow(function() {
- process.binding('buffer');
-}, function(err) {
- if (err instanceof Error) {
- return true;
- }
-}, 'unexpected error');
+process.binding('buffer');
diff --git a/test/parallel/test-process-emitwarning.js b/test/parallel/test-process-emitwarning.js
index 06772c7be6..e07fcd253c 100644
--- a/test/parallel/test-process-emitwarning.js
+++ b/test/parallel/test-process-emitwarning.js
@@ -44,7 +44,7 @@ class CustomWarning extends Error {
[testMsg, { type: testType, code: testCode, detail: null }],
[testMsg, { type: testType, code: testCode, detail: 1 }]
].forEach((i) => {
- assert.doesNotThrow(() => process.emitWarning.apply(null, i));
+ process.emitWarning.apply(null, i);
});
const warningNoToString = new CustomWarning();
diff --git a/test/parallel/test-process-env-symbols.js b/test/parallel/test-process-env-symbols.js
index 51e8eafbea..855c791c0f 100644
--- a/test/parallel/test-process-env-symbols.js
+++ b/test/parallel/test-process-env-symbols.js
@@ -28,4 +28,4 @@ assert.strictEqual(symbol in process.env, false);
assert.strictEqual(delete process.env[symbol], true);
// Checks that well-known symbols like `Symbol.toStringTag` won’t throw.
-assert.doesNotThrow(() => Object.prototype.toString.call(process.env));
+Object.prototype.toString.call(process.env);
diff --git a/test/parallel/test-process-geteuid-getegid.js b/test/parallel/test-process-geteuid-getegid.js
index 8dab52389b..96e8765eb9 100644
--- a/test/parallel/test-process-geteuid-getegid.js
+++ b/test/parallel/test-process-geteuid-getegid.js
@@ -21,10 +21,8 @@ assert.throws(() => {
// If we're not running as super user...
if (process.getuid() !== 0) {
- assert.doesNotThrow(() => {
- process.getegid();
- process.geteuid();
- });
+ process.getegid();
+ process.geteuid();
assert.throws(() => {
process.setegid('nobody');
diff --git a/test/parallel/test-process-setuid-setgid.js b/test/parallel/test-process-setuid-setgid.js
index e0db8ee002..0060e3b1ca 100644
--- a/test/parallel/test-process-setuid-setgid.js
+++ b/test/parallel/test-process-setuid-setgid.js
@@ -39,10 +39,8 @@ assert.throws(() => {
// If we're not running as super user...
if (process.getuid() !== 0) {
- assert.doesNotThrow(() => {
- process.getgid();
- process.getuid();
- });
+ process.getgid();
+ process.getuid();
assert.throws(
() => { process.setgid('nobody'); },
diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js
index 76049584db..25d3774528 100644
--- a/test/parallel/test-querystring.js
+++ b/test/parallel/test-querystring.js
@@ -300,9 +300,7 @@ assert.strictEqual('foo=', qs.stringify({ foo: Infinity }));
assert.strictEqual(f, 'a=b&q=x%3Dy%26y%3Dz');
}
-assert.doesNotThrow(() => {
- qs.parse(undefined);
-});
+qs.parse(undefined);
// nested in colon
{
diff --git a/test/parallel/test-readline-csi.js b/test/parallel/test-readline-csi.js
index a3316a8800..54ca6bde97 100644
--- a/test/parallel/test-readline-csi.js
+++ b/test/parallel/test-readline-csi.js
@@ -61,15 +61,15 @@ assert.deepStrictEqual(writable.data, CSI.kClearLine);
assert.deepStrictEqual(writable.data, set[2]);
});
-assert.doesNotThrow(() => readline.cursorTo(null));
-assert.doesNotThrow(() => readline.cursorTo());
+readline.cursorTo(null);
+readline.cursorTo();
writable.data = '';
-assert.doesNotThrow(() => readline.cursorTo(writable, 'a'));
+readline.cursorTo(writable, 'a');
assert.strictEqual(writable.data, '');
writable.data = '';
-assert.doesNotThrow(() => readline.cursorTo(writable, 'a', 'b'));
+readline.cursorTo(writable, 'a', 'b');
assert.strictEqual(writable.data, '');
writable.data = '';
@@ -83,9 +83,9 @@ common.expectsError(
assert.strictEqual(writable.data, '');
writable.data = '';
-assert.doesNotThrow(() => readline.cursorTo(writable, 1, 'a'));
+readline.cursorTo(writable, 1, 'a');
assert.strictEqual(writable.data, '\x1b[2G');
writable.data = '';
-assert.doesNotThrow(() => readline.cursorTo(writable, 1, 2));
+readline.cursorTo(writable, 1, 2);
assert.strictEqual(writable.data, '\x1b[3;2H');
diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js
index fe33e244ce..30afba843a 100644
--- a/test/parallel/test-readline-interface.js
+++ b/test/parallel/test-readline-interface.js
@@ -823,23 +823,12 @@ function isWarned(emitter) {
fi.emit('data', 'asdf\n');
assert.ok(called);
- assert.doesNotThrow(function() {
- rli.setPrompt('ddd> ');
- });
-
- assert.doesNotThrow(function() {
- rli.prompt();
- });
-
- assert.doesNotThrow(function() {
- rli.write('really shouldnt be seeing this');
- });
-
- assert.doesNotThrow(function() {
- rli.question('What do you think of node.js? ', function(answer) {
- console.log('Thank you for your valuable feedback:', answer);
- rli.close();
- });
+ rli.setPrompt('ddd> ');
+ rli.prompt();
+ rli.write('really shouldnt be seeing this');
+ rli.question('What do you think of node.js? ', function(answer) {
+ console.log('Thank you for your valuable feedback:', answer);
+ rli.close();
});
}
diff --git a/test/parallel/test-regress-GH-6235.js b/test/parallel/test-regress-GH-6235.js
index e8fcda43cc..484138ba2d 100644
--- a/test/parallel/test-regress-GH-6235.js
+++ b/test/parallel/test-regress-GH-6235.js
@@ -21,8 +21,5 @@
'use strict';
require('../common');
-const assert = require('assert');
-assert.doesNotThrow(function() {
- require('vm').runInNewContext('"use strict"; var v = 1; v = 2');
-});
+require('vm').runInNewContext('"use strict"; var v = 1; v = 2');
diff --git a/test/parallel/test-repl-null.js b/test/parallel/test-repl-null.js
index 66d09b28f2..18009558ed 100644
--- a/test/parallel/test-repl-null.js
+++ b/test/parallel/test-repl-null.js
@@ -1,7 +1,6 @@
'use strict';
require('../common');
const repl = require('repl');
-const assert = require('assert');
const replserver = new repl.REPLServer();
@@ -10,8 +9,5 @@ replserver._inTemplateLiteral = true;
// `null` gets treated like an empty string. (Should it? You have to do some
// strange business to get it into the REPL. Maybe it should really throw?)
-assert.doesNotThrow(() => {
- replserver.emit('line', null);
-});
-
+replserver.emit('line', null);
replserver.emit('line', '.exit');
diff --git a/test/parallel/test-repl-throw-null-or-undefined.js b/test/parallel/test-repl-throw-null-or-undefined.js
index fd2fd202b5..3b4657ce98 100644
--- a/test/parallel/test-repl-throw-null-or-undefined.js
+++ b/test/parallel/test-repl-throw-null-or-undefined.js
@@ -3,16 +3,11 @@ require('../common');
// This test ensures that the repl does not
// crash or emit error when throwing `null|undefined`
-// ie `throw null` or `throw undefined`
+// ie `throw null` or `throw undefined`.
-const assert = require('assert');
-const repl = require('repl');
-
-const r = repl.start();
-
-assert.doesNotThrow(() => {
- r.write('throw null\n');
- r.write('throw undefined\n');
-}, TypeError, 'repl crashes/throw error on `throw null|undefined`');
+const r = require('repl').start();
+// Should not throw.
+r.write('throw null\n');
+r.write('throw undefined\n');
r.write('.exit\n');
diff --git a/test/parallel/test-stdio-closed.js b/test/parallel/test-stdio-closed.js
index 7a6625f494..c21bbc2eac 100644
--- a/test/parallel/test-stdio-closed.js
+++ b/test/parallel/test-stdio-closed.js
@@ -22,7 +22,7 @@ if (common.isWindows) {
}
if (process.argv[2] === 'child') {
- [0, 1, 2].forEach((i) => assert.doesNotThrow(() => fs.fstatSync(i)));
+ [0, 1, 2].forEach((i) => fs.fstatSync(i));
return;
}
diff --git a/test/parallel/test-stream-writable-null.js b/test/parallel/test-stream-writable-null.js
index f1b91dee21..706141821b 100644
--- a/test/parallel/test-stream-writable-null.js
+++ b/test/parallel/test-stream-writable-null.js
@@ -27,14 +27,14 @@ common.expectsError(
}
);
-assert.doesNotThrow(() => {
+{
const m = new MyWritable({ objectMode: true }).on('error', (e) => {
assert.ok(e);
});
m.write(null, (err) => {
assert.ok(err);
});
-});
+}
common.expectsError(
() => {
@@ -47,24 +47,25 @@ common.expectsError(
}
);
-assert.doesNotThrow(() => {
+{
const m = new MyWritable().on('error', (e) => {
assert.ok(e);
});
m.write(false, (err) => {
assert.ok(err);
});
-});
+}
-assert.doesNotThrow(() => {
+{
const m = new MyWritable({ objectMode: true });
m.write(false, (err) => assert.ifError(err));
-});
-assert.doesNotThrow(() => {
+}
+
+{
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);
});
-});
+}
diff --git a/test/parallel/test-timers-clear-null-does-not-throw-error.js b/test/parallel/test-timers-clear-null-does-not-throw-error.js
index a15072a4c6..89d433c191 100644
--- a/test/parallel/test-timers-clear-null-does-not-throw-error.js
+++ b/test/parallel/test-timers-clear-null-does-not-throw-error.js
@@ -1,18 +1,11 @@
'use strict';
require('../common');
-const assert = require('assert');
// This test makes sure clearing timers with
// 'null' or no input does not throw error
-
-assert.doesNotThrow(() => clearInterval(null));
-
-assert.doesNotThrow(() => clearInterval());
-
-assert.doesNotThrow(() => clearTimeout(null));
-
-assert.doesNotThrow(() => clearTimeout());
-
-assert.doesNotThrow(() => clearImmediate(null));
-
-assert.doesNotThrow(() => clearImmediate());
+clearInterval(null);
+clearInterval();
+clearTimeout(null);
+clearTimeout();
+clearImmediate(null);
+clearImmediate();
diff --git a/test/parallel/test-timers-unref.js b/test/parallel/test-timers-unref.js
index 9e5a4228ba..d8624d8d9c 100644
--- a/test/parallel/test-timers-unref.js
+++ b/test/parallel/test-timers-unref.js
@@ -22,7 +22,6 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
let unref_interval = false;
let unref_timer = false;
@@ -31,13 +30,8 @@ let checks = 0;
const LONG_TIME = 10 * 1000;
const SHORT_TIME = 100;
-assert.doesNotThrow(() => {
- setTimeout(() => {}, 10).unref().ref().unref();
-}, 'ref and unref are chainable');
-
-assert.doesNotThrow(() => {
- setInterval(() => {}, 10).unref().ref().unref();
-}, 'ref and unref are chainable');
+setTimeout(() => {}, 10).unref().ref().unref();
+setInterval(() => {}, 10).unref().ref().unref();
setInterval(common.mustNotCall('Interval should not fire'), LONG_TIME).unref();
setTimeout(common.mustNotCall('Timer should not fire'), LONG_TIME).unref();
diff --git a/test/parallel/test-tls-client-abort.js b/test/parallel/test-tls-client-abort.js
index be81420d15..09f252db30 100644
--- a/test/parallel/test-tls-client-abort.js
+++ b/test/parallel/test-tls-client-abort.js
@@ -24,7 +24,6 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
-const assert = require('assert');
const tls = require('tls');
const fixtures = require('../common/fixtures');
@@ -32,8 +31,5 @@ const cert = fixtures.readSync('test_cert.pem');
const key = fixtures.readSync('test_key.pem');
const conn = tls.connect({ cert, key, port: 0 }, common.mustNotCall());
-conn.on('error', function() {
-});
-assert.doesNotThrow(function() {
- conn.destroy();
-});
+conn.on('error', function() {});
+conn.destroy();
diff --git a/test/parallel/test-tls-client-abort2.js b/test/parallel/test-tls-client-abort2.js
index 59b592d255..b253e6696c 100644
--- a/test/parallel/test-tls-client-abort2.js
+++ b/test/parallel/test-tls-client-abort2.js
@@ -24,12 +24,9 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
-const assert = require('assert');
const tls = require('tls');
const conn = tls.connect(0, common.mustNotCall());
conn.on('error', common.mustCall(function() {
- assert.doesNotThrow(function() {
- conn.destroy();
- });
+ conn.destroy();
}));
diff --git a/test/parallel/test-tls-legacy-deprecated.js b/test/parallel/test-tls-legacy-deprecated.js
index 3b1919010e..c2560daf21 100644
--- a/test/parallel/test-tls-legacy-deprecated.js
+++ b/test/parallel/test-tls-legacy-deprecated.js
@@ -4,7 +4,6 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
-const assert = require('assert');
const tls = require('tls');
common.expectWarning(
@@ -12,4 +11,4 @@ common.expectWarning(
'tls.createSecurePair() is deprecated. Please use tls.TLSSocket instead.'
);
-assert.doesNotThrow(() => tls.createSecurePair());
+tls.createSecurePair();
diff --git a/test/parallel/test-tls-options-boolean-check.js b/test/parallel/test-tls-options-boolean-check.js
index b84d9b8b17..53f595e0de 100644
--- a/test/parallel/test-tls-options-boolean-check.js
+++ b/test/parallel/test-tls-options-boolean-check.js
@@ -6,7 +6,6 @@ const fixtures = require('../common/fixtures');
if (!common.hasCrypto)
common.skip('missing crypto');
-const assert = require('assert');
const tls = require('tls');
function toArrayBuffer(buf) {
@@ -65,9 +64,7 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
[[{ pem: keyBuff }], false],
[[{ pem: keyBuff }, { pem: keyBuff }], false]
].forEach(([key, cert]) => {
- assert.doesNotThrow(() => {
- tls.createServer({ key, cert });
- });
+ tls.createServer({ key, cert });
});
// Checks to ensure tls.createServer predictably throws an error
@@ -118,9 +115,7 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
[keyBuff, certBuff, caArrDataView],
[keyBuff, certBuff, false],
].forEach(([key, cert, ca]) => {
- assert.doesNotThrow(() => {
- tls.createServer({ key, cert, ca });
- });
+ tls.createServer({ key, cert, ca });
});
// Checks to ensure tls.createServer throws an error for CA assignment
@@ -168,7 +163,5 @@ const invalidCertRE = /^The "cert" argument must be one of type string, Buffer,
['', '', ''],
[0, 0, 0]
].forEach(([key, cert, ca]) => {
- assert.doesNotThrow(() => {
- tls.createSecureContext({ key, cert, ca });
- });
+ tls.createSecureContext({ key, cert, ca });
});
diff --git a/test/parallel/test-util-inspect-proxy.js b/test/parallel/test-util-inspect-proxy.js
index 8c76285499..bc53c1fe68 100644
--- a/test/parallel/test-util-inspect-proxy.js
+++ b/test/parallel/test-util-inspect-proxy.js
@@ -13,7 +13,7 @@ const handler = {
const proxyObj = new Proxy(target, handler);
// Inspecting the proxy should not actually walk it's properties
-assert.doesNotThrow(() => util.inspect(proxyObj, opts));
+util.inspect(proxyObj, opts);
// getProxyDetails is an internal method, not intended for public use.
// This is here to test that the internals are working correctly.
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js
index 31759a372c..4f717e2d6b 100644
--- a/test/parallel/test-util-inspect.js
+++ b/test/parallel/test-util-inspect.js
@@ -537,30 +537,26 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
assert.strictEqual(util.inspect(Object.create(Date.prototype)), 'Date {}');
// GH-1944
-assert.doesNotThrow(() => {
+{
const d = new Date();
d.toUTCString = null;
util.inspect(d);
-});
+}
-assert.doesNotThrow(() => {
+{
const d = new Date();
d.toISOString = null;
util.inspect(d);
-});
+}
-assert.doesNotThrow(() => {
- const r = /regexp/;
- r.toString = null;
- util.inspect(r);
-});
+const r = /regexp/;
+r.toString = null;
+util.inspect(r);
// bug with user-supplied inspect function returns non-string
-assert.doesNotThrow(() => {
- util.inspect([{
- inspect: () => 123
- }]);
-});
+util.inspect([{
+ inspect: () => 123
+}]);
// GH-2225
{
@@ -624,10 +620,8 @@ assert.doesNotThrow(() => {
}
// an object with "hasOwnProperty" overwritten should not throw
-assert.doesNotThrow(() => {
- util.inspect({
- hasOwnProperty: null
- });
+util.inspect({
+ hasOwnProperty: null
});
// new API, accepts an "options" object
@@ -1157,7 +1151,7 @@ if (typeof Symbol !== 'undefined') {
);
}
-assert.doesNotThrow(() => util.inspect(process));
+util.inspect(process);
// Setting custom inspect property to a non-function should do nothing.
{
diff --git a/test/parallel/test-uv-errno.js b/test/parallel/test-uv-errno.js
index 8b10b52c00..d3b4f79db3 100644
--- a/test/parallel/test-uv-errno.js
+++ b/test/parallel/test-uv-errno.js
@@ -14,14 +14,12 @@ keys.forEach((key) => {
if (!key.startsWith('UV_'))
return;
- assert.doesNotThrow(() => {
- const err = _errnoException(uv[key], 'test');
- const name = uv.errname(uv[key]);
- assert.strictEqual(getSystemErrorName(uv[key]), name);
- assert.strictEqual(err.code, name);
- assert.strictEqual(err.code, err.errno);
- assert.strictEqual(err.message, `test ${name}`);
- });
+ const err = _errnoException(uv[key], 'test');
+ const name = uv.errname(uv[key]);
+ assert.strictEqual(getSystemErrorName(uv[key]), name);
+ assert.strictEqual(err.code, name);
+ assert.strictEqual(err.code, err.errno);
+ assert.strictEqual(err.message, `test ${name}`);
});
function runTest(fn) {
diff --git a/test/parallel/test-vm-access-process-env.js b/test/parallel/test-vm-access-process-env.js
index a2f3cb5741..c6b18ec902 100644
--- a/test/parallel/test-vm-access-process-env.js
+++ b/test/parallel/test-vm-access-process-env.js
@@ -28,8 +28,6 @@ require('../common');
const assert = require('assert');
const vm = require('vm');
-assert.doesNotThrow(function() {
- const context = vm.createContext({ process });
- const result = vm.runInContext('process.env["PATH"]', context);
- assert.notStrictEqual(undefined, result);
-});
+const context = vm.createContext({ process });
+const result = vm.runInContext('process.env["PATH"]', context);
+assert.notStrictEqual(undefined, result);
diff --git a/test/parallel/test-vm-create-context-arg.js b/test/parallel/test-vm-create-context-arg.js
index 8675add90c..f549715381 100644
--- a/test/parallel/test-vm-create-context-arg.js
+++ b/test/parallel/test-vm-create-context-arg.js
@@ -28,13 +28,9 @@ assert.throws(function() {
vm.createContext('string is not supported');
}, /^TypeError: sandbox must be an object$/);
-assert.doesNotThrow(function() {
- vm.createContext({ a: 1 });
- vm.createContext([0, 1, 2, 3]);
-});
+vm.createContext({ a: 1 });
+vm.createContext([0, 1, 2, 3]);
-assert.doesNotThrow(function() {
- const sandbox = {};
- vm.createContext(sandbox);
- vm.createContext(sandbox);
-});
+const sandbox = {};
+vm.createContext(sandbox);
+vm.createContext(sandbox);
diff --git a/test/parallel/test-vm-cross-context.js b/test/parallel/test-vm-cross-context.js
index 5d45387e5d..785cc9d7bd 100644
--- a/test/parallel/test-vm-cross-context.js
+++ b/test/parallel/test-vm-cross-context.js
@@ -21,11 +21,8 @@
'use strict';
require('../common');
-const assert = require('assert');
const vm = require('vm');
const ctx = vm.createContext(global);
-assert.doesNotThrow(function() {
- vm.runInContext('!function() { var x = console.log; }()', ctx);
-});
+vm.runInContext('!function() { var x = console.log; }()', ctx);
diff --git a/test/parallel/test-vm-proxy-failure-CP.js b/test/parallel/test-vm-proxy-failure-CP.js
index 343948ac4c..93027576d8 100644
--- a/test/parallel/test-vm-proxy-failure-CP.js
+++ b/test/parallel/test-vm-proxy-failure-CP.js
@@ -1,6 +1,5 @@
'use strict';
require('../common');
-const assert = require('assert');
const vm = require('vm');
// Check that we do not accidentally query attributes.
@@ -13,4 +12,4 @@ const handler = {
const sandbox = new Proxy({ foo: 'bar' }, handler);
const context = vm.createContext(sandbox);
-assert.doesNotThrow(() => vm.runInContext('', context));
+vm.runInContext('', context);
diff --git a/test/parallel/test-whatwg-encoding-textdecoder.js b/test/parallel/test-whatwg-encoding-textdecoder.js
index 5f9499930a..e87364de1e 100644
--- a/test/parallel/test-whatwg-encoding-textdecoder.js
+++ b/test/parallel/test-whatwg-encoding-textdecoder.js
@@ -63,8 +63,8 @@ if (common.hasIntl) {
['unicode-1-1-utf-8', 'utf8', 'utf-8'].forEach((i) => {
const dec = new TextDecoder(i, { fatal: true });
- assert.doesNotThrow(() => dec.decode(buf.slice(0, 8), { stream: true }));
- assert.doesNotThrow(() => dec.decode(buf.slice(8)));
+ dec.decode(buf.slice(0, 8), { stream: true });
+ dec.decode(buf.slice(8));
});
} else {
common.expectsError(
@@ -107,11 +107,11 @@ if (common.hasIntl) {
message: 'Value of "this" must be of type TextDecoder'
};
- assert.doesNotThrow(() => inspectFn.call(instance, Infinity, {}));
- assert.doesNotThrow(() => decodeFn.call(instance));
- assert.doesNotThrow(() => encodingGetter.call(instance));
- assert.doesNotThrow(() => fatalGetter.call(instance));
- assert.doesNotThrow(() => ignoreBOMGetter.call(instance));
+ inspectFn.call(instance, Infinity, {});
+ decodeFn.call(instance);
+ encodingGetter.call(instance);
+ fatalGetter.call(instance);
+ ignoreBOMGetter.call(instance);
const invalidThisArgs = [{}, [], true, 1, '', new TextEncoder()];
invalidThisArgs.forEach((i) => {
diff --git a/test/parallel/test-whatwg-encoding-textencoder.js b/test/parallel/test-whatwg-encoding-textencoder.js
index 4096a02432..5514b714bd 100644
--- a/test/parallel/test-whatwg-encoding-textencoder.js
+++ b/test/parallel/test-whatwg-encoding-textencoder.js
@@ -48,9 +48,9 @@ assert(TextEncoder);
message: 'Value of "this" must be of type TextEncoder'
};
- assert.doesNotThrow(() => inspectFn.call(instance, Infinity, {}));
- assert.doesNotThrow(() => encodeFn.call(instance));
- assert.doesNotThrow(() => encodingGetter.call(instance));
+ inspectFn.call(instance, Infinity, {});
+ encodeFn.call(instance);
+ encodingGetter.call(instance);
const invalidThisArgs = [{}, [], true, 1, '', new TextDecoder()];
invalidThisArgs.forEach((i) => {
diff --git a/test/parallel/test-zlib-close-after-error.js b/test/parallel/test-zlib-close-after-error.js
index 8e21d15933..63d418be09 100644
--- a/test/parallel/test-zlib-close-after-error.js
+++ b/test/parallel/test-zlib-close-after-error.js
@@ -9,7 +9,7 @@ const decompress = zlib.createGunzip(15);
decompress.on('error', common.mustCall((err) => {
assert.strictEqual(decompress._closed, true);
- assert.doesNotThrow(() => decompress.close());
+ decompress.close();
}));
assert.strictEqual(decompress._closed, false);
diff --git a/test/parallel/test-zlib-deflate-constructors.js b/test/parallel/test-zlib-deflate-constructors.js
index 090fbb8d07..97ece1e8af 100644
--- a/test/parallel/test-zlib-deflate-constructors.js
+++ b/test/parallel/test-zlib-deflate-constructors.js
@@ -93,25 +93,11 @@ common.expectsError(
);
// Does not throw if opts.strategy is valid
-assert.doesNotThrow(
- () => { new zlib.Deflate({ strategy: zlib.constants.Z_FILTERED }); }
-);
-
-assert.doesNotThrow(
- () => { new zlib.Deflate({ strategy: zlib.constants.Z_HUFFMAN_ONLY }); }
-);
-
-assert.doesNotThrow(
- () => { new zlib.Deflate({ strategy: zlib.constants.Z_RLE }); }
-);
-
-assert.doesNotThrow(
- () => { new zlib.Deflate({ strategy: zlib.constants.Z_FIXED }); }
-);
-
-assert.doesNotThrow(
- () => { new zlib.Deflate({ strategy: zlib.constants.Z_DEFAULT_STRATEGY }); }
-);
+new zlib.Deflate({ strategy: zlib.constants.Z_FILTERED });
+new zlib.Deflate({ strategy: zlib.constants.Z_HUFFMAN_ONLY });
+new zlib.Deflate({ strategy: zlib.constants.Z_RLE });
+new zlib.Deflate({ strategy: zlib.constants.Z_FIXED });
+new zlib.Deflate({ strategy: zlib.constants.Z_DEFAULT_STRATEGY });
// Throws if opt.strategy is the wrong type.
common.expectsError(
diff --git a/test/parallel/test-zlib-flush-flags.js b/test/parallel/test-zlib-flush-flags.js
index 25cfad70e3..fa9293cfc4 100644
--- a/test/parallel/test-zlib-flush-flags.js
+++ b/test/parallel/test-zlib-flush-flags.js
@@ -1,11 +1,8 @@
'use strict';
const common = require('../common');
-const assert = require('assert');
const zlib = require('zlib');
-assert.doesNotThrow(() => {
- zlib.createGzip({ flush: zlib.constants.Z_SYNC_FLUSH });
-});
+zlib.createGzip({ flush: zlib.constants.Z_SYNC_FLUSH });
common.expectsError(
() => zlib.createGzip({ flush: 'foobar' }),
@@ -23,9 +20,7 @@ common.expectsError(
}
);
-assert.doesNotThrow(() => {
- zlib.createGzip({ finishFlush: zlib.constants.Z_SYNC_FLUSH });
-});
+zlib.createGzip({ finishFlush: zlib.constants.Z_SYNC_FLUSH });
common.expectsError(
() => zlib.createGzip({ finishFlush: 'foobar' }),
diff --git a/test/parallel/test-zlib-invalid-input.js b/test/parallel/test-zlib-invalid-input.js
index 758e489ca0..1b081d919e 100644
--- a/test/parallel/test-zlib-invalid-input.js
+++ b/test/parallel/test-zlib-invalid-input.js
@@ -43,11 +43,9 @@ const unzips = [
nonStringInputs.forEach(common.mustCall((input) => {
// zlib.gunzip should not throw an error when called with bad input.
- assert.doesNotThrow(function() {
- zlib.gunzip(input, function(err, buffer) {
- // zlib.gunzip should pass the error to the callback.
- assert.ok(err);
- });
+ zlib.gunzip(input, function(err, buffer) {
+ // zlib.gunzip should pass the error to the callback.
+ assert.ok(err);
});
}, nonStringInputs.length));
diff --git a/test/parallel/test-zlib-truncated.js b/test/parallel/test-zlib-truncated.js
index 678bfedd41..e04ef7e3d8 100644
--- a/test/parallel/test-zlib-truncated.js
+++ b/test/parallel/test-zlib-truncated.js
@@ -29,10 +29,8 @@ const errMessage = /unexpected end of file/;
const toUTF8 = (buffer) => buffer.toString('utf-8');
// sync sanity
- assert.doesNotThrow(function() {
- const decompressed = zlib[methods.decompSync](compressed);
- assert.strictEqual(toUTF8(decompressed), inputString);
- });
+ const decompressed = zlib[methods.decompSync](compressed);
+ assert.strictEqual(toUTF8(decompressed), inputString);
// async sanity
zlib[methods.decomp](compressed, function(err, result) {
@@ -53,10 +51,8 @@ const errMessage = /unexpected end of file/;
const syncFlushOpt = { finishFlush: zlib.constants.Z_SYNC_FLUSH };
// sync truncated input test, finishFlush = Z_SYNC_FLUSH
- assert.doesNotThrow(function() {
- const result = toUTF8(zlib[methods.decompSync](truncated, syncFlushOpt));
- assert.strictEqual(result, inputString.substr(0, result.length));
- });
+ const result = toUTF8(zlib[methods.decompSync](truncated, syncFlushOpt));
+ assert.strictEqual(result, inputString.substr(0, result.length));
// async truncated input test, finishFlush = Z_SYNC_FLUSH
zlib[methods.decomp](truncated, syncFlushOpt, function(err, decompressed) {
diff --git a/test/parallel/test-zlib.js b/test/parallel/test-zlib.js
index a36e8166ab..1b6855a0b9 100644
--- a/test/parallel/test-zlib.js
+++ b/test/parallel/test-zlib.js
@@ -152,9 +152,7 @@ class SlowStream extends stream.Stream {
}
// windowBits: 8 shouldn't throw
-assert.doesNotThrow(() => {
- zlib.createDeflateRaw({ windowBits: 8 });
-}, 'windowsBits set to 8 should follow legacy zlib behavior');
+zlib.createDeflateRaw({ windowBits: 8 });
{
const node = fs.createReadStream(fixtures.path('person.jpg'));