built-ins/Temporal/Duration/prototype/round/calendar-dateuntil-called-with-singular-largestunit.js is too complicated
Some of the Temporal test such as
https://github.com/tc39/test262/blob/main/test/built-ins/Temporal/Duration/prototype/round/calendar-dateuntil-called-with-singular-largestunit.js
are way too complicated to show why the expectation is correct and track down issue if not.
First the first set of tests
years: ["year", "day", "month", "day"],
months: ["month", "day", "day"],
weeks: ["week", "day", "day"],
days: ["day", "day", "day"],
I got different results but the description in the test file is too hard to fiure out why my actual result are different and why these expectation is stated in the test.
I got
years: ["year", "day", "month" ],
months: ["month", "day" ],
weeks: ["week", "day"],
days: ["day", "day"],
I am not saying the expectation in the test are wrong, but it is way too difficult to figure out which come from where. Could we at least denote where those "dateUntil" got called as expected in a comment (such as from ToRelativeTemporalObject / UnbalanceDurationRelative / RoundDuration / AdjustRoundedDurationDays / BalanceDurationRelative / MoveRelativeZonedDateTime or BalanceDuration in 7.3.20 Temporal.Duration.prototype.round ( options )
Right now as how the test is written, I cannot easily justify the test expectation is either correct or incorrect. It is just way too hard to tell.
Here is my trace of calling dateUntil with the case of "years":
start UnbalanceDurationRelative
end UnbalanceDurationRelative
start RoundDuration
end RoundDuration
start AdjustRoundedDurationDays
Calendar.prototype.dateUntil largestUnit = 'year'
Calendar.prototype.dateUntil largestUnit = 'day'
end AdjustRoundedDurationDays
start BalanceDurationRelative
Calendar.prototype.dateUntil largestUnit = 'month'
end BalanceDurationRelative
start MoveRelativeZonedDateTime
end MoveRelativeZonedDateTime
start BalanceDuration
end BalanceDuration
Here is my trace of calling dateUntil with the case of "months":
start UnbalanceDurationRelative
end UnbalanceDurationRelative
start RoundDuration
end RoundDuration
start AdjustRoundedDurationDays
Calendar.prototype.dateUntil largestUnit = "month"
Calendar.prototype.dateUntil largestUnit = "day"
end AdjustRoundedDurationDays
start BalanceDurationRelative
end BalanceDurationRelative
start MoveRelativeZonedDateTime
end MoveRelativeZonedDateTime
start BalanceDuration
end BalanceDuration
Here is my trace of calling dateUntil with the case of "weeks":
start UnbalanceDurationRelative
end UnbalanceDurationRelative
start RoundDuration
end RoundDuration
start AdjustRoundedDurationDays
Calendar.prototype.dateUntil largestUnit = "week"
Calendar.prototype.dateUntil largestUnit = "day"
end AdjustRoundedDurationDays
start BalanceDurationRelative
end BalanceDurationRelative
start MoveRelativeZonedDateTime
end MoveRelativeZonedDateTime
start BalanceDuration
end BalanceDuration
Here is my trace of calling dateUntil with the case of "days":
start UnbalanceDurationRelative
end UnbalanceDurationRelative
start RoundDuration
end RoundDuration
start AdjustRoundedDurationDays
Calendar.prototype.dateUntil largestUnit = "day"
Calendar.prototype.dateUntil largestUnit = "day"
end AdjustRoundedDurationDays
start BalanceDurationRelative
end BalanceDurationRelative
start MoveRelativeZonedDateTime
end MoveRelativeZonedDateTime
start BalanceDuration
end BalanceDuration
Could someone help me out where is the last "day" in the expectation should come from?
@ptomato @Ms2ger @jugglinmike @ryzokuken
I tried to describe where these calls come from in the comment before that block: https://github.com/tc39/test262/blob/main/test/built-ins/Temporal/Duration/prototype/round/calendar-dateuntil-called-with-singular-largestunit.js#L79-L86, and in the info block it shows which algorithm paths to consider.
So, for example, I think in the case of
const duration = new Temporal.Duration(0, 0, 0, 0, 0, 0, 0, 0, 0, 86399_999_999_999);
const relativeTo = new Temporal.ZonedDateTime(0n, "UTC", calendar);
duration.round({ largestUnit: 'day', roundingIncrement: 2, roundingMode: 'ceil', relativeTo });
I believe the three calls are through these paths:
- Temporal.Duration.prototype.round
- AdjustRoundedDurationDays
- AddDuration
- DifferenceZonedDateTime
- DifferenceISODateTime calls it once
- NanosecondsToDays
- DifferenceISODateTime calls it a second time
- DifferenceZonedDateTime
- AddDuration
- BalanceDuration
- NanosecondsToDays
- DifferenceISODateTime calls it a third time
- NanosecondsToDays
- AdjustRoundedDurationDays