Debian Codegraph @

js/src/tests/test262/intl402/Locale/constructor-options-calendar-valid.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 14. Let calendar be ? GetOption(options, "calendar", "string", undefined, undefined).
14 ...
15
16 features: [Intl.Locale]
17 ---*/
18
19 const validCalendarOptions = [
20 ["abc", "en-u-ca-abc"],
21 ["abcd", "en-u-ca-abcd"],
22 ["abcde", "en-u-ca-abcde"],
23 ["abcdef", "en-u-ca-abcdef"],
24 ["abcdefg", "en-u-ca-abcdefg"],
25 ["abcdefgh", "en-u-ca-abcdefgh"],
26 ["12345678", "en-u-ca-12345678"],
27 ["1234abcd", "en-u-ca-1234abcd"],
28 ["1234abcd-abc123", "en-u-ca-1234abcd-abc123"],
29 ];
30 for (const [calendar, expected] of validCalendarOptions) {
31 assert.sameValue(
32 new Intl.Locale('en', { calendar }).toString(),
33 expected,
34 `new Intl.Locale('en', { calendar: "${calendar}" }).toString() returns "${expected}"`
35 );
36 assert.sameValue(
37 new Intl.Locale('en-u-ca-gregory', { calendar }).toString(),
38 expected,
39 `new Intl.Locale('en-u-ca-gregory', { calendar: "${calendar}" }).toString() returns "${expected}"`
40 );
41 }
42
43 reportCompare(0, 0);