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

Adds BigInt support to stringify util function. #4112

Merged
merged 2 commits into from
Feb 3, 2021
Merged

Adds BigInt support to stringify util function. #4112

merged 2 commits into from
Feb 3, 2021

Conversation

jjsfernandez
Copy link

Description of the Change

Fixes #4090, adds a new case to the _stringify function in utils so it can handle the BigInt case.

Alternate Designs

There were two choices considered in the issue BigInt<123> or 123n i went with the latter because it's the standard way JS presents BigInts

Why should this be in core?

Nice way of representing BigInts in errors.

Benefits

Support for Stringify-ing BigInts

Possible Drawbacks

I had to add /* global BigInt */ at the top of the spec file, i don't know if that is the best place for it.

Applicable issues

Fixes #4090

@jsf-clabot
Copy link

jsf-clabot commented Nov 27, 2019

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link

coveralls commented Nov 27, 2019

Coverage Status

Coverage increased (+0.003%) to 94.129% when pulling 2127bcd on JosejeSinohui:issue/4090 into 9878f32 on mochajs:master.

@jjsfernandez
Copy link
Author

I already signed the Contributor License Agreement, i don't know why does it show like pending, is there a way to reset it to sign it again?

@boneskull
Copy link
Contributor

it could be a mismatch between username / email address.

some ideas:

  • is the email the same in the commits?
  • is the email address and username in the CLA tool the same as your github account?
  • does email address on github account match the email address you used in the tool?

@boneskull
Copy link
Contributor

the test should be failing in IE11 and maybe safari... hmm.

@jjsfernandez
Copy link
Author

jjsfernandez commented Dec 4, 2019

the test should be failing in IE11 and maybe safari... hmm.

@boneskull
i checked compatibility here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof

is there something i am missing?

@jjsfernandez
Copy link
Author

@boneskull any follow up on this?

@boneskull
Copy link
Contributor

just that those don’t support BigInt but I’m confused about why they weren’t failing CI. could you look in to it? I don’t have time atm. hoping to have more time for project after new year

@jjsfernandez
Copy link
Author

From what i see, the CI runs tests only on different NodeJs versions, Node 8 doesn't support BigInts either but I only added a new case to the stringify function, in that case it uses the toString function to create the representation of the BigInt, so the code it's never instantiating a BigInteger, just knows how to handle one if it ever receives it.
The build was failing before because in the test that I added was creating a BigInt to test that it was correctly parsed into a string with the stringify function. Because of this the test didn't pass in node8 because BigInteger wasn't supported there. To fix it I just added a check for support before trying it.

@mvlabat
Copy link

mvlabat commented Nov 13, 2020

Mocha just hangs for me when it tries to assert equality of two different bigints (it's fine when they are equal though). Might it be related to the issue that this PR fixes?

@boneskull any chance this PR gets merged anytime soon? Sorry to nudge.

@mattbishop
Copy link

👍 BigInt support is widespread in 2021: https://caniuse.com/?search=bigint

@juergba
Copy link
Contributor

juergba commented Feb 2, 2021

I rebased to master branch.
I don't know why the ESLint test is failing, I will have a look later.
The cancelled browser test (pull_request) is off-topic, due to our GH actions setup.

@juergba
Copy link
Contributor

juergba commented Feb 2, 2021

GH actions has problems with downloading an artifact and therefore the ESLint tests fail. It doesn't seem to be related to this PR.
I restarted our CI tests on another, successfully passing PR and the ESLint tests fail now.
It's not the first time GH actions is behaving weirdly.

Copy link
Contributor

@juergba juergba left a comment

Choose a reason for hiding this comment

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

@JosejeSinohui thank you. I apologize for the long delay.

@juergba juergba merged commit 9122909 into mochajs:master Feb 3, 2021
@juergba juergba added type: feature enhancement proposal semver-patch implementation requires increase of "patch" version number; "bug fixes" labels Feb 3, 2021
@juergba juergba added this to the next milestone Feb 3, 2021
chharvey pushed a commit to chharvey/mocha that referenced this pull request Feb 9, 2021
@juergba juergba modified the milestones: next, v8.3.0 Feb 11, 2021
This was referenced Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch implementation requires increase of "patch" version number; "bug fixes" type: feature enhancement proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bigint support.
8 participants