~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/jit-test/tests/jaeger/inline/stringCharAt.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
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
 
12
 
 
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), "");
 
23
 
 
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");
 
34
 
 
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");
 
43
 
 
44
/* Other 'this'. */
 
45
var arr = [1, 2];
 
46
arr.charAt = String.prototype.charAt;
 
47
assertEq(arr.charAt(1), ",");
 
48
 
 
49