Add Temporal half-rounding boundary tests for PlainDate, PlainDateTime, PlainYearMonth, and ZonedDateTime#4996
Open
MidnightDesign wants to merge 3 commits intotc39:mainfrom
Open
Conversation
…and dayOfWeek The existing rounding mode tests for PlainDate.prototype.since() and PlainDate.prototype.until() use dates that produce ~31.97 months of difference, well above the 0.5 boundary. All half-* rounding modes produce identical results, making it impossible to distinguish halfExpand from halfTrunc, or halfEven from halfCeil. These new tests use dates that produce exactly 0.5 fractional progress (183/366 days in a leap year), causing all nine rounding modes to produce distinct result patterns. The 2.5-year case specifically distinguishes halfEven (rounds to nearest even integer 2) from halfExpand (rounds away from zero to 3). Also adds: - inLeapYear century-year tests (1700, 1800, 1900, 2100, 2200) exercising the 100/400 rule that the basic test does not cover - dayOfWeek tests across all 12 months of a year, since the basic test only checks 7 consecutive days within a single month Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unrelated dayOfWeek and inLeapYear tests. Add RoundRelativeDuration spec references to info blocks. Extend half-boundary coverage to PlainDateTime, PlainYearMonth, and ZonedDateTime (until + since). PlainYearMonth uses June-starting dates because RoundRelativeDuration converts month remainders to days: Jun-Nov = 183 days in a 366-day year span (Jun 2019 - Jun 2020 crossing Feb 29), giving exactly 183/366 = 0.5. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Note
This PR was drafted with the help of Claude Code. Apologies if that's not welcome here — happy to revise anything by hand.
Context
We're building temporal-php, a PHP 8.4 port of the TC39 Temporal API. We run the test262 suite as part of our CI (transpiled to PHP) and also use Infection for mutation testing. Infection systematically modifies source code and checks whether the test suite catches each mutation. Out of 11,983 mutations, several hundred escaped — and many of those escaped because the upstream test262 data doesn't exercise certain code paths. This PR adds tests to close the most impactful gaps we found.
Summary
Eight new test files across four Temporal types, all exercising the exact 0.5 fractional boundary in
RoundRelativeDuration:PlainDate,PlainDateTime,ZonedDateTime(since/anduntil/): Test all 9 rounding modes at exact 0.5 fractional progress (183 days out of a 366-day leap year). The existingroundingmode-*.jstests use dates producing ~2.663 fractional years, where all half-* modes round identically. These new tests include both 1.5-year (odd integer) and 2.5-year (even integer) cases to distinguishhalfEvenfromhalfExpand.PlainYearMonth(since/anduntil/): Same boundary test, but uses June-starting dates becauseRoundRelativeDurationconverts month remainders to days: Jun–Nov = 183 days in the 366-day year span from Jun 2019 to Jun 2020 (crossing Feb 29), giving exactly 183/366 = 0.5.The
untiltests cover the positive direction; thesincetests cover the negative direction (wherehalfExpandandhalfCeildiverge).How the gaps were found
Infection rewrites code like swapping
halfExpandmatch arms, etc. If no test fails, the mutant "escapes." We traced ~80 escaped mutants back to the fact that all half-* rounding modes produce the same output with the current test data (no value near the 0.5 boundary), so entirematcharms can be deleted or swapped without detection.All expected values were verified against V8's
Temporalimplementation viatest262-harnesswithesvu-installed V8 (d8).