diff options
Diffstat (limited to 'js/src/tests/test262/intl402/ch12/12.2')
-rw-r--r-- | js/src/tests/test262/intl402/ch12/12.2/12.2.1.js | 22 | ||||
-rw-r--r-- | js/src/tests/test262/intl402/ch12/12.2/12.2.2_L15.js | 14 | ||||
-rw-r--r-- | js/src/tests/test262/intl402/ch12/12.2/12.2.2_a.js | 28 | ||||
-rw-r--r-- | js/src/tests/test262/intl402/ch12/12.2/12.2.2_b.js | 13 | ||||
-rw-r--r-- | js/src/tests/test262/intl402/ch12/12.2/12.2.3_b.js | 47 | ||||
-rw-r--r-- | js/src/tests/test262/intl402/ch12/12.2/12.2.3_c.js | 52 | ||||
-rw-r--r-- | js/src/tests/test262/intl402/ch12/12.2/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/test262/intl402/ch12/12.2/shell.js | 0 |
8 files changed, 176 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/ch12/12.2/12.2.1.js b/js/src/tests/test262/intl402/ch12/12.2/12.2.1.js new file mode 100644 index 000000000..3590c0a9d --- /dev/null +++ b/js/src/tests/test262/intl402/ch12/12.2/12.2.1.js @@ -0,0 +1,22 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/** + * @description Tests that Intl.DateTimeFormat.prototype has the required attributes. + * @author Norbert Lindenberg + */ + +var desc = Object.getOwnPropertyDescriptor(Intl.DateTimeFormat, "prototype"); +if (desc === undefined) { + $ERROR("Intl.DateTimeFormat.prototype is not defined."); +} +if (desc.writable) { + $ERROR("Intl.DateTimeFormat.prototype must not be writable."); +} +if (desc.enumerable) { + $ERROR("Intl.DateTimeFormat.prototype must not be enumerable."); +} +if (desc.configurable) { + $ERROR("Intl.DateTimeFormat.prototype must not be configurable."); +} + diff --git a/js/src/tests/test262/intl402/ch12/12.2/12.2.2_L15.js b/js/src/tests/test262/intl402/ch12/12.2/12.2.2_L15.js new file mode 100644 index 000000000..8b21df1fd --- /dev/null +++ b/js/src/tests/test262/intl402/ch12/12.2/12.2.2_L15.js @@ -0,0 +1,14 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/** + * @description Tests that Intl.DateTimeFormat.supportedLocalesOf + * meets the requirements for built-in objects defined by the introduction of + * chapter 15 of the ECMAScript Language Specification. + * @author Norbert Lindenberg + */ + +$INCLUDE("testBuiltInObject.js"); + +testBuiltInObject(Intl.DateTimeFormat.supportedLocalesOf, true, false, [], 1); + diff --git a/js/src/tests/test262/intl402/ch12/12.2/12.2.2_a.js b/js/src/tests/test262/intl402/ch12/12.2/12.2.2_a.js new file mode 100644 index 000000000..42eedc0a1 --- /dev/null +++ b/js/src/tests/test262/intl402/ch12/12.2/12.2.2_a.js @@ -0,0 +1,28 @@ +// Copyright 2012 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @description Tests that Intl.DateTimeFormat has a supportedLocalesOf + * property, and it works as planned. + * @author: Roozbeh Pournader + */ + +var defaultLocale = new Intl.DateTimeFormat().resolvedOptions().locale; +var notSupported = 'zxx'; // "no linguistic content" +var requestedLocales = [defaultLocale, notSupported]; + +var supportedLocales; + +if (!Intl.DateTimeFormat.hasOwnProperty('supportedLocalesOf')) { + $ERROR("Intl.DateTimeFormat doesn't have a supportedLocalesOf property."); +} + +supportedLocales = Intl.DateTimeFormat.supportedLocalesOf(requestedLocales); +if (supportedLocales.length !== 1) { + $ERROR('The length of supported locales list is not 1.'); +} + +if (supportedLocales[0] !== defaultLocale) { + $ERROR('The default locale is not returned in the supported list.'); +} + diff --git a/js/src/tests/test262/intl402/ch12/12.2/12.2.2_b.js b/js/src/tests/test262/intl402/ch12/12.2/12.2.2_b.js new file mode 100644 index 000000000..06bc8027e --- /dev/null +++ b/js/src/tests/test262/intl402/ch12/12.2/12.2.2_b.js @@ -0,0 +1,13 @@ +// Copyright 2013 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/** + * @description Tests that Intl.DateTimeFormat.supportedLocalesOf + * doesn't access arguments that it's not given. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +taintDataProperty(Object.prototype, "1"); +new Intl.DateTimeFormat("und"); diff --git a/js/src/tests/test262/intl402/ch12/12.2/12.2.3_b.js b/js/src/tests/test262/intl402/ch12/12.2/12.2.3_b.js new file mode 100644 index 000000000..65fd9dc5f --- /dev/null +++ b/js/src/tests/test262/intl402/ch12/12.2/12.2.3_b.js @@ -0,0 +1,47 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/** + * @description Tests that Intl.DateTimeFormat does not accept Unicode locale + * extension keys and values that are not allowed. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +var locales = ["ja-JP", "zh-Hans-CN", "zh-Hant-TW"]; +var input = new Date(Date.parse("1989-11-09T17:57:00Z")); + +locales.forEach(function (locale) { + var defaultDateTimeFormat = new Intl.DateTimeFormat([locale]); + var defaultOptions = defaultDateTimeFormat.resolvedOptions(); + var defaultOptionsJSON = JSON.stringify(defaultOptions); + var defaultLocale = defaultOptions.locale; + var defaultFormatted = defaultDateTimeFormat.format(input); + + var keyValues = { + "cu": ["USD", "EUR", "JPY", "CNY", "TWD", "invalid"], // DateTimeFormat internally uses NumberFormat + "nu": ["native", "traditio", "finance", "invalid"], + "tz": ["usnavajo", "utcw01", "aumel", "uslax", "usnyc", "deber", "invalid"] + }; + + Object.getOwnPropertyNames(keyValues).forEach(function (key) { + keyValues[key].forEach(function (value) { + var dateTimeFormat = new Intl.DateTimeFormat([locale + "-u-" + key + "-" + value]); + var options = dateTimeFormat.resolvedOptions(); + if (options.locale !== defaultLocale) { + $ERROR("Locale " + options.locale + " is affected by key " + + key + "; value " + value + "."); + } + if (JSON.stringify(options) !== defaultOptionsJSON) { + $ERROR("Resolved options " + JSON.stringify(options) + " are affected by key " + + key + "; value " + value + "."); + } + if (defaultFormatted !== dateTimeFormat.format(input)) { + $ERROR("Formatted value " + dateTimeFormat.format(input) + " is affected by key " + + key + "; value " + value + "."); + } + }); + }); +}); + diff --git a/js/src/tests/test262/intl402/ch12/12.2/12.2.3_c.js b/js/src/tests/test262/intl402/ch12/12.2/12.2.3_c.js new file mode 100644 index 000000000..0aced6ca9 --- /dev/null +++ b/js/src/tests/test262/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 + "."); + } + } + }); + }); +}); + diff --git a/js/src/tests/test262/intl402/ch12/12.2/browser.js b/js/src/tests/test262/intl402/ch12/12.2/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch12/12.2/browser.js diff --git a/js/src/tests/test262/intl402/ch12/12.2/shell.js b/js/src/tests/test262/intl402/ch12/12.2/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch12/12.2/shell.js |