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]: Diff viewer(#1229, #1132, ...) #1493

Merged
merged 1 commit into from
Jan 18, 2015
Merged

[Fix]: Diff viewer(#1229, #1132, ...) #1493

merged 1 commit into from
Jan 18, 2015

Conversation

a8m
Copy link
Contributor

@a8m a8m commented Jan 7, 2015

This PR should fix some issues in the Diff viewer that depends on the stringify function
for example:

expect(-0).eql(0);  // assert with empty representation
expect({ n: -0 }).eql({ n: 0 });  // same with the canonical behavior
expect(-0).eql(1);
/* representation:
  +expected: 1
  -actual: 0
expect(new Buffer([0x01])).eql(new Buffer([0x02])); // asset with empty representation
  • Infinity,NaN:
expect({ infi: Infinity, nan: NaN }).eql({});
/* representation:
-{
-  "infi": null
-  "nan": null
-}
this happens because JSON.stringify(NaN/Infinity) returns `null`(could fixed with `replacer` function)
  • Date, RegExp, Function and Circular represents as a string:
var actual = {
  string: "string",
  regex: /^[a-z]/,
  func: function() {},
  date: new Date(0)
};
actual.circular =  actual;
expect(actual).eql({});
/* should represent without the `"` sign(that indicating to string representation)
 -{
 -  "circular": "[Circular]"
 -  "date": "[Date: 1970-01-01T00:00:00.000Z]"
 -  "func": "[Function]"
 -  "regex": "/^[a-z]/"
 -  "string": "string"
 -}

- This PR fixed that and the result will be like so:
 -{
 -  "circular": [Circular]
 -  "date": [Date: 1970-01-01T00:00:00.000Z]
 -  "func": [Function]
 -  "regex": /^[a-z]/
 -  "string": "string"
 -}

I changed the current specs, created more tests to get full coverage and did some DRY refactoring

@travisjeffery
Copy link
Contributor

broken tests?

@a8m
Copy link
Contributor Author

a8m commented Jan 9, 2015

@travisjeffery the tests was failed on 0.8 and 0.11 versions, I fixed that in fea3fb7ad291d8fad0b5d0edc6fced987b24e579
thanks

@a8m
Copy link
Contributor Author

a8m commented Jan 11, 2015

//cc @boneskull

@travisjeffery
Copy link
Contributor

@a8m can you squash these commits? thanks

@a8m
Copy link
Contributor Author

a8m commented Jan 13, 2015

@travisjeffery done.
thanks

travisjeffery pushed a commit that referenced this pull request Jan 18, 2015
[Fix]: Diff viewer(#1229, #1132, ...)
@travisjeffery travisjeffery merged commit e130e31 into mochajs:master Jan 18, 2015
@a8m
Copy link
Contributor Author

a8m commented Jan 18, 2015

Awesome @travisjeffery
Thx

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