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

toString() precision #1006

Merged
merged 4 commits into from
Oct 22, 2020
Merged

toString() precision #1006

merged 4 commits into from
Oct 22, 2020

Conversation

ptomato
Copy link
Collaborator

@ptomato ptomato commented Oct 16, 2020

The bulk of this commit is adding :00 to expected test output; it's probably safe to ignore those parts when reviewing this.

Closes: #329

@codecov
Copy link

codecov bot commented Oct 16, 2020

Codecov Report

Merging #1006 into main will increase coverage by 0.05%.
The diff coverage is 98.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1006      +/-   ##
==========================================
+ Coverage   94.33%   94.38%   +0.05%     
==========================================
  Files          18       18              
  Lines        6420     6556     +136     
  Branches      959      983      +24     
==========================================
+ Hits         6056     6188     +132     
- Misses        357      361       +4     
  Partials        7        7              
Flag Coverage Δ
#test262 47.60% <44.73%> (+0.67%) ⬆️
#tests 90.54% <98.16%> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
polyfill/lib/time.mjs 97.14% <97.05%> (-0.33%) ⬇️
polyfill/lib/datetime.mjs 95.23% <97.87%> (+0.19%) ⬆️
polyfill/lib/ecmascript.mjs 96.18% <98.36%> (+0.08%) ⬆️
polyfill/lib/date.mjs 92.14% <100.00%> (ø)
polyfill/lib/duration.mjs 97.46% <100.00%> (ø)
polyfill/lib/instant.mjs 97.22% <100.00%> (-0.17%) ⬇️
polyfill/lib/yearmonth.mjs 94.96% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 70153a1...33728dd. Read the comment docs.

@Ms2ger Ms2ger force-pushed the 329-tostring-precision branch from f3f9928 to 40a11a5 Compare October 19, 2020 08:48
Copy link
Collaborator

@Ms2ger Ms2ger left a comment

Choose a reason for hiding this comment

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

Note that I rebased and fixed the failing test262 tests

polyfill/lib/ecmascript.mjs Outdated Show resolved Hide resolved
polyfill/lib/instant.mjs Outdated Show resolved Hide resolved
spec/abstractops.html Outdated Show resolved Hide resolved
spec/abstractops.html Outdated Show resolved Hide resolved
spec/abstractops.html Outdated Show resolved Hide resolved
spec/datetime.html Outdated Show resolved Hide resolved
polyfill/lib/ecmascript.mjs Show resolved Hide resolved
spec/abstractops.html Outdated Show resolved Hide resolved
Copy link
Collaborator

@Ms2ger Ms2ger left a comment

Choose a reason for hiding this comment

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

LGTM modulo the one comment

spec/abstractops.html Outdated Show resolved Hide resolved
spec/abstractops.html Show resolved Hide resolved
In toString() we are going to have a different default rounding mode than
in round() and difference(), so don't hardcode the default in the abstract
operation.

See: #329
This will be reused in Temporal.DateTime.prototype.toString when we add
precision options.

See: #329
This will be reused in Temporal.Instant.prototype.toString when we add
precision options.

See: #329
On DateTime.toString(), Time.toString(), and Instant.toString(), we add
an options bag with the options `fractionalSecondDigits`, `smallestUnit`,
and `roundingMode`. `smallestUnit` and `fractionalSecondDigits` control
which units are output, and `roundingMode` is a rarely-needed option that
allows other rounding behaviour than truncation.

The default behaviour is changed as well. Previously seconds would not be
output if the seconds and lower components would be 0, and the precision
after the decimal point would be 0, 3, 6, or 9. After this change, seconds
are always output, and all trailing zeroes after the decimal point are
dropped.

This change requires a lot of adjustments to expected test output.

Closes: #329
@ptomato
Copy link
Collaborator Author

ptomato commented Oct 22, 2020

Addressed the review comments, so merging as per the approval

@ptomato ptomato merged commit 43b8373 into main Oct 22, 2020
@ptomato ptomato deleted the 329-tostring-precision branch October 22, 2020 18:42
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.

Why do toString methods truncate?
2 participants