Skip to content

Conversation

@ptomato
Copy link
Collaborator

@ptomato ptomato commented Dec 8, 2025

Testing Temporal.Duration.prototype.total() with a variety of "interesting" durations, with relativeTo being various PlainDates, various ZonedDateTimes, or nothing.

Tests the invariant that total() and round() should agree. This invariant actually does not hold in a surprising number of situations, but as far as I can tell that is correct per the specification and is due to floating-point precision loss which we have correctly accounted for.

I also updated the "interesting" durations to be distributed a bit more over the full testing space, and updated the existing snapshot files accordingly.

I noticed that we hardly had any tests with large numbers in the years,
months, weeks, or days fields of durations, or non-calendar durations
with days. This removes some of the randomly generated durations from
the existing categories and adds randomly generated durations from the
categories named above, so that makeDurationCases() has a mix of
durations that are better distributed throughout the testing space.

Also pulls each category of randomly generated durations out into its
own array, and concats them in makeDurationCases(), to allow for
adjusting the mix during debugging.

Updates the snapshots accordingly.
Testing Temporal.Duration.prototype.total() with a variety
of "interesting" durations, with relativeTo being various PlainDates,
various ZonedDateTimes, or nothing.

Tests the invariant that total() and round() should agree. This
invariant actually does not hold in a surprising number of situations,
but as far as I can tell that is correct per the specification and is
due to floating-point precision loss which we have correctly accounted
for.
@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.74%. Comparing base (2cee76a) to head (8249519).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3200   +/-   ##
=======================================
  Coverage   96.74%   96.74%           
=======================================
  Files          22       22           
  Lines       10348    10348           
  Branches     1859     1859           
=======================================
  Hits        10011    10011           
  Misses        287      287           
  Partials       50       50           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants