Skip to content

Commit

Permalink
[Refactor] _assert: avoid reassigning arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jan 13, 2024
1 parent 878a500 commit dc64c08
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/test.js
Expand Up @@ -450,7 +450,7 @@ Test.prototype._assert = function assert(ok, opts) {
var self = this;
var extra = opts.extra || {};

ok = !!ok || !!extra.skip;
var actualOK = !!ok || !!extra.skip;

var name = defined(extra.message, opts.message, '(unnamed assert)');
if (this.calledEnd && opts.operator !== 'fail') {
Expand All @@ -460,7 +460,7 @@ Test.prototype._assert = function assert(ok, opts) {

var res = {
id: self.assertCount++,
ok: ok,
ok: actualOK,
skip: defined(extra.skip, opts.skip),
todo: defined(extra.todo, opts.todo, self._todo),
name: name,
Expand All @@ -473,13 +473,13 @@ Test.prototype._assert = function assert(ok, opts) {
if (hasOwn(opts, 'expected') || hasOwn(extra, 'expected')) {
res.expected = defined(extra.expected, opts.expected);
}
this._ok = !!(this._ok && ok);
this._ok = !!(this._ok && actualOK);

if (!ok && !res.todo) {
if (!actualOK && !res.todo) {
res.error = defined(extra.error, opts.error, new Error(res.name));
}

if (!ok) {
if (!actualOK) {
var e = new Error('exception');
var err = $split(e.stack || '', '\n');
var tapeDir = __dirname + path.sep;
Expand Down

0 comments on commit dc64c08

Please sign in to comment.