Skip to content

Commit

Permalink
assert: replace many if's with if-else statement
Browse files Browse the repository at this point in the history
Replace multiple mutually exclusive `if` statements with if-else
statements.

PR-URL: #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>
  • Loading branch information
viktor-ku authored and tniessen committed Jul 5, 2017
1 parent b01ac75 commit 6e86a70
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6e86a70

Please sign in to comment.