test262
test262 copied to clipboard
Update Intl.DurationFormat tests
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
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.
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:
- 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
- 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