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.
michael@0 | 1 | |
michael@0 | 2 | assertEq("foo".charCodeAt(-123), NaN); |
michael@0 | 3 | assertEq("foo".charCodeAt(-0), 102); |
michael@0 | 4 | assertEq("foo".charCodeAt(0), 102); |
michael@0 | 5 | assertEq("foo".charCodeAt(2), 111); |
michael@0 | 6 | assertEq("foo".charCodeAt(3.4), NaN); |
michael@0 | 7 | assertEq("foo".charCodeAt(), 102); |
michael@0 | 8 | assertEq("".charCodeAt(), NaN); |
michael@0 | 9 | assertEq("".charCodeAt(0), NaN); |
michael@0 | 10 | |
michael@0 | 11 | /* Inferred as string.charCodeAt(int). */ |
michael@0 | 12 | function charCodeAt1(x) { |
michael@0 | 13 | return "abc".charCodeAt(x); |
michael@0 | 14 | } |
michael@0 | 15 | assertEq(charCodeAt1(-1), NaN); |
michael@0 | 16 | assertEq(charCodeAt1(0), 97); |
michael@0 | 17 | assertEq(charCodeAt1(1), 98); |
michael@0 | 18 | assertEq(charCodeAt1(2), 99); |
michael@0 | 19 | assertEq(charCodeAt1(3), NaN); |
michael@0 | 20 | assertEq(charCodeAt1(1234), NaN); |
michael@0 | 21 | |
michael@0 | 22 | /* Inferred as string.charCodeAt(double). */ |
michael@0 | 23 | function charCodeAt2(x) { |
michael@0 | 24 | return "abc".charCodeAt(x); |
michael@0 | 25 | } |
michael@0 | 26 | assertEq(charCodeAt2(-1.3), NaN); |
michael@0 | 27 | assertEq(charCodeAt2(-0), 97); |
michael@0 | 28 | assertEq(charCodeAt2(2), 99); |
michael@0 | 29 | assertEq(charCodeAt2(2.3), 99); |
michael@0 | 30 | assertEq(charCodeAt2(3.14), NaN); |
michael@0 | 31 | assertEq(charCodeAt2(NaN), 97); |
michael@0 | 32 | |
michael@0 | 33 | /* Test ropes. */ |
michael@0 | 34 | function charCodeAt3(s, i) { |
michael@0 | 35 | var s2 = "abcdef" + s + "12345"; |
michael@0 | 36 | return s2.charCodeAt(i); |
michael@0 | 37 | } |
michael@0 | 38 | assertEq(charCodeAt3("abcdef", 14), 51); |
michael@0 | 39 | assertEq(charCodeAt3("a" + "b", 1), 98); |
michael@0 | 40 | assertEq(charCodeAt3("abcdefg" + "hijklmnop", 10), 101); |
michael@0 | 41 | |
michael@0 | 42 | /* Other 'this'. */ |
michael@0 | 43 | var n = new Number(123); |
michael@0 | 44 | n.charCodeAt = String.prototype.charCodeAt; |
michael@0 | 45 | assertEq(n.charCodeAt(1), 50); |
michael@0 | 46 | |
michael@0 | 47 |