|
1 // Copyright 2012 Mozilla Corporation. All rights reserved. |
|
2 // This code is governed by the license found in the LICENSE file. |
|
3 |
|
4 /** |
|
5 * @description Tests that the object returned by Intl.DateTimeFormat.prototype.resolvedOptions |
|
6 * has the right properties. |
|
7 * @author Norbert Lindenberg |
|
8 */ |
|
9 |
|
10 $INCLUDE("testIntl.js"); |
|
11 |
|
12 var actual = new Intl.DateTimeFormat().resolvedOptions(); |
|
13 |
|
14 var actual2 = new Intl.DateTimeFormat().resolvedOptions(); |
|
15 if (actual2 === actual) { |
|
16 $ERROR("resolvedOptions returned the same object twice."); |
|
17 } |
|
18 |
|
19 // source: CLDR file common/bcp47/calendar.xml; version CLDR 21. |
|
20 var calendars = [ |
|
21 "buddhist", |
|
22 "chinese", |
|
23 "coptic", |
|
24 "ethioaa", |
|
25 "ethiopic", |
|
26 "gregory", |
|
27 "hebrew", |
|
28 "indian", |
|
29 "islamic", |
|
30 "islamicc", |
|
31 "iso8601", |
|
32 "japanese", |
|
33 "persian", |
|
34 "roc" |
|
35 ]; |
|
36 |
|
37 // this assumes the default values where the specification provides them |
|
38 mustHaveProperty(actual, "locale", isCanonicalizedStructurallyValidLanguageTag); |
|
39 mustHaveProperty(actual, "calendar", calendars); |
|
40 mustHaveProperty(actual, "numberingSystem", isValidNumberingSystem); |
|
41 mustHaveProperty(actual, "timeZone", [undefined]); |
|
42 mustNotHaveProperty(actual, "weekday"); |
|
43 mustNotHaveProperty(actual, "era"); |
|
44 mustHaveProperty(actual, "year", ["2-digit", "numeric"]); |
|
45 mustHaveProperty(actual, "month", ["2-digit", "numeric", "narrow", "short", "long"]); |
|
46 mustHaveProperty(actual, "day", ["2-digit", "numeric"]); |
|
47 mustNotHaveProperty(actual, "hour"); |
|
48 mustNotHaveProperty(actual, "minute"); |
|
49 mustNotHaveProperty(actual, "second"); |
|
50 mustNotHaveProperty(actual, "timeZoneName"); |
|
51 mustNotHaveProperty(actual, "hour12"); |
|
52 |