assert: replace many if's with if-else statement

Replace multiple mutually exclusive `if` statements with if-else
statements.

PR-URL: https://github.com/nodejs/node/pull/14043
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: David Cai <davidcai1993@yahoo.com>
This commit is contained in:
kuroljov 2017-07-02 23:48:47 +03:00 committed by Tobias Nießen
parent b01ac75edc
commit 6e86a70da2

View File

@ -62,18 +62,20 @@ function innerFail(actual, expected, message, operator, stackStartFunction) {
} }
function fail(actual, expected, message, operator, stackStartFunction) { function fail(actual, expected, message, operator, stackStartFunction) {
if (arguments.length === 0) { const argsLen = arguments.length;
if (argsLen === 0) {
message = 'Failed'; message = 'Failed';
} } else if (argsLen === 1) {
if (arguments.length === 1) {
message = actual; message = actual;
actual = undefined; actual = undefined;
} } else if (argsLen === 2) {
if (arguments.length === 2) {
operator = '!='; operator = '!=';
} }
innerFail(actual, expected, message, operator, stackStartFunction || fail); innerFail(actual, expected, message, operator, stackStartFunction || fail);
} }
assert.fail = fail; assert.fail = fail;
// The AssertionError is defined in internal/error. // The AssertionError is defined in internal/error.