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