summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/ch11
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/intl402/ch11')
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.1_1.js43
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.1_15.js13
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.1_17.js81
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.1_19.js31
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.1_20_c.js196
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.1_21.js15
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.1_32.js44
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.1_34.js12
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.1_6.js18
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.1_7.js12
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.1_a.js18
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.2.1_4.js21
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.2.js30
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1.3.js19
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/11.1_L15.js14
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/browser.js0
-rw-r--r--js/src/tests/test262/intl402/ch11/11.1/shell.js0
-rw-r--r--js/src/tests/test262/intl402/ch11/11.2/11.2.1.js22
-rw-r--r--js/src/tests/test262/intl402/ch11/11.2/11.2.2_L15.js14
-rw-r--r--js/src/tests/test262/intl402/ch11/11.2/11.2.2_a.js28
-rw-r--r--js/src/tests/test262/intl402/ch11/11.2/11.2.2_b.js13
-rw-r--r--js/src/tests/test262/intl402/ch11/11.2/11.2.3_b.js46
-rw-r--r--js/src/tests/test262/intl402/ch11/11.2/browser.js0
-rw-r--r--js/src/tests/test262/intl402/ch11/11.2/shell.js0
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3.1.js14
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3.2_1_a_L15.js14
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3.2_1_a_ii.js27
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3.2_1_c.js41
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_1.js19
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_2.js59
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_3_b.js27
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_3_e.js47
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3.2_L15.js14
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3.2_TRF.js56
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3.2_TRP.js56
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3.3.js31
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3.3_L15.js14
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3_L15.js14
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3_a.js16
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/11.3_b.js33
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/browser.js0
-rw-r--r--js/src/tests/test262/intl402/ch11/11.3/shell.js0
-rw-r--r--js/src/tests/test262/intl402/ch11/11.4/11.4_a.js15
-rw-r--r--js/src/tests/test262/intl402/ch11/11.4/browser.js0
-rw-r--r--js/src/tests/test262/intl402/ch11/11.4/shell.js0
-rw-r--r--js/src/tests/test262/intl402/ch11/browser.js0
-rw-r--r--js/src/tests/test262/intl402/ch11/shell.js0
47 files changed, 1187 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.1_1.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_1.js
new file mode 100644
index 000000000..33af16975
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_1.js
@@ -0,0 +1,43 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that an object can't be re-initialized as a NumberFormat.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+testWithIntlConstructors(function (Constructor) {
+ var obj, error;
+
+ // variant 1: use constructor in a "new" expression
+ obj = new Constructor();
+ try {
+ Intl.NumberFormat.call(obj);
+ } catch (e) {
+ error = e;
+ }
+ if (error === undefined) {
+ $ERROR("Re-initializing object created with \"new\" as NumberFormat was not rejected.");
+ } else if (error.name !== "TypeError") {
+ $ERROR("Re-initializing object created with \"new\" as NumberFormat was rejected with wrong error " + error.name + ".");
+ }
+
+ // variant 2: use constructor as a function
+ obj = Constructor.call({});
+ error = undefined;
+ try {
+ Intl.NumberFormat.call(obj);
+ } catch (e) {
+ error = e;
+ }
+ if (error === undefined) {
+ $ERROR("Re-initializing object created with constructor as function as NumberFormat was not rejected.");
+ } else if (error.name !== "TypeError") {
+ $ERROR("Re-initializing object created with constructor as function as NumberFormat was rejected with wrong error " + error.name + ".");
+ }
+
+ return true;
+});
+
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.1_15.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_15.js
new file mode 100644
index 000000000..4d0467428
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_15.js
@@ -0,0 +1,13 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the option style is processed correctly.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+testOption(Intl.NumberFormat, "style", "string", ["decimal", "percent", "currency"], "decimal",
+ {extra: {"currency": {currency: "CNY"}}});
+
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.1_17.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_17.js
new file mode 100644
index 000000000..08c0e8e5c
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_17.js
@@ -0,0 +1,81 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the option currency is processed correctly.
+ * @author Norbert Lindenberg
+ */
+
+var validValues = ["CNY", "USD", "EUR", "IDR", "jpy", {toString: function () {return "INR";}}];
+var invalidValues = ["$", "SFr.", "US$", "ßP", {toString: function () {return;}}];
+
+var defaultLocale = new Intl.NumberFormat().resolvedOptions().locale;
+
+validValues.forEach(function (value) {
+ var format, actual, expected;
+
+ // with currency style, we should get the upper case form back
+ format = new Intl.NumberFormat([defaultLocale], {style: "currency", currency: value});
+ actual = format.resolvedOptions().currency;
+ expected = value.toString().toUpperCase();
+ if (actual !== expected) {
+ $ERROR("Incorrect resolved currency with currency style - expected " +
+ expected + "; got " + actual + ".");
+ }
+
+ // without currency style, we shouldn't get any currency back
+ format = new Intl.NumberFormat([defaultLocale], {currency: value});
+ actual = format.resolvedOptions().currency;
+ expected = undefined;
+ if (actual !== expected) {
+ $ERROR("Incorrect resolved currency with non-currency style - expected " +
+ expected + "; got " + actual + ".");
+ }
+
+ // currencies specified through the locale must be ignored
+ format = new Intl.NumberFormat([defaultLocale + "-u-cu-krw"], {style: "currency", currency: value});
+ actual = format.resolvedOptions().currency;
+ expected = value.toString().toUpperCase();
+ if (actual !== expected) {
+ $ERROR("Incorrect resolved currency with -u-cu- and currency style - expected " +
+ expected + "; got " + actual + ".");
+ }
+
+ format = new Intl.NumberFormat([defaultLocale + "-u-cu-krw"], {currency: value});
+ actual = format.resolvedOptions().currency;
+ expected = undefined;
+ if (actual !== expected) {
+ $ERROR("Incorrect resolved currency with -u-cu- and non-currency style - expected " +
+ expected + "; got " + actual + ".");
+ }
+});
+
+invalidValues.forEach(function (value) {
+ function expectError(f) {
+ var error;
+ try {
+ f();
+ } catch (e) {
+ error = e;
+ }
+ if (error === undefined) {
+ $ERROR("Invalid currency value " + value + " was not rejected.");
+ } else if (error.name !== "RangeError") {
+ $ERROR("Invalid currency value " + value + " was rejected with wrong error " + error.name + ".");
+ }
+ }
+
+ expectError(function () {
+ return new Intl.NumberFormat([defaultLocale], {style: "currency", currency: value});
+ });
+ expectError(function () {
+ return new Intl.NumberFormat([defaultLocale], {currency: value});
+ });
+ expectError(function () {
+ return new Intl.NumberFormat([defaultLocale + "-u-cu-krw"], {style: "currency", currency: value});
+ });
+ expectError(function () {
+ return new Intl.NumberFormat([defaultLocale + "-u-cu-krw"], {currency: value});
+ });
+});
+
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.1_19.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_19.js
new file mode 100644
index 000000000..e41ca5bec
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_19.js
@@ -0,0 +1,31 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the currency style can not be used without a specified currency.
+ * @author Norbert Lindenberg
+ */
+
+var defaultLocale = new Intl.NumberFormat().resolvedOptions().locale;
+
+function expectError(f) {
+ var error;
+ try {
+ f();
+ } catch (e) {
+ error = e;
+ }
+ if (error === undefined) {
+ $ERROR("Invalid currency value " + value + " was not rejected.");
+ } else if (error.name !== "TypeError") {
+ $ERROR("Invalid currency value " + value + " was rejected with wrong error " + error.name + ".");
+ }
+}
+
+expectError(function () {
+ return new Intl.NumberFormat([defaultLocale], {style: "currency"});
+});
+expectError(function () {
+ return new Intl.NumberFormat([defaultLocale + "-u-cu-krw"], {style: "currency"});
+});
+
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.1_20_c.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_20_c.js
new file mode 100644
index 000000000..6a705ab33
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_20_c.js
@@ -0,0 +1,196 @@
+// Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the number of fractional digits is determined correctly for currencies.
+ * @author Norbert Lindenberg
+ */
+
+// data from http://www.currency-iso.org/dl_iso_table_a1.xml, 2013-02-25
+var currencyDigits = {
+ AED: 2,
+ AFN: 2,
+ ALL: 2,
+ AMD: 2,
+ ANG: 2,
+ AOA: 2,
+ ARS: 2,
+ AUD: 2,
+ AWG: 2,
+ AZN: 2,
+ BAM: 2,
+ BBD: 2,
+ BDT: 2,
+ BGN: 2,
+ BHD: 3,
+ BIF: 0,
+ BMD: 2,
+ BND: 2,
+ BOB: 2,
+ BOV: 2,
+ BRL: 2,
+ BSD: 2,
+ BTN: 2,
+ BWP: 2,
+ BYR: 0,
+ BZD: 2,
+ CAD: 2,
+ CDF: 2,
+ CHE: 2,
+ CHF: 2,
+ CHW: 2,
+ CLF: 4,
+ CLP: 0,
+ CNY: 2,
+ COP: 2,
+ COU: 2,
+ CRC: 2,
+ CUC: 2,
+ CUP: 2,
+ CVE: 2,
+ CZK: 2,
+ DJF: 0,
+ DKK: 2,
+ DOP: 2,
+ DZD: 2,
+ EGP: 2,
+ ERN: 2,
+ ETB: 2,
+ EUR: 2,
+ FJD: 2,
+ FKP: 2,
+ GBP: 2,
+ GEL: 2,
+ GHS: 2,
+ GIP: 2,
+ GMD: 2,
+ GNF: 0,
+ GTQ: 2,
+ GYD: 2,
+ HKD: 2,
+ HNL: 2,
+ HRK: 2,
+ HTG: 2,
+ HUF: 2,
+ IDR: 2,
+ ILS: 2,
+ INR: 2,
+ IQD: 3,
+ IRR: 2,
+ ISK: 0,
+ JMD: 2,
+ JOD: 3,
+ JPY: 0,
+ KES: 2,
+ KGS: 2,
+ KHR: 2,
+ KMF: 0,
+ KPW: 2,
+ KRW: 0,
+ KWD: 3,
+ KYD: 2,
+ KZT: 2,
+ LAK: 2,
+ LBP: 2,
+ LKR: 2,
+ LRD: 2,
+ LSL: 2,
+ LTL: 2,
+ LVL: 2,
+ LYD: 3,
+ MAD: 2,
+ MDL: 2,
+ MGA: 2,
+ MKD: 2,
+ MMK: 2,
+ MNT: 2,
+ MOP: 2,
+ MRO: 2,
+ MUR: 2,
+ MVR: 2,
+ MWK: 2,
+ MXN: 2,
+ MXV: 2,
+ MYR: 2,
+ MZN: 2,
+ NAD: 2,
+ NGN: 2,
+ NIO: 2,
+ NOK: 2,
+ NPR: 2,
+ NZD: 2,
+ OMR: 3,
+ PAB: 2,
+ PEN: 2,
+ PGK: 2,
+ PHP: 2,
+ PKR: 2,
+ PLN: 2,
+ PYG: 0,
+ QAR: 2,
+ RON: 2,
+ RSD: 2,
+ RUB: 2,
+ RWF: 0,
+ SAR: 2,
+ SBD: 2,
+ SCR: 2,
+ SDG: 2,
+ SEK: 2,
+ SGD: 2,
+ SHP: 2,
+ SLL: 2,
+ SOS: 2,
+ SRD: 2,
+ SSP: 2,
+ STD: 2,
+ SVC: 2,
+ SYP: 2,
+ SZL: 2,
+ THB: 2,
+ TJS: 2,
+ TMT: 2,
+ TND: 3,
+ TOP: 2,
+ TRY: 2,
+ TTD: 2,
+ TWD: 2,
+ TZS: 2,
+ UAH: 2,
+ UGX: 0,
+ USD: 2,
+ USN: 2,
+ USS: 2,
+ UYI: 0,
+ UYU: 2,
+ UZS: 2,
+ VEF: 2,
+ VND: 0,
+ VUV: 0,
+ WST: 2,
+ XAF: 0,
+ XCD: 2,
+ XOF: 0,
+ XPF: 0,
+ YER: 2,
+ ZAR: 2,
+ ZMW: 2,
+ ZWL: 2
+};
+
+Object.getOwnPropertyNames(currencyDigits).forEach(function (currency) {
+ var digits = currencyDigits[currency];
+ format = Intl.NumberFormat([], {style: "currency", currency: currency});
+ var min = format.resolvedOptions().minimumFractionDigits;
+ var max = format.resolvedOptions().maximumFractionDigits;
+ if (min !== digits) {
+ $ERROR("Didn't get correct minimumFractionDigits for currency " +
+ currency + "; expected " + digits + ", got " + min + ".");
+ }
+ if (max !== digits) {
+ $ERROR("Didn't get correct maximumFractionDigits for currency " +
+ currency + "; expected " + digits + ", got " + max + ".");
+ }
+});
+
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.1_21.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_21.js
new file mode 100644
index 000000000..1751b8b57
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_21.js
@@ -0,0 +1,15 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the option currencyDisplay is processed correctly.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+testOption(Intl.NumberFormat, "currencyDisplay", "string", ["code", "symbol", "name"],
+ "symbol", {extra: {any: {style: "currency", currency: "XDR"}}});
+testOption(Intl.NumberFormat, "currencyDisplay", "string", ["code", "symbol", "name"],
+ undefined, {noReturn: true});
+
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.1_32.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_32.js
new file mode 100644
index 000000000..9196318ef
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_32.js
@@ -0,0 +1,44 @@
+// Copyright 2013 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the options minimumSignificantDigits and
+ * maximumSignificantDigits are read in the right sequence.
+ * @author Norbert Lindenberg
+ */
+
+var read = 0;
+
+function readMinimumSignificantDigits() {
+ ++read;
+ if (read === 1) {
+ return 0; // invalid value, but on first read that's OK
+ } else if (read === 3) {
+ return 1; // valid value
+ } else {
+ $ERROR("minimumSignificantDigits read out of sequence: " + read + ".");
+ }
+}
+
+function readMaximumSignificantDigits() {
+ ++read;
+ if (read === 2) {
+ return 0; // invalid value, but on first read that's OK
+ } else if (read === 4) {
+ return 1; // valid value
+ } else {
+ $ERROR("maximumSignificantDigits read out of sequence: " + read + ".");
+ }
+}
+
+var options = {};
+Object.defineProperty(options, "minimumSignificantDigits",
+ { get: readMinimumSignificantDigits });
+Object.defineProperty(options, "maximumSignificantDigits",
+ { get: readMaximumSignificantDigits });
+
+new Intl.NumberFormat("de", options);
+
+if (read !== 4) {
+ $ERROR("insuffient number of property reads: " + read + ".");
+}
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.1_34.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_34.js
new file mode 100644
index 000000000..98ba9a062
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_34.js
@@ -0,0 +1,12 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the option useGrouping is processed correctly.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+testOption(Intl.NumberFormat, "useGrouping", "boolean", undefined, true);
+
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.1_6.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_6.js
new file mode 100644
index 000000000..5b9d342eb
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_6.js
@@ -0,0 +1,18 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the behavior of a Record is not affected by adversarial
+ * changes to Object.prototype.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+taintProperties(["localeMatcher"]);
+
+var locale = new Intl.NumberFormat(undefined, {localeMatcher: "lookup"}).resolvedOptions().locale;
+if (!isCanonicalizedStructurallyValidLanguageTag(locale)) {
+ $ERROR("NumberFormat returns invalid locale " + locale + ".");
+}
+
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.1_7.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_7.js
new file mode 100644
index 000000000..4b13b245b
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_7.js
@@ -0,0 +1,12 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the option localeMatcher is processed correctly.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+testOption(Intl.NumberFormat, "localeMatcher", "string", ["lookup", "best fit"], "best fit", {noReturn: true});
+
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.1_a.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_a.js
new file mode 100644
index 000000000..611816b61
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.1_a.js
@@ -0,0 +1,18 @@
+// Copyright 2013 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that constructing a NumberFormat doesn't create or modify
+ * unwanted properties on the RegExp constructor.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+testForUnwantedRegExpChanges(function () {
+ new Intl.NumberFormat("de-DE-u-nu-latn");
+});
+
+testForUnwantedRegExpChanges(function () {
+ new Intl.NumberFormat("de-DE-u-nu-latn", {style: "currency", currency: "EUR"});
+});
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.2.1_4.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.2.1_4.js
new file mode 100644
index 000000000..18b5b98fa
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.2.1_4.js
@@ -0,0 +1,21 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that for non-object values passed as this to NumberFormat a
+ * wrapper object will be initialized and returned.
+ * @author Norbert Lindenberg
+ */
+
+var thisValues = [true, 42, "国際化"];
+
+thisValues.forEach(function (value) {
+ var format = Intl.NumberFormat.call(value);
+ // check that the returned object functions as a number format
+ var referenceFormat = new Intl.NumberFormat();
+ if (Intl.NumberFormat.prototype.format.call(format, 12.3456) !== referenceFormat.format(12.3456)) {
+ $ERROR("NumberFormat initialized from " + value + " doesn't behave like normal number format.");
+ }
+ return true;
+});
+
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.2.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.2.js
new file mode 100644
index 000000000..0ca8cbbda
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.2.js
@@ -0,0 +1,30 @@
+// Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that Intl.NumberFormat can be subclassed.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+// get a number format and have it format an array of numbers for comparison with the subclass
+var locales = ["tlh", "id", "en"];
+var a = [0, 1, -1, -123456.789, -Infinity, NaN];
+var referenceNumberFormat = new Intl.NumberFormat(locales);
+var referenceFormatted = a.map(referenceNumberFormat.format);
+
+function MyNumberFormat(locales, options) {
+ Intl.NumberFormat.call(this, locales, options);
+ // could initialize MyNumberFormat properties
+}
+
+MyNumberFormat.prototype = Object.create(Intl.NumberFormat.prototype);
+MyNumberFormat.prototype.constructor = MyNumberFormat;
+// could add methods to MyNumberFormat.prototype
+
+var format = new MyNumberFormat(locales);
+var actual = a.map(format.format);
+testArraysAreSame(referenceFormatted, actual);
+
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1.3.js b/js/src/tests/test262/intl402/ch11/11.1/11.1.3.js
new file mode 100644
index 000000000..f0bfb5552
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1.3.js
@@ -0,0 +1,19 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that objects constructed by Intl.NumberFormat have the specified internal properties.
+ * @author Norbert Lindenberg
+ */
+
+var obj = new Intl.NumberFormat();
+
+var actualPrototype = Object.getPrototypeOf(obj);
+if (actualPrototype !== Intl.NumberFormat.prototype) {
+ $ERROR("Prototype of object constructed by Intl.NumberFormat isn't Intl.NumberFormat.prototype; got " + actualPrototype);
+}
+
+if (!Object.isExtensible(obj)) {
+ $ERROR("Object constructed by Intl.NumberFormat must be extensible.");
+}
+
diff --git a/js/src/tests/test262/intl402/ch11/11.1/11.1_L15.js b/js/src/tests/test262/intl402/ch11/11.1/11.1_L15.js
new file mode 100644
index 000000000..e40ffc53e
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/11.1_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
+ * 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, true, true, ["supportedLocalesOf"], 0);
+
diff --git a/js/src/tests/test262/intl402/ch11/11.1/browser.js b/js/src/tests/test262/intl402/ch11/11.1/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/browser.js
diff --git a/js/src/tests/test262/intl402/ch11/11.1/shell.js b/js/src/tests/test262/intl402/ch11/11.1/shell.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.1/shell.js
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
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3.1.js b/js/src/tests/test262/intl402/ch11/11.3/11.3.1.js
new file mode 100644
index 000000000..46c7fc519
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.1.js
@@ -0,0 +1,14 @@
+// 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.prototype.constructor is the
+ * Intl.NumberFormat.
+ * @author: Roozbeh Pournader
+ */
+
+if (Intl.NumberFormat.prototype.constructor !== Intl.NumberFormat) {
+ $ERROR("Intl.NumberFormat.prototype.constructor is not the same as " +
+ "Intl.NumberFormat");
+}
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3.2_1_a_L15.js b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_1_a_L15.js
new file mode 100644
index 000000000..8e1c95835
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_1_a_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 the function returned by Intl.NumberFormat.prototype.format
+ * 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(new Intl.NumberFormat().format, true, false, [], 1);
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3.2_1_a_ii.js b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_1_a_ii.js
new file mode 100644
index 000000000..cb284f43e
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_1_a_ii.js
@@ -0,0 +1,27 @@
+// 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.prototype.format
+ * converts other types to numbers.
+ * @author: Roozbeh Pournader
+ */
+
+var formatter = new Intl.NumberFormat();
+var testData = [undefined, null, true, '0.6666666', {valueOf: function () { return '0.1234567';}}];
+var number;
+var i, input, correctResult, result;
+
+for (i in testData) {
+ input = testData[i];
+ number = +input;
+ correctResult = formatter.format(number);
+
+ result = formatter.format(input);
+ if (result !== correctResult) {
+ $ERROR('Intl.NumberFormat does not convert other ' +
+ 'types to numbers. Input: "'+input+'" Output: "'+result+'" '+
+ 'Expected output: "'+correctResult+'"');
+ }
+}
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3.2_1_c.js b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_1_c.js
new file mode 100644
index 000000000..3fc877b31
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_1_c.js
@@ -0,0 +1,41 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that format function is bound to its Intl.NumberFormat.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+var numbers = [0, -0, 1, -1, 5.5, 123, -123, -123.45, 123.44501, 0.001234,
+ -0.00000000123, 0.00000000000000000000000000000123, 1.2, 0.0000000012344501,
+ 123445.01, 12344501000000000000000000000000000, -12344501000000000000000000000000000,
+ Infinity, -Infinity, NaN];
+var locales = [undefined, ["de"], ["th-u-nu-thai"], ["en"], ["ja-u-nu-jpanfin"], ["ar-u-nu-arab"]];
+var options = [
+ undefined,
+ {style: "percent"},
+ {style: "currency", currency: "EUR", currencyDisplay: "symbol"},
+ {style: "currency", currency: "IQD", currencyDisplay: "symbol"},
+ {style: "currency", currency: "KMF", currencyDisplay: "symbol"},
+ {style: "currency", currency: "CLF", currencyDisplay: "symbol"},
+ {useGrouping: false, minimumIntegerDigits: 3, minimumFractionDigits: 1, maximumFractionDigits: 3}
+];
+
+locales.forEach(function (locales) {
+ options.forEach(function (options) {
+ var formatObj = new Intl.NumberFormat(locales, options);
+ var formatFunc = formatObj.format;
+ numbers.forEach(function (number) {
+ var referenceFormatted = formatObj.format(number);
+ var formatted = formatFunc(number);
+ if (referenceFormatted !== formatted) {
+ $ERROR("format function produces different result than format method for locales " +
+ locales + "; options: " + (options ? JSON.stringify(options) : options) +
+ " : " + formatted + " vs. " + referenceFormatted + ".");
+ }
+ });
+ });
+});
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_1.js b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_1.js
new file mode 100644
index 000000000..5f14e7772
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_1.js
@@ -0,0 +1,19 @@
+// 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.prototype.format
+ * doesn't treat all numbers as negative.
+ * @author: Roozbeh Pournader
+ */
+
+var formatter = new Intl.NumberFormat();
+
+if (formatter.format(1) === formatter.format(-1)) {
+ $ERROR('Intl.NumberFormat is formatting 1 and -1 the same way.');
+}
+
+if (formatter.format(-0) !== formatter.format(0)) {
+ $ERROR('Intl.NumberFormat is formatting signed zeros differently.');
+}
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_2.js b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_2.js
new file mode 100644
index 000000000..ec11a679d
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_2.js
@@ -0,0 +1,59 @@
+// 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.prototype.format
+ * handles NaN, Infinity, and -Infinity properly.
+ * @author: Roozbeh Pournader
+ */
+
+// FIXME: We are only listing Numeric_Type=Decimal. May need to add more
+// when the spec clarifies. Current as of Unicode 6.1.
+var hasUnicodeDigits = new RegExp('.*([' +
+ '0-9\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F' +
+ '\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF' +
+ '\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0E50-\u0E59\u0ED0-\u0ED9' +
+ '\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u17E0-\u17E9\u1810-\u1819' +
+ '\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59' +
+ '\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9' +
+ '\uA900-\uA909\uA9D0-\uA9D9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19' +
+ ']|' +
+ '\uD801[\uDCA0-\uDCA9]|' +
+ '\uD804[\uDC66-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9]|' +
+ '\uD805[\uDEC0-\uDEC9]|' +
+ '\uD835[\uDFCE-\uDFFF])');
+
+var formatter = new Intl.NumberFormat();
+var formattedNaN = formatter.format(NaN);
+var formattedInfinity = formatter.format(Infinity);
+var formattedNegativeInfinity = formatter.format(-Infinity);
+
+if (formattedNaN === formattedInfinity) {
+ $ERROR('Intl.NumberFormat formats NaN and Infinity the ' +
+ 'same way.');
+}
+
+if (formattedNaN === formattedNegativeInfinity) {
+ $ERROR('Intl.NumberFormat formats NaN and negative ' +
+ 'Infinity the same way.');
+}
+
+if (formattedInfinity === formattedNegativeInfinity) {
+ $ERROR('Intl.NumberFormat formats Infinity and ' +
+ 'negative Infinity the same way.');
+}
+
+if (hasUnicodeDigits.test(formattedNaN)) {
+ $ERROR('Intl.NumberFormat formats NaN using a digit.');
+}
+
+if (hasUnicodeDigits.test(formattedInfinity)) {
+ $ERROR('Intl.NumberFormat formats Infinity using a ' +
+ 'digit.');
+}
+
+if (hasUnicodeDigits.test(formattedNegativeInfinity)) {
+ $ERROR('Intl.NumberFormat formats negative Infinity ' +
+ 'using a digit.');
+}
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_3_b.js b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_3_b.js
new file mode 100644
index 000000000..efe15575d
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_3_b.js
@@ -0,0 +1,27 @@
+// 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.prototype.format
+ * formats percent values properly.
+ * @author: Roozbeh Pournader
+ */
+
+var numberFormatter = new Intl.NumberFormat();
+var percentFormatter = new Intl.NumberFormat(undefined, {style: 'percent'});
+
+var formattedTwenty = numberFormatter.format(20);
+var formattedTwentyPercent = percentFormatter.format(0.20);
+
+// FIXME: May not work for some theoretical locales where percents and
+// normal numbers are formatted using different numbering systems.
+if (formattedTwentyPercent.indexOf(formattedTwenty) === -1) {
+ $ERROR("Intl.NumberFormat's formatting of 20% does not include a " +
+ "formatting of 20 as a substring.");
+}
+
+// FIXME: Move this to somewhere appropriate
+if (percentFormatter.format(0.011) === percentFormatter.format(0.02)) {
+ $ERROR('Intl.NumberFormat is formatting 1.1% and 2% the same way.');
+}
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_3_e.js b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_3_e.js
new file mode 100644
index 000000000..234ae6325
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_3_e.js
@@ -0,0 +1,47 @@
+// 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.prototype.format
+ * supports all alternative numbering systems.
+ * @author: Roozbeh Pournader
+ */
+
+var numberingSystems = {
+ arab: 0x0660,
+ arabext: 0x06F0,
+ beng: 0x09E6,
+ deva: 0x0966,
+ fullwide: 0xFF10,
+ gujr: 0x0AE6,
+ guru: 0x0A66,
+ hanidec: [0x3007, 0x4E00, 0x4E8C, 0x4E09, 0x56DB,
+ 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D],
+ khmr: 0x17E0,
+ knda: 0x0CE6,
+ laoo: 0x0ED0,
+ latn: 0x0030,
+ mlym: 0x0D66,
+ mong: 0x1810,
+ mymr: 0x1040,
+ orya: 0x0B66,
+ tamldec: 0x0BE6,
+ telu: 0x0C66,
+ thai: 0x0E50,
+ tibt: 0x0F20
+};
+
+var options, formatter;
+var s, zeroCode, digitList;
+
+for (s in numberingSystems) {
+ zeroCode = numberingSystems[s];
+ if (typeof zeroCode === 'number') {
+ digitList = [zeroCode, zeroCode+1, zeroCode+2, zeroCode+3, zeroCode+4,
+ zeroCode+5, zeroCode+6, zeroCode+7, zeroCode+8, zeroCode+9];
+ numberingSystems[s] = digitList;
+ }
+}
+
+// FIXME: Unfinished
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3.2_L15.js b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_L15.js
new file mode 100644
index 000000000..17b688b7a
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.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 the getter for Intl.NumberFormat.prototype.format
+ * 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(Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, "format").get , true, false, [], 0);
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3.2_TRF.js b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_TRF.js
new file mode 100644
index 000000000..c042a318a
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_TRF.js
@@ -0,0 +1,56 @@
+// Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the digits are determined correctly when specifying pre/post decimal digits.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+var locales = [
+ new Intl.NumberFormat().resolvedOptions().locale,
+ "ar", "de", "th", "ja"
+];
+var numberingSystems = [
+ "arab",
+ "latn",
+ "thai",
+ "hanidec"
+];
+var testData = {
+ "0": "000.0",
+ "-0": "000.0",
+ "123": "123.0",
+ "-123": "-123.0",
+ "12345": "12345.0",
+ "-12345": "-12345.0",
+ "123.45": "123.45",
+ "-123.45": "-123.45",
+ "123.444499": "123.444",
+ "-123.444499": "-123.444",
+ "123.444500": "123.445",
+ "-123.444500": "-123.445",
+ "123.44501": "123.445",
+ "-123.44501": "-123.445",
+ "0.001234": "000.001",
+ "-0.001234": "-000.001",
+ "0.00000000123": "000.0",
+ "-0.00000000123": "-000.0",
+ "0.00000000000000000000000000000123": "000.0",
+ "-0.00000000000000000000000000000123": "-000.0",
+ "1.2": "001.2",
+ "-1.2": "-001.2",
+ "0.0000000012344501": "000.0",
+ "-0.0000000012344501": "-000.0",
+ "123445.01": "123445.01",
+ "-123445.01": "-123445.01",
+ "12344501000000000000000000000000000": "12344501000000000000000000000000000.0",
+ "-12344501000000000000000000000000000": "-12344501000000000000000000000000000.0"
+};
+
+testNumberFormat(locales, numberingSystems,
+ {useGrouping: false, minimumIntegerDigits: 3, minimumFractionDigits: 1, maximumFractionDigits: 3},
+ testData);
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3.2_TRP.js b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_TRP.js
new file mode 100644
index 000000000..9ab6550b6
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_TRP.js
@@ -0,0 +1,56 @@
+// Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that the digits are determined correctly when specifying significant digits.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+var locales = [
+ new Intl.NumberFormat().resolvedOptions().locale,
+ "ar", "de", "th", "ja"
+];
+var numberingSystems = [
+ "arab",
+ "latn",
+ "thai",
+ "hanidec"
+];
+var testData = {
+ "0": "0.00",
+ "-0": "0.00",
+ "123": "123",
+ "-123": "-123",
+ "12345": "12345",
+ "-12345": "-12345",
+ "123.45": "123.45",
+ "-123.45": "-123.45",
+ "123.44499": "123.44",
+ "-123.44499": "-123.44",
+ "123.44500": "123.45",
+ "-123.44500": "-123.45",
+ "123.44501": "123.45",
+ "-123.44501": "-123.45",
+ "0.001234": "0.001234",
+ "-0.001234": "-0.001234",
+ "0.00000000123": "0.00000000123",
+ "-0.00000000123": "-0.00000000123",
+ "0.00000000000000000000000000000123": "0.00000000000000000000000000000123",
+ "-0.00000000000000000000000000000123": "-0.00000000000000000000000000000123",
+ "1.2": "1.20",
+ "-1.2": "-1.20",
+ "0.0000000012344501": "0.0000000012345",
+ "-0.0000000012344501": "-0.0000000012345",
+ "123445.01": "123450",
+ "-123445.01": "-123450",
+ "12344501000000000000000000000000000": "12345000000000000000000000000000000",
+ "-12344501000000000000000000000000000": "-12345000000000000000000000000000000"
+};
+
+testNumberFormat(locales, numberingSystems,
+ {useGrouping: false, minimumSignificantDigits: 3, maximumSignificantDigits: 5},
+ testData);
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3.3.js b/js/src/tests/test262/intl402/ch11/11.3/11.3.3.js
new file mode 100644
index 000000000..5a220ccc9
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.3.js
@@ -0,0 +1,31 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the license found in the LICENSE file.
+
+/**
+ * @description Tests that the object returned by Intl.NumberFormat.prototype.resolvedOptions
+ * has the right properties.
+ * @author Norbert Lindenberg
+ */
+
+$INCLUDE("testIntl.js");
+
+var actual = new Intl.NumberFormat().resolvedOptions();
+
+var actual2 = new Intl.NumberFormat().resolvedOptions();
+if (actual2 === actual) {
+ $ERROR("resolvedOptions returned the same object twice.");
+}
+
+// this assumes the default values where the specification provides them
+mustHaveProperty(actual, "locale", isCanonicalizedStructurallyValidLanguageTag);
+mustHaveProperty(actual, "numberingSystem", isValidNumberingSystem);
+mustHaveProperty(actual, "style", ["decimal"]);
+mustNotHaveProperty(actual, "currency");
+mustNotHaveProperty(actual, "currencyDisplay");
+mustHaveProperty(actual, "minimumIntegerDigits", [1]);
+mustHaveProperty(actual, "minimumFractionDigits", [0]);
+mustHaveProperty(actual, "maximumFractionDigits", [3]);
+mustNotHaveProperty(actual, "minimumSignificantDigits");
+mustNotHaveProperty(actual, "maximumSignificantDigits");
+mustHaveProperty(actual, "useGrouping", [true]);
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3.3_L15.js b/js/src/tests/test262/intl402/ch11/11.3/11.3.3_L15.js
new file mode 100644
index 000000000..b9f95866d
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.3_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.prototype.resolvedOptions
+ * 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.prototype.resolvedOptions, true, false, [], 0);
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3_L15.js b/js/src/tests/test262/intl402/ch11/11.3/11.3_L15.js
new file mode 100644
index 000000000..ac1f0c05d
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3_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.prototype
+ * 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.prototype, false, false, ["constructor", "format", "resolvedOptions"]);
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3_a.js b/js/src/tests/test262/intl402/ch11/11.3/11.3_a.js
new file mode 100644
index 000000000..282a10bf6
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3_a.js
@@ -0,0 +1,16 @@
+// 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.prototype is an object that
+ * has been initialized as an Intl.NumberFormat.
+ * @author: Roozbeh Pournader
+ */
+
+// test by calling a function that would fail if "this" were not an object
+// initialized as an Intl.NumberFormat
+if (typeof Intl.NumberFormat.prototype.format(0) !== "string") {
+ $ERROR("Intl.NumberFormat's prototype is not an object that has been " +
+ "initialized as an Intl.NumberFormat");
+}
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/11.3_b.js b/js/src/tests/test262/intl402/ch11/11.3/11.3_b.js
new file mode 100644
index 000000000..6d0162b1d
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/11.3_b.js
@@ -0,0 +1,33 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that Intl.NumberFormat.prototype functions throw a
+ * TypeError if called on a non-object value or an object that hasn't been
+ * initialized as a NumberFormat.
+ * @author Norbert Lindenberg
+ */
+
+var functions = {
+ "format getter": Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, "format").get,
+ resolvedOptions: Intl.NumberFormat.prototype.resolvedOptions
+};
+var invalidTargets = [undefined, null, true, 0, "NumberFormat", [], {}];
+
+Object.getOwnPropertyNames(functions).forEach(function (functionName) {
+ var f = functions[functionName];
+ invalidTargets.forEach(function (target) {
+ var error;
+ try {
+ f.call(target);
+ } catch (e) {
+ error = e;
+ }
+ if (error === undefined) {
+ $ERROR("Calling " + functionName + " on " + target + " was not rejected.");
+ } else if (error.name !== "TypeError") {
+ $ERROR("Calling " + functionName + " on " + target + " was rejected with wrong error " + error.name + ".");
+ }
+ });
+});
+
diff --git a/js/src/tests/test262/intl402/ch11/11.3/browser.js b/js/src/tests/test262/intl402/ch11/11.3/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/browser.js
diff --git a/js/src/tests/test262/intl402/ch11/11.3/shell.js b/js/src/tests/test262/intl402/ch11/11.3/shell.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.3/shell.js
diff --git a/js/src/tests/test262/intl402/ch11/11.4/11.4_a.js b/js/src/tests/test262/intl402/ch11/11.4/11.4_a.js
new file mode 100644
index 000000000..a562879ec
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.4/11.4_a.js
@@ -0,0 +1,15 @@
+// Copyright 2012 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @description Tests that Intl.NumberFormat instances have the specified properties.
+ * @author Norbert Lindenberg
+ */
+
+var obj = new Intl.NumberFormat();
+
+var toStringValue = Object.prototype.toString.call(obj);
+if (toStringValue !== "[object Object]") {
+ $ERROR("Intl.NumberFormat instance produces wrong [[Class]] - toString returns " + toStringValue + ".");
+}
+
diff --git a/js/src/tests/test262/intl402/ch11/11.4/browser.js b/js/src/tests/test262/intl402/ch11/11.4/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.4/browser.js
diff --git a/js/src/tests/test262/intl402/ch11/11.4/shell.js b/js/src/tests/test262/intl402/ch11/11.4/shell.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/11.4/shell.js
diff --git a/js/src/tests/test262/intl402/ch11/browser.js b/js/src/tests/test262/intl402/ch11/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/browser.js
diff --git a/js/src/tests/test262/intl402/ch11/shell.js b/js/src/tests/test262/intl402/ch11/shell.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/test262/intl402/ch11/shell.js