summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/String/fromCodePoint.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_6/String/fromCodePoint.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_6/String/fromCodePoint.js')
-rw-r--r--js/src/tests/ecma_6/String/fromCodePoint.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/String/fromCodePoint.js b/js/src/tests/ecma_6/String/fromCodePoint.js
new file mode 100644
index 000000000..dad61663f
--- /dev/null
+++ b/js/src/tests/ecma_6/String/fromCodePoint.js
@@ -0,0 +1,60 @@
+var BUGNUMBER = 918879;
+var summary = 'String.fromCodePoint';
+
+print(BUGNUMBER + ": " + summary);
+
+// Tests taken from:
+// https://github.com/mathiasbynens/String.fromCodePoint/blob/master/tests/tests.js
+
+assertEq(String.fromCodePoint.length, 1);
+assertEq(String.fromCodePoint.name, 'fromCodePoint');
+assertEq(String.propertyIsEnumerable('fromCodePoint'), false);
+
+assertEq(String.fromCodePoint(''), '\0');
+assertEq(String.fromCodePoint(), '');
+assertEq(String.fromCodePoint(-0), '\0');
+assertEq(String.fromCodePoint(0), '\0');
+assertEq(String.fromCodePoint(0x1D306), '\uD834\uDF06');
+assertEq(String.fromCodePoint(0x1D306, 0x61, 0x1D307), '\uD834\uDF06a\uD834\uDF07');
+assertEq(String.fromCodePoint(0x61, 0x62, 0x1D307), 'ab\uD834\uDF07');
+assertEq(String.fromCodePoint(false), '\0');
+assertEq(String.fromCodePoint(null), '\0');
+
+assertThrowsInstanceOf(function() { String.fromCodePoint('_'); }, RangeError);
+assertThrowsInstanceOf(function() { String.fromCodePoint('+Infinity'); }, RangeError);
+assertThrowsInstanceOf(function() { String.fromCodePoint('-Infinity'); }, RangeError);
+assertThrowsInstanceOf(function() { String.fromCodePoint(-1); }, RangeError);
+assertThrowsInstanceOf(function() { String.fromCodePoint(0x10FFFF + 1); }, RangeError);
+assertThrowsInstanceOf(function() { String.fromCodePoint(3.14); }, RangeError);
+assertThrowsInstanceOf(function() { String.fromCodePoint(3e-2); }, RangeError);
+assertThrowsInstanceOf(function() { String.fromCodePoint(Infinity); }, RangeError);
+assertThrowsInstanceOf(function() { String.fromCodePoint(NaN); }, RangeError);
+assertThrowsInstanceOf(function() { String.fromCodePoint(undefined); }, RangeError);
+assertThrowsInstanceOf(function() { String.fromCodePoint({}); }, RangeError);
+
+var counter = Math.pow(2, 15) * 3 / 2;
+var result = [];
+while (--counter >= 0) {
+ result.push(0); // one code unit per symbol
+}
+String.fromCodePoint.apply(null, result); // must not throw
+
+var counter = Math.pow(2, 15) * 3 / 2;
+var result = [];
+while (--counter >= 0) {
+ result.push(0xFFFF + 1); // two code units per symbol
+}
+String.fromCodePoint.apply(null, result); // must not throw
+
+// str_fromCodePoint_one_arg (single argument, creates an inline string)
+assertEq(String.fromCodePoint(0x31), '1');
+// str_fromCodePoint_few_args (few arguments, creates an inline string)
+// JSFatInlineString::MAX_LENGTH_TWO_BYTE / 2 = floor(11 / 2) = 5
+assertEq(String.fromCodePoint(0x31, 0x32), '12');
+assertEq(String.fromCodePoint(0x31, 0x32, 0x33), '123');
+assertEq(String.fromCodePoint(0x31, 0x32, 0x33, 0x34), '1234');
+assertEq(String.fromCodePoint(0x31, 0x32, 0x33, 0x34, 0x35), '12345');
+// str_fromCodePoint (many arguments, creates a malloc string)
+assertEq(String.fromCodePoint(0x31, 0x32, 0x33, 0x34, 0x35, 0x36), '123456');
+
+reportCompare(0, 0, "ok");