From febf246e059a6cd110c4a89776d133abdcb86387 Mon Sep 17 00:00:00 2001 From: Ben Allen Date: Tue, 15 Oct 2024 12:10:46 -0700 Subject: [PATCH] DurationFormat: Add tests for durations with large hour/minute/second unit values while using digital style Grouping separators suppressed in this situation. See tc39/proposal-intl-duration-format/pull/198 --- .../format/style-digital-large-hms-values.js | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/intl402/DurationFormat/prototype/format/style-digital-large-hms-values.js diff --git a/test/intl402/DurationFormat/prototype/format/style-digital-large-hms-values.js b/test/intl402/DurationFormat/prototype/format/style-digital-large-hms-values.js new file mode 100644 index 0000000000..d050180581 --- /dev/null +++ b/test/intl402/DurationFormat/prototype/format/style-digital-large-hms-values.js @@ -0,0 +1,42 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-formatnumericunits +description: > + Test to ensure that grouping separators are suppressed when formatting Durations with /hour, minute, and second values while using digital style. + +info: | + 1.1.12 FormatNumericUnits ( durationFormat, duration, firstNumericUnit, signDisplayed ) + + 16. If hoursFormatted is true, then + ... + b. Append FormatNumericHours ( durationFormat, hoursValue, signDisplayed ) to numericPartsList. + 17. If minutesFormatted is true, then + ... + b. Append FormatNumericMinutes ( durationFormat, minutesValue, hoursFormatted, signDisplayed ) to numericPartsList. + 18. If secondsFormatted is true, then + a. Append FormatNumericSeconds ( durationFormat, secondsValue, minutesFormatted, signDisplayed ) to numericPartsList. + + 1.1.9 FormatNumericHours ( durationFormat, hoursValue, signDisplayed ) + ... + 9. Perform ! CreateDataPropertyOrThrow(nfOpts, "useGrouping", false). + + 1.1.10 FormatNumericMinutes (durationFormat, minutesValue, hoursDisplayed, signDisplayed) + ... + 10. Perform ! CreateDataPropertyOrThrow(nfOpts, "useGrouping", false). + + 1.1.11 FormatNumericSeconds ( durationFormat, secondsValue, minutesDisplayed, signDisplayed ) + ... + 10. Perform ! CreateDataPropertyOrThrow(nfOpts, "useGrouping", false). + +locale: [en] +features: [Intl.DurationFormat] +---*/ + +const locale = "en"; +const duration = {hours: 1234, minutes: 1234567, seconds: 12345678}; + +let df = new Intl.DurationFormat(locale, {style: "digital"}); + +assert.sameValue(df.format(duration), "1234:1234567:12345678", `failed to suppress grouping separator using digital style`);