constructor-options-hourcycle-invalid.js (1049B)
1 // Copyright 2018 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.locale 6 description: > 7 Checks error cases for the options argument to the Locale constructor. 8 info: | 9 Intl.Locale( tag [, options] ) 10 11 ... 12 20. Let hc be ? GetOption(options, "hourCycle", "string", « "h11", "h12", "h23", "h24" », undefined). 13 ... 14 15 GetOption ( options, property, type, values, fallback ) 16 ... 17 2. d. If values is not undefined, then 18 i. If values does not contain an element equal to value, throw a RangeError exception. 19 ... 20 features: [Intl.Locale] 21 ---*/ 22 23 24 const invalidHourCycleOptions = [ 25 "", 26 "h", 27 "h00", 28 "h01", 29 "h10", 30 "h13", 31 "h22", 32 "h25", 33 "h48", 34 "h012", 35 "h120", 36 "h12\0", 37 "H12", 38 ]; 39 for (const hourCycle of invalidHourCycleOptions) { 40 assert.throws(RangeError, function() { 41 new Intl.Locale("en", {hourCycle}); 42 }, `new Intl.Locale("en", {hourCycle: "${hourCycle}"}) throws RangeError`); 43 } 44 45 reportCompare(0, 0);