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

Fix #2109: stringify should handle objects with non-coercible length #2110

Merged
merged 1 commit into from
Mar 20, 2016

Conversation

joshlory
Copy link

Fix for #2109. When comparing objects with certain length properties, the reporter throws when stringifying the diff:

it('compare two objects', function () {
   assert.deepEqual({length: {toString: 0}}, {length: 1});
});

Root cause is that some JS objects cannot be coerced to a Number:

> Number({toString: 0});
TypeError: Cannot convert object to primitive value

> Number({a: 0});
< NaN

@danielstjules
Copy link
Contributor

Looks good :) Can you fix the conflicts?

…length

Root cause is that some JS objects cannot be coerced to a Number:

Number({toString: 0});
TypeError: can't convert ({toString:0}) to number
Number({a: 0});
NaN
@joshlory
Copy link
Author

Rebased!

@joshlory
Copy link
Author

@danielstjules is this PR ready to merge? Thanks!

danielstjules added a commit that referenced this pull request Mar 20, 2016
Fix #2109: stringify should handle objects with non-coercible length
@danielstjules danielstjules merged commit 61fbb7f into mochajs:master Mar 20, 2016
@danielstjules
Copy link
Contributor

Thanks again!

@joshlory joshlory deleted the stringify-fix branch March 21, 2016 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants