options-localeMatcher-invalid.js (1083B)
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.Segmenter.supportedLocalesOf 6 description: Checks handling of invalid values for the localeMatcher option to the supportedLocalesOf function. 7 info: | 8 SupportedLocales ( availableLocales, requestedLocales, options ) 9 10 1. If options is not undefined, then 11 b. Let matcher be ? GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit"). 12 features: [Intl.Segmenter] 13 ---*/ 14 15 assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function", 16 "Should support Intl.Segmenter.supportedLocalesOf."); 17 18 const invalidOptions = [ 19 null, 20 1, 21 "", 22 "Lookup", 23 "LOOKUP", 24 "lookup\0", 25 "Best fit", 26 "BEST FIT", 27 "best\u00a0fit", 28 ]; 29 30 for (const invalidOption of invalidOptions) { 31 assert.throws(RangeError, function() { 32 Intl.Segmenter.supportedLocalesOf([], {"localeMatcher": invalidOption}); 33 }, `${invalidOption} is an invalid localeMatcher option value`); 34 } 35 36 reportCompare(0, 0);