Skip to content

Enforce arguments constraint reflexively #102

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -929,10 +929,11 @@
if (a.prototype !== b.prototype) return false;
//~~~I've managed to break Object.keys through screwy arguments passing.
// Converting to array solves the problem.
if (isArguments(a)) {
if (!isArguments(b)) {
return false;
}
var aIsArgs = isArguments(a),
bIsArgs = isArguments(b);
if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
return false;
if (aIsArgs) {
a = pSlice.call(a);
b = pSlice.call(b);
return expect.eql(a, b);
Expand Down
8 changes: 8 additions & 0 deletions test/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ describe('expect', function () {
expect('4').to.eql(4);
expect(/a/gmi).to.eql(/a/mig);

err(function() {
expect([]).to.eql(arguments);
}, 'expected [] to sort of equal {}');

err(function() {
expect(arguments).to.eql([]);
}, 'expected {} to sort of equal []');

err(function () {
expect(4).to.eql(3);
}, 'expected 4 to sort of equal 3');
Expand Down