Debian Codegraph @

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

raw
1 // Copyright 2018 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-intl.locale
6 description: >
7 Checks error cases for the options argument to the Locale
8 constructor.
9 info: |
10 Intl.Locale( tag [, options] )
11
12 ...
13 15. If calendar is not undefined, then
14 a. If calendar does not match the [(3*8alphanum) *("-" (3*8alphanum))] sequence, throw a RangeError exception.
15 16. Set opt.[[ca]] to calendar.
16
17 features: [Intl.Locale]
18 ---*/
19
20
21 /*
22 alphanum = (ALPHA / DIGIT) ; letters and numbers
23 calendar = (3*8alphanum) *("-" (3*8alphanum))
24 */
25 const invalidCalendarOptions = [
26 "",
27 "a",
28 "ab",
29 "abcdefghi",
30 "abc-abcdefghi",
31 ];
32 for (const calendar of invalidCalendarOptions) {
33 assert.throws(RangeError, function() {
34 new Intl.Locale("en", {calendar});
35 }, `new Intl.Locale("en", {calendar: "${calendar}"}) throws RangeError`);
36 }
37
38 reportCompare(0, 0);