summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js')
-rw-r--r--js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js
new file mode 100644
index 0000000000..dc5ad4ea84
--- /dev/null
+++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js
@@ -0,0 +1,44 @@
+// |reftest| skip -- Intl.DurationFormat is not supported
+// Copyright (C) 2023 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-Intl.DurationFormat.prototype.format
+description: >
+ The correct separator is used for numeric hours with zero minutes and non-zero seconds.
+locale: [en-US]
+features: [Intl.DurationFormat]
+---*/
+
+const df = new Intl.DurationFormat("en", {
+ // hours must be numeric, so that a time separator is used for the following units.
+ hours: "numeric",
+});
+
+const lf = new Intl.ListFormat("en", {
+ type: "unit",
+ style: "short",
+});
+
+const duration = {
+ hours: 1,
+
+ // Minutes is omitted from the output when its value is zero.
+ minutes: 0,
+
+ // Either seconds or sub-seconds must be non-zero.
+ seconds: 3,
+};
+
+const expected = lf.format([
+ new Intl.NumberFormat("en", {minimumIntegerDigits: 1}).format(duration.hours),
+ new Intl.NumberFormat("en", {minimumIntegerDigits: 2}).format(duration.seconds),
+]);
+
+assert.sameValue(
+ df.format(duration),
+ expected,
+ `No time separator is used when minutes is zero`
+);
+
+reportCompare(0, 0);