diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/formatToParts-style-long-en.js | |
parent | Initial commit. (diff) | |
download | firefox-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-long-en.js')
-rw-r--r-- | js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/formatToParts-style-long-en.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/formatToParts-style-long-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/formatToParts-style-long-en.js new file mode 100644 index 0000000000..a54ddb61f8 --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/formatToParts-style-long-en.js @@ -0,0 +1,49 @@ +// |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 style = "long"; + +const expected = partitionDurationFormatPattern(duration, style); + +let df = new Intl.DurationFormat('en', { style }); +compare(df.formatToParts(duration), expected, `Using style : ${style}`); + +reportCompare(0, 0); |