Conversation
This adds thorough snapshotting tests for various types' since() and until() methods with various combinations of largestUnit, smallestUnit, and roundingIncrement. At one point I tried adding these before, but the snapshot files were too large for GitHub. But, it's worth trying again since we did actually find bugs in these methods. I've done some tricks to reduce the snapshot file size and cut down the testing space. Note there is no datetimedifferencerounding.mjs - that snapshot file is still too large. But I believe the code paths are sufficiently covered by PlainDate and PlainTime.
This adds thorough snapshotting tests for Duration.round() with various combinations of largestUnit, smallestUnit, and roundingIncrement, with a relativeTo. But only a "boring" relativeTo, either 1970-01-01 in plain or zoned (UTC) form. At one point I tried to write a more comprehensive version of this snapshot test using all the "interesting" values for relativeTo, but the snapshot file was too large for GitHub. But, it's worth trying again with this reduced testing space since we did actually find bugs in these methods.
Seems to be a regression from #3147. There is a condition triggering the special case for avoiding a disambiguation when calculating the startEpochNs of the bounding window (added to fix #3149). This condition is not correct when largestUnit ≠ smallestUnit, and the smallest unit is 0 while a larger unit is nonzero. The condition only checks that the smallest unit (r1) is 0, while it should check that all larger units are 0 as well. Updates the newly added snapshot tests to show where the differences in output are. See: #3316
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3319 +/- ##
=======================================
Coverage 98.39% 98.39%
=======================================
Files 22 22
Lines 10763 10763
Branches 1866 1866
=======================================
Hits 10590 10590
Misses 161 161
Partials 12 12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Seems to be a regression from #3147. There is a condition triggering the special case for avoiding a disambiguation when calculating the startEpochNs of the bounding window (added to fix #3149). This condition is not correct when largestUnit ≠ smallestUnit, and the smallest unit is 0 while a larger unit is nonzero. The condition only checks that the smallest unit (r1) is 0, while it should check that all larger units are 0 as well.
Updates the newly added snapshot tests to show where the differences in output are.
This fix corresponds to a needs-consensus PR that reached TC39 consensus in the meeting of 2026-05-19.
Closes: #3316