-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Implement Number.prototype.toPrecision #962
Conversation
Codecov Report
@@ Coverage Diff @@
## master #962 +/- ##
==========================================
+ Coverage 59.40% 59.48% +0.08%
==========================================
Files 166 166
Lines 10717 10780 +63
==========================================
+ Hits 6366 6413 +47
- Misses 4351 4367 +16
Continue to review full report at Codecov.
|
…ototype.toPrecision
Test262 conformance changes:
|
The doc comment for |
@RageKnify Done; the last commit should correct the spec and mdn links :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @NathanRoyer having comments with // 1
, // 2
, etc matching the spec's steps helps a lot in understanding the code, these are long functions and having each step identified makes it easy to check the "Rust translation", should be easy for you to do and it helps everyone who will one day read the function to understand it.
One thing I think can be changed to more closely follow the spec is in step 3 to use:
Line 878 in 8f388d5
pub fn to_integer_or_infinity(&self, context: &mut Context) -> Result<IntegerOrInfinity> { |
That was recently implemeted and should make the first
if
a bit clearer.
You can also use the following code to get precision
as a Value
without needing to use unwrap
, you will get Value::undefined
if no argument was given.
let precision = args.get(0).cloned().unwrap_or_default();
And for the links you changed the wrong ones 😅 , you changed lines 13-14 but the method's links are in lines 321-322, but don't worry just place the old links back and replaced the method's.
Updating my fork to the original project
…r to the spec for Number.prototype.toPrecision
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's looking good, just a few more changes to make it easier to read it along with the spec.
@Razican Hey, I just found 2 bugs earlier today, and I was discussing them on the discord forum... I will include the fixes in my next contribution. |
This Pull Request closes #349.
It changes the following: