2 var left = newRope("@ABCDEFGHIJKLMNO", "PQRSTUVWXYZ[\\]^_");
3 var right = newRope("`abcdefghijklmno", "pqrstuvwxyz{|}~");
4 var rope = newRope(left, right);
5 return {left, right, rope};
8 // Load a character from the left rope child using a constant index. The input
9 // to String.prototype.at is always rope.
10 function testLeftChildConstant() {
11 for (var i = 0; i < 200; ++i) {
12 var {rope} = makeRope();
18 for (var i = 0; i < 2; ++i) {
19 testLeftChildConstant();
22 // Load a character from the right rope child using a constant index. The input
23 // to String.prototype.at is always rope.
24 function testRightChildConstant() {
25 for (var i = 0; i < 200; ++i) {
26 var {rope} = makeRope();
32 for (var i = 0; i < 2; ++i) {
33 testRightChildConstant();
36 // Load a character from the left rope child using a variable index. The input
37 // to String.prototype.at is always rope.
38 function testLeftChildVariable() {
39 for (var i = 0; i < 200; ++i) {
40 var {left, rope} = makeRope();
42 var idx = i % left.length;
43 var ch = rope.at(idx);
44 assertEq(ch, String.fromCharCode(0x40 + idx));
47 for (var i = 0; i < 2; ++i) {
48 testLeftChildVariable();
51 // Load a character from the right rope child using a variable index. The input
52 // to String.prototype.at is always rope.
53 function testRightChildVariable() {
54 for (var i = 0; i < 200; ++i) {
55 var {left, right, rope} = makeRope();
57 var idx = i % right.length;
58 var ch = rope.at(left.length + idx);
59 assertEq(ch, String.fromCharCode(0x60 + idx));
62 for (var i = 0; i < 2; ++i) {
63 testRightChildVariable();
66 // Load all characters from both child ropes. This covers the case when the
67 // call to String.prototype.at linearizes the rope.
68 function testBothChildren() {
69 for (var i = 0; i < 200; ++i) {
70 var {rope} = makeRope();
72 for (var j = 0; j < rope.length; ++j) {
74 assertEq(ch, String.fromCharCode(0x40 + j));
78 for (var i = 0; i < 2; ++i) {