Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
2 assertEq("foo".charAt(-123), "");
3 assertEq("foo".charAt(-1), "");
4 assertEq("foo".charAt(0), "f");
5 assertEq("foo".charAt(1), "o");
6 assertEq("foo".charAt(2), "o");
7 assertEq("foo".charAt(3.4), "");
8 assertEq("foo".charAt(), "f");
9 assertEq("".charAt(), "");
10 assertEq("".charAt(0), "");
11 assertEq("abc\u9123".charAt(3), "\u9123"); // char without unit string
13 /* Inferred as string.charAt(int). */
14 function charAt1(x) {
15 return "abc".charAt(x);
16 }
17 assertEq(charAt1(-1), "");
18 assertEq(charAt1(0), "a");
19 assertEq(charAt1(1), "b");
20 assertEq(charAt1(2), "c");
21 assertEq(charAt1(3), "");
22 assertEq(charAt1(1234), "");
24 /* Inferred as string.charAt(double). */
25 function charAt2(x) {
26 return "abc".charAt(x);
27 }
28 assertEq(charAt2(-1.3), "");
29 assertEq(charAt2(-0), "a");
30 assertEq(charAt2(2), "c");
31 assertEq(charAt2(2.3), "c");
32 assertEq(charAt2(3.14), "");
33 assertEq(charAt2(NaN), "a");
35 /* Test ropes. */
36 function charAt3(s, i) {
37 var s2 = "abcdef" + s + "12345";
38 return s2.charAt(i);
39 }
40 assertEq(charAt3("abcdef", 14), "3");
41 assertEq(charAt3("a" + "b", 1), "b");
42 assertEq(charAt3("abcdefg" + "hijklmnop", 10), "e");
44 /* Other 'this'. */
45 var arr = [1, 2];
46 arr.charAt = String.prototype.charAt;
47 assertEq(arr.charAt(1), ",");