| 1 |
// |reftest| skip-if(!Intl.hasOwnProperty('DurationFormat')) -- Intl.DurationFormat is not enabled unconditionally |
| 2 |
// Copyright 2024 Igalia, S.L. All rights reserved. |
| 3 |
// This code is governed by the BSD license found in the LICENSE file. |
| 4 |
|
| 5 |
/*--- |
| 6 |
esid: sec-Intl.DurationFormat |
| 7 |
description: Verifies that default style settings for units following units with "numeric" or "2-digit" style are honored. |
| 8 |
info: | |
| 9 |
GetDurationUnitOptions (unit, options, baseStyle, stylesList, digitalBase, prevStyle) |
| 10 |
(...) |
| 11 |
3. If style is undefined, then |
| 12 |
(...) |
| 13 |
i. If prevStyle is "fractional", "numeric" or "2-digit", then |
| 14 |
(...) |
| 15 |
2. Set style to "numeric". |
| 16 |
(...) |
| 17 |
9. If prevStyle is "numeric" or "2-digit", then |
| 18 |
(...) |
| 19 |
b. If unit is "minutes" or "seconds", then |
| 20 |
i. Set style to "2-digit". |
| 21 |
features: [Intl.DurationFormat] |
| 22 |
---*/ |
| 23 |
|
| 24 |
for (const numericLikeStyle of ["numeric", "2-digit"]){ |
| 25 |
var opts = new Intl.DurationFormat([], {hours: numericLikeStyle}).resolvedOptions(); |
| 26 |
|
| 27 |
assert.sameValue(opts.minutes, "2-digit", `minutes default value should be '2-digit' when following any ${numericLikeStyle}-styled unit`); |
| 28 |
assert.sameValue(opts.seconds, "2-digit", `seconds default value should be '2-digit' when following any ${numericLikeStyle}-styled unit`); |
| 29 |
assert.sameValue(opts.milliseconds, "numeric", `milliseconds default value should be 'numeric' when following any ${numericLikeStyle}-styled unit`); |
| 30 |
assert.sameValue(opts.microseconds, "numeric", `microseconds default value should be 'numeric' when following any ${numericLikeStyle}-styled unit`); |
| 31 |
assert.sameValue(opts.nanoseconds, "numeric", `nanoseconds default value should be 'numeric' when following any ${numericLikeStyle}-styled unit`); |
| 32 |
} |
| 33 |
|
| 34 |
reportCompare(0, 0); |