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

Add tests for Number constructor that highlight deficiencies in certain environments. #366

Merged
merged 1 commit into from
Nov 1, 2015

Conversation

Xotic750
Copy link
Contributor

These were recently fixed in lodash trunk, _.toNumber.

Original PR lodash/lodash#1577
Actual merge lodash/lodash@3795534

@Xotic750
Copy link
Contributor Author

There are a couple of others that I will try to add, but you should have everything you need.

@@ -387,5 +387,31 @@ describe('Number', function () {
expect(Number('0o11')).to.equal(9);
expect(Number({ toString: function () { return '0o12'; }, valueOf: function () { return '0o13'; } })).to.equal(11);
});

it('should produce NaN', function () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

these tests are failing but it's very hard to figure out which line is failing.

Perhaps expect(String(Number(…))).to.equal('NaN') would be better? I don't think we need to worry about testing that Number() returns a number :-)

@Xotic750
Copy link
Contributor Author

Changed those to String and 'NaN', hope that helps you a little more. On Node v0.10 and v0.12 the very first test on line 392 is failing to begin with.
expect(String(Number('0b12'))).to.equal('NaN');
https://github.com/paulmillr/es6-shim/pull/366/files#diff-cc37320af8aeb8b7582dad90cc114e55R392

@ljharb
Copy link
Collaborator

ljharb commented Oct 31, 2015

Thanks, this is highlighting a real failure. Can you please rebase these two commits down to one? I'll merge it manually, along with the fix.

…in environments.

Altered tests as suggested
@Xotic750
Copy link
Contributor Author

Xotic750 commented Nov 1, 2015

There are some other tests that highlight other issues but I guess we can take those separately?

@ljharb
Copy link
Collaborator

ljharb commented Nov 1, 2015

I can leave this PR open, and you can keep adding commits to it, but if you rebase the existing diff into a single commit, I can cherry-pick it into master.

@Xotic750
Copy link
Contributor Author

Xotic750 commented Nov 1, 2015

I can do that when I have a little time (next week), I think some of this affects your https://github.com/ljharb/es-abstract and https://github.com/ljharb/es-to-primitive projects.

@ljharb
Copy link
Collaborator

ljharb commented Nov 1, 2015

It definitely does - please open issues/PRs there as well when you can :-)

@ljharb ljharb merged commit 2385f6e into paulmillr:master Nov 1, 2015
ljharb added a commit that referenced this pull request Nov 1, 2015
@ljharb
Copy link
Collaborator

ljharb commented Nov 1, 2015

Turns out to-primitive doesn't have the bug, as it doesn't apply there. es-abstract is now fixed. Thanks!

@Xotic750
Copy link
Contributor Author

Xotic750 commented Nov 1, 2015

No problem, I think you still have the badHex issue though, some older environments, node v0.8 accepts +/-Hex value. But you may not be worried about such environments. I think the other (missing tests) are to check whitespace trimming, making sure that the correct ones are stripped.

@ljharb
Copy link
Collaborator

ljharb commented Nov 1, 2015

@Xotic750 I am indeed worried about those environments - more tests are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants