Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert: remove unneeded arguments special handling #7413

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
const compare = process.binding('buffer').compare;
const util = require('util');
const Buffer = require('buffer').Buffer;
const pSlice = Array.prototype.slice;
const pToString = (obj) => Object.prototype.toString.call(obj);

// 1. The assert module provides functions that throw
Expand Down Expand Up @@ -223,11 +222,6 @@ function objEquiv(a, b, strict, actualVisitedObjects) {
const bIsArgs = isArguments(b);
if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
return false;
if (aIsArgs) {
a = pSlice.call(a);
b = pSlice.call(b);
return _deepEqual(a, b, strict);
}
const ka = Object.keys(a);
const kb = Object.keys(b);
var key, i;
Expand Down
16 changes: 15 additions & 1 deletion test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ assert.throws(makeBlock(a.strictEqual, null, undefined),
assert.doesNotThrow(makeBlock(a.notStrictEqual, 2, '2'),
'notStrictEqual(2, \'2\')');

// deepEquals joy!
// deepEqual joy!
// 7.2
assert.doesNotThrow(makeBlock(a.deepEqual, new Date(2000, 3, 14),
new Date(2000, 3, 14)),
Expand Down Expand Up @@ -409,6 +409,20 @@ var args = (function() { return arguments; })();
a.throws(makeBlock(a.deepEqual, [], args));
a.throws(makeBlock(a.deepEqual, args, []));

// more checking that arguments objects are handled correctly
{
const returnArguments = function() { return arguments; };

const someArgs = returnArguments('a');
const sameArgs = returnArguments('a');
const diffArgs = returnArguments('b');

a.throws(makeBlock(a.deepEqual, someArgs, ['a']));
a.throws(makeBlock(a.deepEqual, ['a'], someArgs));
a.throws(makeBlock(a.deepEqual, someArgs, {'0': 'a'}));
a.throws(makeBlock(a.deepEqual, someArgs, diffArgs));
a.doesNotThrow(makeBlock(a.deepEqual, someArgs, sameArgs));
}

var circular = {y: 1};
circular.x = circular;
Expand Down