js/src/tests/test262/intl402/ch12/12.2/12.2.3_c.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 // Copyright 2012 Mozilla Corporation. All rights reserved.
     2 // This code is governed by the license found in the LICENSE file.
     4 /**
     5  * @description Tests that Intl.DateTimeFormat provides the required date-time
     6  *     format component subsets.
     7  * @author Norbert Lindenberg
     8  */
    10 $INCLUDE("testIntl.js");
    12 var locales = ["de-DE", "en-US", "hi-IN", "id-ID", "ja-JP", "th-TH", "zh-Hans-CN", "zh-Hant-TW", "zxx"];
    13 var subsets = [
    14     {weekday: "long", year: "numeric", month: "numeric", day: "numeric",
    15         hour: "numeric", minute: "numeric", second: "numeric"},
    16     {weekday: "long", year: "numeric", month: "numeric", day: "numeric"},
    17     {year: "numeric", month: "numeric", day: "numeric"},
    18     {year: "numeric", month: "numeric"},
    19     {month: "numeric", day: "numeric"},
    20     {hour: "numeric", minute: "numeric", second: "numeric"},
    21     {hour: "numeric", minute: "numeric"}
    22 ];
    24 locales.forEach(function (locale) {
    25     subsets.forEach(function (subset) {
    26         var format = new Intl.DateTimeFormat([locale], subset);
    27         var actual = format.resolvedOptions();
    28         getDateTimeComponents().forEach(function (component) {
    29             if (actual.hasOwnProperty(component)) {
    30                 if (!subset.hasOwnProperty(component)) {
    31                     $ERROR("Unrequested component " + component +
    32                         " added to requested subset " + JSON.stringify(subset) +
    33                         "; locale " + locale + ".");
    34                 }
    35                 try {
    36                     testValidDateTimeComponentValue(component, actual[component]);
    37                 } catch (e) {
    38                     e.message += " (Testing locale " + locale + "; subset " +
    39                         JSON.stringify(subset) + ")";
    40                     throw e;
    41                 }
    42             } else {
    43                 if (subset.hasOwnProperty(component)) {
    44                     $ERROR("Missing component " + component +
    45                         " from requested subset " + JSON.stringify(subset) +
    46                         "; locale " + locale + ".");
    47                 }
    48             }
    49         });
    50     });
    51 });

mercurial