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

Tests for negative zero (-0) #8

Merged
merged 1 commit into from Jan 28, 2017
Merged

Conversation

brigand
Copy link
Contributor

@brigand brigand commented Oct 31, 2016

I had to disable a test that's failing in master. I tried to fix it initially, but I don't quite understand why it's not working.

@@ -7,10 +7,3 @@ test('function', function (t) {
t.equal(inspect(obj), '[ 1, 2, [Function: f], 4 ]');
});

test('function name', function (t) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this test fails in master on node 6+ due to function name inference.

I'll fix this in master rather than just removing the test here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k, fixed in 7540ae5

@@ -33,6 +33,14 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
if (typeof obj === 'string') {
return inspectString(obj);
}
if (typeof obj === 'number') {
if (Object.is) {
Copy link
Member

@ljharb ljharb Oct 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should still pass when Object.is is not present - it'd probably be simpler to do:

if (obj === 0) {
  return Infinity / obj > 0 ? '0' : '-0';
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly, Object.is is present as far back as node 0.8 :-). I've made this change so it works in 0.6.

@ljharb ljharb merged commit 521d345 into inspect-js:master Jan 28, 2017
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.

None yet

2 participants