string-charCodeAt-constant-index-in-left-rope-child.js (508B)
1 // `str.charCodeAt(0)` doesn't need to inspect the right rope child, because 2 // the first character is guaranteed to be in the left child. 3 4 const ropes = [ 5 newRope("ABCDEFGHIJKL", "MNOPQRSTUVWXYZ"), 6 newRope("abcdefghijkl", "mnopqrstuvwxyz"), 7 8 newRope("A", "BCDEFGHIJKLMNOPQRSTUVWXYZ"), 9 newRope("a", "bcdefghijklmnopqrstuvwxyz"), 10 ]; 11 12 for (let i = 0; i < 500; ++i) { 13 let rope = ropes[i & 3]; 14 15 let actual = rope.charCodeAt(0); 16 let expected = 0x41 + (i & 1) * 0x20; 17 assertEq(actual, expected); 18 }