rope-char-at.js (882B)
1 function test(a, b, firstCharCode) { 2 var s = newRope(a, b); 3 for (var i = 0; i < s.length; i++) { 4 assertEq(s.charCodeAt(i), firstCharCode + i); 5 assertEq(s.charAt(i), String.fromCharCode(firstCharCode + i)); 6 } 7 // charAt/charCodeAt support one-level deep ropes without linearizing. 8 assertEq(isRope(s), true); 9 assertEq(isRope(a), false); 10 assertEq(isRope(b), false); 11 } 12 test("abcdefghijkl", "mnopqrstuvwxyz", 97); 13 test("a", "bcdefghijklmnopqrstuvwxyz", 97); 14 test("abcdefghijklmnopqrstuvwxy", "z", 97); 15 test("0123456789:;<=>?@ABCDEFGHIJ", "K", 48); 16 test("\u00fe\u00ff", "\u0100\u0101\u0102\u0103\u0104\u0105\u0106\u0107\u0108\u0109\u010A", 0xfe); 17 test("\u1000\u1001\u1002", "\u1003\u1004\u1005\u1006\u1007\u1008\u1009\u100A\u100B\u100C", 4096); 18 19 // charAt/charCodeAt stubs currently fail for nested ropes. 20 test("ab", newRope("cdefghijklmnop", "qrstuvwxyz{|}~"), 97);