From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../jit-test/tests/jaeger/inline/stringCharAt.js | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 js/src/jit-test/tests/jaeger/inline/stringCharAt.js (limited to 'js/src/jit-test/tests/jaeger/inline/stringCharAt.js') 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), ","); + + -- cgit v1.2.3