test262 icon indicating copy to clipboard operation
test262 copied to clipboard

Update Intl.DurationFormat tests

Open anba opened this issue 1 year ago • 1 comments

Update Intl.DurationFormat tests to match the current draft spec and add tests to cover:

  • https://github.com/tc39/proposal-intl-duration-format/pull/183
  • https://github.com/tc39/proposal-intl-duration-format/pull/184

anba avatar Jan 09 '24 11:01 anba

Nonetheless I would suggest that numeric-hour-with-zero-minutes-and-non-zero-seconds.js was clearer using NumberFormat and ListFormat directly, as it previously did, so maybe we should drop the commit ' Use formatDurationFormatPattern for "/numeric-hour-with-zero-minutes-and-non-zero-seconds"'.

This isn't actually possible, because of https://github.com/tc39/proposal-intl-duration-format/pull/180. Before that PR, the test expected the string "1, 03", so the hours and seconds duration units were number-formatted and then concatenated through the list formatter. After the PR, the expected string is "1:00:03", so the list formatter is no longer used at all. The only alternative here is to hardcode the string "1:00:03" as the expected result and don't use a number nor a list formatter.

anba avatar Jan 19 '24 09:01 anba

With regard to the "numeric-hour-with-zero-minutes-and-non-zero-seconds" question: in recent tests involving digital-like styles (see: https://github.com/tc39/test262/pull/4034) I've been handling them by stitching together the unit values with ":" as a hard-coded separator. My theory is that this is slightly better than using a fully hard-coded string, since:

  1. Tests written this way could in the future be used to test in other locales that also use ":" as the hours/minutes and minutes/seconds separators, but that use different numbering systems
  2. It makes it relatively simpler to (in the somewhat more distant future) draw from the new [[HoursMinutesSeparator]], and [[MinutesSecondsSeparator]] slots from https://github.com/tc39/proposal-intl-duration-format/pull/188

ben-allen avatar Apr 11 '24 20:04 ben-allen