Debian Codegraph @

js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-localeMatcher-invalid.js

raw
1 // |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
2 // Copyright 2018 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-Intl.Segmenter.supportedLocalesOf
7 description: Checks handling of invalid values for the localeMatcher option to the supportedLocalesOf function.
8 info: |
9 SupportedLocales ( availableLocales, requestedLocales, options )
10
11 1. If options is not undefined, then
12 b. Let matcher be ? GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit").
13 features: [Intl.Segmenter]
14 ---*/
15
16 assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function",
17 "Should support Intl.Segmenter.supportedLocalesOf.");
18
19 const invalidOptions = [
20 null,
21 1,
22 "",
23 "Lookup",
24 "LOOKUP",
25 "lookup\0",
26 "Best fit",
27 "BEST FIT",
28 "best\u00a0fit",
29 ];
30
31 for (const invalidOption of invalidOptions) {
32 assert.throws(RangeError, function() {
33 Intl.Segmenter.supportedLocalesOf([], {"localeMatcher": invalidOption});
34 }, `${invalidOption} is an invalid localeMatcher option value`);
35 }
36
37 reportCompare(0, 0);