summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/warp/string-charCodeAt-constant-index-in-left-rope-child.js
blob: 5835b019ad4333ffabe6c1629ff68a94a08b0fea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// `str.charCodeAt(0)` doesn't need to inspect the right rope child, because
// the first character is guaranteed to be in the left child.

const ropes = [
  newRope("ABCDEFGHIJKL", "MNOPQRSTUVWXYZ"),
  newRope("abcdefghijkl", "mnopqrstuvwxyz"),

  newRope("A", "BCDEFGHIJKLMNOPQRSTUVWXYZ"),
  newRope("a", "bcdefghijklmnopqrstuvwxyz"),
];

for (let i = 0; i < 500; ++i) {
  let rope = ropes[i & 3];

  let actual = rope.charCodeAt(0);
  let expected = 0x41 + (i & 1) * 0x20;
  assertEq(actual, expected);
}