constructor-options-localeMatcher-invalid.js (855B)
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 localeMatcher option to the DurationFormat constructor. 7 info: | 8 Intl.DurationFormat ( [ locales [ , options ] ] ) 9 (...) 10 5. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). 11 features: [Intl.DurationFormat] 12 ---*/ 13 14 const invalidOptions = [ 15 null, 16 1, 17 "", 18 "Lookup", 19 "LOOKUP", 20 "lookup\0", 21 "Best fit", 22 "BEST FIT", 23 "best\u00a0fit", 24 ]; 25 26 for (const localeMatcher of invalidOptions) { 27 assert.throws(RangeError, function() { 28 new Intl.DurationFormat([], { localeMatcher }); 29 }, `${localeMatcher} is an invalid localeMatcher option value`); 30 } 31 32 reportCompare(0, 0);