Debian Codegraph @

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

raw
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.RelativeTimeFormat.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.RelativeTimeFormat]
13 ---*/
14
15 assert.sameValue(typeof Intl.RelativeTimeFormat.supportedLocalesOf, "function",
16 "Should support Intl.RelativeTimeFormat.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.RelativeTimeFormat.supportedLocalesOf([], {"localeMatcher": invalidOption});
33 }, `${invalidOption} is an invalid localeMatcher option value`);
34 }
35
36 reportCompare(0, 0);