js/src/jit-test/tests/jaeger/inline/stringCharCodeAt.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial