mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
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>
This commit is contained in:
124 files changed
+598
-1012
No files matched your search
@@ -144,6 +144,4 @@ assert.strictEqual(ret, `${msg}\n`);
|
||||
}
|
||||
|
||||
// Verify the shell option works properly
|
||||
assert.doesNotThrow(() => {
|
||||
execFileSync(process.execPath, [], execOpts);
|
||||
});
|
||||
execFileSync(process.execPath, [], execOpts);
|
||||
@@ -42,19 +42,15 @@ tmpdir.refresh();
|
||||
|
||||
fs.writeFileSync(filepath, 'hello');
|
||||
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
const watcher = fs.watch(filepath);
|
||||
watcher.on('change', common.mustCall(function(event, filename) {
|
||||
assert.strictEqual(event, 'change');
|
||||
const watcher = fs.watch(filepath);
|
||||
watcher.on('change', common.mustCall(function(event, filename) {
|
||||
assert.strictEqual(event, 'change');
|
||||
|
||||
if (expectFilePath) {
|
||||
assert.strictEqual(filename, 'watch.txt');
|
||||
}
|
||||
watcher.close();
|
||||
}));
|
||||
if (expectFilePath) {
|
||||
assert.strictEqual(filename, 'watch.txt');
|
||||
}
|
||||
);
|
||||
watcher.close();
|
||||
}));
|
||||
|
||||
setImmediate(function() {
|
||||
fs.writeFileSync(filepath, 'world');
|
||||
@@ -68,19 +64,15 @@ tmpdir.refresh();
|
||||
|
||||
fs.writeFileSync(filepathAbs, 'howdy');
|
||||
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
const watcher =
|
||||
fs.watch('hasOwnProperty', common.mustCall(function(event, filename) {
|
||||
assert.strictEqual(event, 'change');
|
||||
const watcher =
|
||||
fs.watch('hasOwnProperty', common.mustCall(function(event, filename) {
|
||||
assert.strictEqual(event, 'change');
|
||||
|
||||
if (expectFilePath) {
|
||||
assert.strictEqual(filename, 'hasOwnProperty');
|
||||
}
|
||||
watcher.close();
|
||||
}));
|
||||
}
|
||||
);
|
||||
if (expectFilePath) {
|
||||
assert.strictEqual(filename, 'hasOwnProperty');
|
||||
}
|
||||
watcher.close();
|
||||
}));
|
||||
|
||||
setImmediate(function() {
|
||||
fs.writeFileSync(filepathAbs, 'pardner');
|
||||
@@ -91,21 +83,17 @@ tmpdir.refresh();
|
||||
const testsubdir = fs.mkdtempSync(testDir + path.sep);
|
||||
const filepath = path.join(testsubdir, 'newfile.txt');
|
||||
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
const watcher =
|
||||
fs.watch(testsubdir, common.mustCall(function(event, filename) {
|
||||
const renameEv = common.isSunOS || common.isAIX ? 'change' : 'rename';
|
||||
assert.strictEqual(event, renameEv);
|
||||
if (expectFilePath) {
|
||||
assert.strictEqual(filename, 'newfile.txt');
|
||||
} else {
|
||||
assert.strictEqual(filename, null);
|
||||
}
|
||||
watcher.close();
|
||||
}));
|
||||
}
|
||||
);
|
||||
const watcher =
|
||||
fs.watch(testsubdir, common.mustCall(function(event, filename) {
|
||||
const renameEv = common.isSunOS || common.isAIX ? 'change' : 'rename';
|
||||
assert.strictEqual(event, renameEv);
|
||||
if (expectFilePath) {
|
||||
assert.strictEqual(filename, 'newfile.txt');
|
||||
} else {
|
||||
assert.strictEqual(filename, null);
|
||||
}
|
||||
watcher.close();
|
||||
}));
|
||||
|
||||
setImmediate(function() {
|
||||
const fd = fs.openSync(filepath, 'w');
|
||||
|
||||
@@ -4,7 +4,6 @@ const common = require('../common');
|
||||
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
const assert = require('assert');
|
||||
const { Session } = require('inspector');
|
||||
|
||||
const session = new Session();
|
||||
@@ -18,10 +17,8 @@ common.expectsError(
|
||||
}
|
||||
);
|
||||
|
||||
assert.doesNotThrow(() => session.connect());
|
||||
|
||||
assert.doesNotThrow(
|
||||
() => session.post('Runtime.evaluate', { expression: '2 + 2' }));
|
||||
session.connect();
|
||||
session.post('Runtime.evaluate', { expression: '2 + 2' });
|
||||
|
||||
[1, {}, [], true, Infinity, undefined].forEach((i) => {
|
||||
common.expectsError(
|
||||
@@ -58,5 +55,5 @@ common.expectsError(
|
||||
}
|
||||
);
|
||||
|
||||
assert.doesNotThrow(() => session.disconnect());
|
||||
assert.doesNotThrow(() => session.disconnect());
|
||||
session.disconnect();
|
||||
session.disconnect();
|
||||
@@ -3,7 +3,6 @@ const common = require('../common');
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
const assert = require('assert');
|
||||
const tls = require('tls');
|
||||
|
||||
['foobar', 1, {}, []].forEach(function connectThrows(input) {
|
||||
@@ -30,7 +29,5 @@ function connectDoesNotThrow(input) {
|
||||
lookup: input
|
||||
};
|
||||
|
||||
assert.doesNotThrow(function() {
|
||||
tls.connect(opts);
|
||||
});
|
||||
tls.connect(opts);
|
||||
}
|
||||
Reference in new issue
Block a user