summaryrefslogtreecommitdiff
path: root/test/suite/intl402/ch12/12.3
diff options
context:
space:
mode:
Diffstat (limited to 'test/suite/intl402/ch12/12.3')
-rw-r--r--test/suite/intl402/ch12/12.3/12.3.1.js21
-rw-r--r--test/suite/intl402/ch12/12.3/12.3.2_2.js34
-rw-r--r--test/suite/intl402/ch12/12.3/12.3.2_3.js26
-rw-r--r--test/suite/intl402/ch12/12.3/12.3.2_4.js66
-rw-r--r--test/suite/intl402/ch12/12.3/12.3.2_5_b.js34
-rw-r--r--test/suite/intl402/ch12/12.3/12.3.2_5_e.js54
-rw-r--r--test/suite/intl402/ch12/12.3/12.3.js21
7 files changed, 256 insertions, 0 deletions
diff --git a/test/suite/intl402/ch12/12.3/12.3.1.js b/test/suite/intl402/ch12/12.3/12.3.1.js
new file mode 100644
index 000000000..a00c2df53
--- /dev/null
+++ b/test/suite/intl402/ch12/12.3/12.3.1.js
@@ -0,0 +1,21 @@
+// Copyright 2012 Google Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @path intl402/ch12/12.3/12.3.1.js
+ * @description Tests that Intl.NumberFormat.prototype.constructor is the
+ * Intl.NumberFormat.
+ * @author: Roozbeh Pournader
+ */
+
+var testcase = function() {
+ "use strict";
+
+ if (Intl.NumberFormat.prototype.constructor !== Intl.NumberFormat) {
+ $ERROR("Intl.NumberFormat.prototype.constructor is not the same as "
+ +"Intl.NumberFormat");
+ }
+
+ return true;
+}
+runTestCase(testcase);
diff --git a/test/suite/intl402/ch12/12.3/12.3.2_2.js b/test/suite/intl402/ch12/12.3/12.3.2_2.js
new file mode 100644
index 000000000..09fafe15d
--- /dev/null
+++ b/test/suite/intl402/ch12/12.3/12.3.2_2.js
@@ -0,0 +1,34 @@
+// Copyright 2012 Google Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @path intl402/ch12/12.3/12.3.2_2.js
+ * @description Tests that Intl.NumberFormat.prototype.format
+ * converts other types to numbers.
+ * @author: Roozbeh Pournader
+ */
+
+var testcase = function() {
+ "use strict";
+
+ var formatter = new Intl.NumberFormat();
+ var testData = [undefined, null, true, '0.6666666'];
+ 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+'"');
+ }
+ }
+
+ return true;
+}
+runTestCase(testcase);
diff --git a/test/suite/intl402/ch12/12.3/12.3.2_3.js b/test/suite/intl402/ch12/12.3/12.3.2_3.js
new file mode 100644
index 000000000..21fc256fe
--- /dev/null
+++ b/test/suite/intl402/ch12/12.3/12.3.2_3.js
@@ -0,0 +1,26 @@
+// Copyright 2012 Google Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @path intl402/ch12/12.3/12.3.2_3.js
+ * @description Tests that Intl.NumberFormat.prototype.format
+ * doesn't treat all numbers as negative.
+ * @author: Roozbeh Pournader
+ */
+
+var testcase = function() {
+ "use strict";
+
+ 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.');
+ }
+
+ return true;
+}
+runTestCase(testcase);
diff --git a/test/suite/intl402/ch12/12.3/12.3.2_4.js b/test/suite/intl402/ch12/12.3/12.3.2_4.js
new file mode 100644
index 000000000..c3dae9600
--- /dev/null
+++ b/test/suite/intl402/ch12/12.3/12.3.2_4.js
@@ -0,0 +1,66 @@
+// Copyright 2012 Google Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @path intl402/ch12/12.3/12.3.2_4.js
+ * @description Tests that Intl.NumberFormat.prototype.format
+ * hangles NaN, Infinity, and -Infinity properly.
+ * @author: Roozbeh Pournader
+ */
+
+var testcase = function() {
+ "use strict";
+
+ // 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('.*([' +
+ '\u0030-\u0039\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 ' +
+ 'negaive 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.');
+ }
+
+ return true;
+}
+runTestCase(testcase);
diff --git a/test/suite/intl402/ch12/12.3/12.3.2_5_b.js b/test/suite/intl402/ch12/12.3/12.3.2_5_b.js
new file mode 100644
index 000000000..94a900d56
--- /dev/null
+++ b/test/suite/intl402/ch12/12.3/12.3.2_5_b.js
@@ -0,0 +1,34 @@
+// Copyright 2012 Google Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @path intl402/ch12/12.3/12.3.2_5_b.js
+ * @description Tests that Intl.NumberFormat.prototype.format
+ * formats percent values properly.
+ * @author: Roozbeh Pournader
+ */
+
+var testcase = function() {
+ "use strict";
+
+ 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.');
+ }
+
+ return true;
+}
+runTestCase(testcase);
diff --git a/test/suite/intl402/ch12/12.3/12.3.2_5_e.js b/test/suite/intl402/ch12/12.3/12.3.2_5_e.js
new file mode 100644
index 000000000..4d23bd1a9
--- /dev/null
+++ b/test/suite/intl402/ch12/12.3/12.3.2_5_e.js
@@ -0,0 +1,54 @@
+// Copyright 2012 Google Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @path intl402/ch12/12.3/12.3.2_5_e.js
+ * @description Tests that Intl.NumberFormat.prototype.format
+ * supports all alternative numbering systems.
+ * @author: Roozbeh Pournader
+ */
+
+var testcase = function() {
+ "use strict";
+
+ 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
+
+ return true;
+}
+runTestCase(testcase);
diff --git a/test/suite/intl402/ch12/12.3/12.3.js b/test/suite/intl402/ch12/12.3/12.3.js
new file mode 100644
index 000000000..7327197bf
--- /dev/null
+++ b/test/suite/intl402/ch12/12.3/12.3.js
@@ -0,0 +1,21 @@
+// Copyright 2012 Google Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/**
+ * @path intl402/ch12/12.3/12.3.js
+ * @description Tests that Intl.NumberFormat.prototype is an intance of
+ * Intl.NumberFormat.
+ * @author: Roozbeh Pournader
+ */
+
+var testcase = function() {
+ "use strict";
+
+ if (!(Intl.NumberFormat.prototype instanceof Intl.NumberFormat)) {
+ $ERROR("Intl.NumberFormat's prototype is not an instance of " +
+ "Intl.NumberFormat");
+ }
+
+ return true;
+}
+runTestCase(testcase);