Debian Codegraph @

js/src/tests/test262/intl402/DateTimeFormat/constructor-options-calendar-invalid.js

raw
1 // Copyright 2020 André Bargull; 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-createdatetimeformat
6 description: >
7 Checks error cases for the options argument to the DateTimeFormat constructor.
8 info: |
9 CreateDateTimeFormat ( dateTimeFormat, locales, options, required, defaults )
10
11 ...
12 8. If calendar is not undefined, then
13 a. If calendar does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception.
14 ---*/
15
16 /*
17 alphanum = (ALPHA / DIGIT) ; letters and numbers
18 numberingSystem = (3*8alphanum) *("-" (3*8alphanum))
19 */
20 const invalidCalendarOptions = [
21 "",
22 "a",
23 "ab",
24 "abcdefghi",
25 "abc-abcdefghi",
26 "!invalid!",
27 "-gregory-",
28 "gregory-",
29 "gregory--",
30 "gregory-nu",
31 "gregory-nu-",
32 "gregory-nu-latn",
33 "gregoryé",
34 "gregory역법",
35 ];
36 for (const calendar of invalidCalendarOptions) {
37 assert.throws(RangeError, function() {
38 new Intl.DateTimeFormat('en', {calendar});
39 }, `new Intl.DateTimeFormat("en", {calendar: "${calendar}"}) throws RangeError`);
40 }
41
42 reportCompare(0, 0);