diff options
Diffstat (limited to 'js/src/tests/test262/intl402/ch11/11.2')
-rw-r--r-- | js/src/tests/test262/intl402/ch11/11.2/11.2.1.js | 22 | ||||
-rw-r--r-- | js/src/tests/test262/intl402/ch11/11.2/11.2.2_L15.js | 14 | ||||
-rw-r--r-- | js/src/tests/test262/intl402/ch11/11.2/11.2.2_a.js | 28 | ||||
-rw-r--r-- | js/src/tests/test262/intl402/ch11/11.2/11.2.2_b.js | 13 | ||||
-rw-r--r-- | js/src/tests/test262/intl402/ch11/11.2/11.2.3_b.js | 46 | ||||
-rw-r--r-- | js/src/tests/test262/intl402/ch11/11.2/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/test262/intl402/ch11/11.2/shell.js | 0 |
7 files changed, 123 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/ch11/11.2/11.2.1.js b/js/src/tests/test262/intl402/ch11/11.2/11.2.1.js new file mode 100644 index 000000000..83bebb283 --- /dev/null +++ b/js/src/tests/test262/intl402/ch11/11.2/11.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.NumberFormat.prototype has the required attributes. + * @author Norbert Lindenberg + */ + +var desc = Object.getOwnPropertyDescriptor(Intl.NumberFormat, "prototype"); +if (desc === undefined) { + $ERROR("Intl.NumberFormat.prototype is not defined."); +} +if (desc.writable) { + $ERROR("Intl.NumberFormat.prototype must not be writable."); +} +if (desc.enumerable) { + $ERROR("Intl.NumberFormat.prototype must not be enumerable."); +} +if (desc.configurable) { + $ERROR("Intl.NumberFormat.prototype must not be configurable."); +} + diff --git a/js/src/tests/test262/intl402/ch11/11.2/11.2.2_L15.js b/js/src/tests/test262/intl402/ch11/11.2/11.2.2_L15.js new file mode 100644 index 000000000..49dce3bae --- /dev/null +++ b/js/src/tests/test262/intl402/ch11/11.2/11.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.NumberFormat.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.NumberFormat.supportedLocalesOf, true, false, [], 1); + diff --git a/js/src/tests/test262/intl402/ch11/11.2/11.2.2_a.js b/js/src/tests/test262/intl402/ch11/11.2/11.2.2_a.js new file mode 100644 index 000000000..c6c9f9a46 --- /dev/null +++ b/js/src/tests/test262/intl402/ch11/11.2/11.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.NumberFormat has a supportedLocalesOf + * property, and it works as planned. + * @author: Roozbeh Pournader + */ + +var defaultLocale = new Intl.NumberFormat().resolvedOptions().locale; +var notSupported = 'zxx'; // "no linguistic content" +var requestedLocales = [defaultLocale, notSupported]; + +var supportedLocales; + +if (!Intl.NumberFormat.hasOwnProperty('supportedLocalesOf')) { + $ERROR("Intl.NumberFormat doesn't have a supportedLocalesOf property."); +} + +supportedLocales = Intl.NumberFormat.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/ch11/11.2/11.2.2_b.js b/js/src/tests/test262/intl402/ch11/11.2/11.2.2_b.js new file mode 100644 index 000000000..6b4d77e77 --- /dev/null +++ b/js/src/tests/test262/intl402/ch11/11.2/11.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.NumberFormat.supportedLocalesOf + * doesn't access arguments that it's not given. + * @author Norbert Lindenberg + */ + +$INCLUDE("testIntl.js"); + +taintDataProperty(Object.prototype, "1"); +new Intl.NumberFormat("und"); diff --git a/js/src/tests/test262/intl402/ch11/11.2/11.2.3_b.js b/js/src/tests/test262/intl402/ch11/11.2/11.2.3_b.js new file mode 100644 index 000000000..70fe7cf11 --- /dev/null +++ b/js/src/tests/test262/intl402/ch11/11.2/11.2.3_b.js @@ -0,0 +1,46 @@ +// Copyright 2012 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/** + * @description Tests that Intl.NumberFormat 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 = 1234567.89; + +locales.forEach(function (locale) { + var defaultNumberFormat = new Intl.NumberFormat([locale]); + var defaultOptions = defaultNumberFormat.resolvedOptions(); + var defaultOptionsJSON = JSON.stringify(defaultOptions); + var defaultLocale = defaultOptions.locale; + var defaultFormatted = defaultNumberFormat.format(input); + + var keyValues = { + "cu": ["USD", "EUR", "JPY", "CNY", "TWD", "invalid"], + "nu": ["native", "traditio", "finance", "invalid"] + }; + + Object.getOwnPropertyNames(keyValues).forEach(function (key) { + keyValues[key].forEach(function (value) { + var numberFormat = new Intl.NumberFormat([locale + "-u-" + key + "-" + value]); + var options = numberFormat.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 !== numberFormat.format(input)) { + $ERROR("Formatted value " + numberFormat.format(input) + " is affected by key " + + key + "; value " + value + "."); + } + }); + }); +}); + diff --git a/js/src/tests/test262/intl402/ch11/11.2/browser.js b/js/src/tests/test262/intl402/ch11/11.2/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch11/11.2/browser.js diff --git a/js/src/tests/test262/intl402/ch11/11.2/shell.js b/js/src/tests/test262/intl402/ch11/11.2/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/test262/intl402/ch11/11.2/shell.js |