From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../prototype/format/mixed-short-and-numeric.js | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-short-and-numeric.js (limited to 'js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-short-and-numeric.js') diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-short-and-numeric.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-short-and-numeric.js new file mode 100644 index 0000000000..19adbfbd47 --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-short-and-numeric.js @@ -0,0 +1,37 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.format +description: Checks that durations containing a mixture of numericlike and non-numericlike styles are formatted using the "short" style when DurationFormat base style is *undefined*. +info: | + PartitionDurationFormatPattern ( durationFormat, duration ) + + 12. Let listStyle be durationFormat.[[Style]]. + (...) + 14. Perform ! CreateDataPropertyOrThrow(lfOpts, "style", listStyle). + +locale: [en] +features: [Intl.DurationFormat] +---*/ + +const locale = "en"; +const timeSeparator = ":"; + + +let d = {days: 5, hours: 1, minutes: 2, seconds: 3}; +let dfOpts = {minutes: "numeric", seconds: "numeric"}; + +let expectedList = []; +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "day", unitDisplay: "short"}).format(d.days)); +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "hour", unitDisplay: "short"}).format(d.hours)); +expectedList.push(new Intl.NumberFormat(locale).format(d.minutes) + timeSeparator + new Intl.NumberFormat(locale, {minimumIntegerDigits: 2}).format(d.seconds)); + +let expected = new Intl.ListFormat(locale, {style: "short"}).format(expectedList); +let actual = new Intl.DurationFormat(locale, dfOpts).format(d); + +assert.sameValue(actual, expected); + + +reportCompare(0, 0); -- cgit v1.2.3