summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/jaeger/inline/stringCharAt.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/jit-test/tests/jaeger/inline/stringCharAt.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/jit-test/tests/jaeger/inline/stringCharAt.js')
-rw-r--r--js/src/jit-test/tests/jaeger/inline/stringCharAt.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/jaeger/inline/stringCharAt.js b/js/src/jit-test/tests/jaeger/inline/stringCharAt.js
new file mode 100644
index 000000000..bf2bbbd67
--- /dev/null
+++ b/js/src/jit-test/tests/jaeger/inline/stringCharAt.js
@@ -0,0 +1,49 @@
+
+assertEq("foo".charAt(-123), "");
+assertEq("foo".charAt(-1), "");
+assertEq("foo".charAt(0), "f");
+assertEq("foo".charAt(1), "o");
+assertEq("foo".charAt(2), "o");
+assertEq("foo".charAt(3.4), "");
+assertEq("foo".charAt(), "f");
+assertEq("".charAt(), "");
+assertEq("".charAt(0), "");
+assertEq("abc\u9123".charAt(3), "\u9123"); // char without unit string
+
+/* Inferred as string.charAt(int). */
+function charAt1(x) {
+ return "abc".charAt(x);
+}
+assertEq(charAt1(-1), "");
+assertEq(charAt1(0), "a");
+assertEq(charAt1(1), "b");
+assertEq(charAt1(2), "c");
+assertEq(charAt1(3), "");
+assertEq(charAt1(1234), "");
+
+/* Inferred as string.charAt(double). */
+function charAt2(x) {
+ return "abc".charAt(x);
+}
+assertEq(charAt2(-1.3), "");
+assertEq(charAt2(-0), "a");
+assertEq(charAt2(2), "c");
+assertEq(charAt2(2.3), "c");
+assertEq(charAt2(3.14), "");
+assertEq(charAt2(NaN), "a");
+
+/* Test ropes. */
+function charAt3(s, i) {
+ var s2 = "abcdef" + s + "12345";
+ return s2.charAt(i);
+}
+assertEq(charAt3("abcdef", 14), "3");
+assertEq(charAt3("a" + "b", 1), "b");
+assertEq(charAt3("abcdefg" + "hijklmnop", 10), "e");
+
+/* Other 'this'. */
+var arr = [1, 2];
+arr.charAt = String.prototype.charAt;
+assertEq(arr.charAt(1), ",");
+
+