aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite/intl402/ch12/12.2/12.2.3_c.js
diff options
context:
space:
mode:
authorNorbert Lindenberg <ecmascript@lindenbergsoftware.com>2012-08-26 20:50:24 -0700
committerNorbert Lindenberg <ecmascript@lindenbergsoftware.com>2012-08-26 20:50:24 -0700
commitd71ffa59d5fa2df454bf1c1853b0ccfc87fe3bcd (patch)
tree79aed459cf2d8f9d26f8e0ece825d5e20b1d4650 /test/suite/intl402/ch12/12.2/12.2.3_c.js
parent1af24250750e0a4318ec8efb467245fa0e86c215 (diff)
Added new tests for chapters 10 to 13 of the ECMAScript Internationalization API Specification.
Diffstat (limited to 'test/suite/intl402/ch12/12.2/12.2.3_c.js')
-rw-r--r--test/suite/intl402/ch12/12.2/12.2.3_c.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/suite/intl402/ch12/12.2/12.2.3_c.js b/test/suite/intl402/ch12/12.2/12.2.3_c.js
new file mode 100644
index 000000000..0aced6ca9
--- /dev/null
+++ b/test/suite/intl402/ch12/12.2/12.2.3_c.js
@@ -0,0 +1,52 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/**
+ * @description Tests that Intl.DateTimeFormat provides the required date-time
+ * format component subsets.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+var locales = ["de-DE", "en-US", "hi-IN", "id-ID", "ja-JP", "th-TH", "zh-Hans-CN", "zh-Hant-TW", "zxx"];
+var subsets = [
+ {weekday: "long", year: "numeric", month: "numeric", day: "numeric",
+ hour: "numeric", minute: "numeric", second: "numeric"},
+ {weekday: "long", year: "numeric", month: "numeric", day: "numeric"},
+ {year: "numeric", month: "numeric", day: "numeric"},
+ {year: "numeric", month: "numeric"},
+ {month: "numeric", day: "numeric"},
+ {hour: "numeric", minute: "numeric", second: "numeric"},
+ {hour: "numeric", minute: "numeric"}
+];
+
+locales.forEach(function (locale) {
+ subsets.forEach(function (subset) {
+ var format = new Intl.DateTimeFormat([locale], subset);
+ var actual = format.resolvedOptions();
+ getDateTimeComponents().forEach(function (component) {
+ if (actual.hasOwnProperty(component)) {
+ if (!subset.hasOwnProperty(component)) {
+ $ERROR("Unrequested component " + component +
+ " added to requested subset " + JSON.stringify(subset) +
+ "; locale " + locale + ".");
+ }
+ try {
+ testValidDateTimeComponentValue(component, actual[component]);
+ } catch (e) {
+ e.message += " (Testing locale " + locale + "; subset " +
+ JSON.stringify(subset) + ")";
+ throw e;
+ }
+ } else {
+ if (subset.hasOwnProperty(component)) {
+ $ERROR("Missing component " + component +
+ " from requested subset " + JSON.stringify(subset) +
+ "; locale " + locale + ".");
+ }
+ }
+ });
+ });
+});
+