summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/Array/from_string.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/Array/from_string.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/Array/from_string.js')
-rw-r--r--js/src/tests/ecma_6/Array/from_string.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Array/from_string.js b/js/src/tests/ecma_6/Array/from_string.js
new file mode 100644
index 000000000..3ad19e253
--- /dev/null
+++ b/js/src/tests/ecma_6/Array/from_string.js
@@ -0,0 +1,23 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/ */
+
+// Array.from on a string iterates over the string.
+assertDeepEq(Array.from("test string"),
+ ['t', 'e', 's', 't', ' ', 's', 't', 'r', 'i', 'n', 'g']);
+
+// Array.from on a string handles surrogate pairs correctly.
+var gclef = "\uD834\uDD1E"; // U+1D11E MUSICAL SYMBOL G CLEF
+assertDeepEq(Array.from(gclef), [gclef]);
+assertDeepEq(Array.from(gclef + " G"), [gclef, " ", "G"]);
+
+// Array.from on a string calls the @@iterator method.
+String.prototype[Symbol.iterator] = function* () { yield 1; yield 2; };
+assertDeepEq(Array.from("anything"), [1, 2]);
+
+// If the iterator method is deleted, Strings are still arraylike.
+delete String.prototype[Symbol.iterator];
+assertDeepEq(Array.from("works"), ['w', 'o', 'r', 'k', 's']);
+assertDeepEq(Array.from(gclef), ['\uD834', '\uDD1E']);
+
+if (typeof reportCompare === 'function')
+ reportCompare(0, 0);