Skip to content

Thorough duration totalling tests#3200

Merged
Ms2ger merged 2 commits intomainfrom
duration-total
Feb 5, 2026
Merged

Thorough duration totalling tests#3200
Ms2ger merged 2 commits intomainfrom
duration-total

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.

@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.09%. Comparing base (b2e8299) to head (2b8234a).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3200   +/-   ##
=======================================
  Coverage   98.09%   98.09%           
=======================================
  Files          22       22           
  Lines       10464    10464           
  Branches     1808     1808           
=======================================
  Hits        10265    10265           
  Misses        182      182           
  Partials       17       17           

☔ 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.

@Ms2ger Ms2ger enabled auto-merge (rebase) February 5, 2026 10:41
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.
@Ms2ger Ms2ger merged commit 003a37a into main Feb 5, 2026
6 checks passed
@Ms2ger Ms2ger deleted the duration-total branch February 5, 2026 11:01
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