1 // |reftest| skip -- Intl.DurationFormat is not supported
2 // Copyright (C) 2023 André Bargull. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
6 esid: sec-Intl.DurationFormat.prototype.formatToParts
8 Test formatToParts method with negative duration and "digital" style
10 includes: [testIntl.js]
11 features: [Intl.DurationFormat]
14 function compare(actual, expected, message) {
15 assert.sameValue(Array.isArray(expected), true, `${message}: expected is Array`);
16 assert.sameValue(Array.isArray(actual), true, `${message}: actual is Array`);
17 assert.sameValue(actual.length, expected.length, `${message}: length`);
19 for (let i = 0; i < expected.length; ++i) {
20 let actualEntry = actual[i];
21 let expectedEntry = expected[i];
23 assert.sameValue(actualEntry.type, expectedEntry.type, `type for entry ${i}`);
24 assert.sameValue(actualEntry.value, expectedEntry.value, `value for entry ${i}`);
25 assert.sameValue("unit" in actualEntry, "unit" in expectedEntry, `unit for entry ${i}`);
26 if ("unit" in expectedEntry) {
27 assert.sameValue(actualEntry.unit, expectedEntry.unit, `unit for entry ${i}`);
32 const style = "digital";
47 const expected = partitionDurationFormatPattern(duration, style);
49 const df = new Intl.DurationFormat("en", { style });
50 compare(df.formatToParts(duration), expected, `Using style : ${style}`);