constructor-options-style-invalid.js (967B)
1 // Copyright 2022 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: Checks handling of invalid value for the style option to the DurationFormat constructor. 7 info: | 8 InitializeDurationFormat (DurationFormat, locales, options) 9 (...) 10 13. Let style be ? GetOption(options, "style", "string", « "long", "short", "narrow", "digital" », "long"). 11 14. Set durationFormat.[[Style]] to style. 12 features: [Intl.DurationFormat] 13 ---*/ 14 15 const invalidOptions = [ 16 null, 17 1, 18 "", 19 "Long", 20 "LONG", 21 "long\0", 22 "Short", 23 "SHORT", 24 "short\0", 25 "Narrow", 26 "NARROW", 27 "narrow\0", 28 "Digital", 29 "DIGITAL", 30 "digital\0", 31 ]; 32 33 for (const invalidOption of invalidOptions) { 34 assert.throws(RangeError, function() { 35 new Intl.DurationFormat([], {"style": invalidOption}); 36 }, `${invalidOption} is an invalid style option value`); 37 } 38 39 reportCompare(0, 0);