summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/formatToParts-style-default-en.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/formatToParts/formatToParts-style-default-en.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/formatToParts/formatToParts-style-default-en.js')
-rw-r--r--js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/formatToParts-style-default-en.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/formatToParts-style-default-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/formatToParts-style-default-en.js
new file mode 100644
index 0000000000..03b16dc627
--- /dev/null
+++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/formatToParts-style-default-en.js
@@ -0,0 +1,47 @@
+// |reftest| skip -- Intl.DurationFormat is not supported
+// Copyright (C) 2023 Igalia S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-Intl.DurationFormat.prototype.formatToParts
+description: Checks basic handling of formatToParts, using long, short,narrow and digital styles.
+includes: [testIntl.js]
+features: [Intl.DurationFormat]
+---*/
+
+// Utils functions
+function* zip(a, b) {
+ for (let i = 0; i < a.length; ++i) {
+ yield [i, a[i], b[i]];
+ }
+}
+
+function compare(actual, expected, message) {
+ assert.sameValue(Array.isArray(expected), true, `${message}: expected is Array`);
+ assert.sameValue(Array.isArray(actual), true, `${message}: actual is Array`);
+ assert.sameValue(actual.length, expected.length, `${message}: length`);
+
+ for (const [i, actualEntry, expectedEntry] of zip(actual, expected)) {
+ // assertions
+ assert.sameValue(actualEntry.type, expectedEntry.type, `type for entry ${i}`);
+ assert.sameValue(actualEntry.value, expectedEntry.value, `value for entry ${i}`);
+ if (expectedEntry.unit) {
+ assert.sameValue(actualEntry.unit, expectedEntry.unit, `unit for entry ${i}`);
+ }
+ }
+}
+const duration = {
+ hours: 7,
+ minutes: 8,
+ seconds: 9,
+ milliseconds: 123,
+ microseconds: 456,
+ nanoseconds: 789,
+};
+
+const expected = partitionDurationFormatPattern(duration);
+
+let df = new Intl.DurationFormat('en');
+compare(df.formatToParts(duration), expected, `Using style : default`);
+
+reportCompare(0, 0);