Debian Codegraph @

js/src/tests/test262/intl402/DurationFormat/constructor-options-numberingSystem-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: >
8 Checks error cases for the options argument to the DurationFormat constructor.
9 info: |
10 Intl.DurationFormat ( [ locales [ , options ] ] )
11 (...)
12 6. Let numberingSystem be ? GetOption(options, "numberingSystem", "string", undefined, undefined).
13 7. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception.
14 features: [Intl.DurationFormat]
15 ---*/
16
17 const invalidOptions = [
18 "",
19 "a",
20 "ab",
21 "abcdefghi",
22 "abc-abcdefghi",
23 "!invalid!",
24 "-latn-",
25 "latn-",
26 "latn--",
27 "latn-ca",
28 "latn-ca-",
29 "latn-ca-gregory",
30 "latné",
31 "latn编号",
32 ];
33 for (const numberingSystem of invalidOptions) {
34 assert.throws(RangeError, function() {
35 new Intl.DurationFormat('en', {numberingSystem});
36 }, `new Intl.DurationFormat("en", {numberingSystem: "${numberingSystem}"}) throws RangeError`);
37 }
38
39 reportCompare(0, 0);