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
1 changed files with 7 additions and 5 deletions

View File

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