Debian Codegraph @

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

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