You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: javascript/tests/diff_match_patch_test.js
+21-14Lines changed: 21 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -174,9 +174,9 @@ function testDiffLinesToChars() {
174
174
varn=300;
175
175
varlineList=[];
176
176
varcharList=[];
177
-
for(varx=1;x<n+1;x++){
178
-
lineList[x-1]=x+'\n';
179
-
charList[x-1]=String.fromCharCode(x);
177
+
for(vari=1;i<n+1;i++){
178
+
lineList[i-1]=i+'\n';
179
+
charList[i-1]=String.fromCharCode(i);
180
180
}
181
181
assertEquals(n,lineList.length);
182
182
varlines=lineList.join('');
@@ -196,9 +196,9 @@ function testDiffCharsToLines() {
196
196
varn=300;
197
197
varlineList=[];
198
198
varcharList=[];
199
-
for(varx=1;x<n+1;x++){
200
-
lineList[x-1]=x+'\n';
201
-
charList[x-1]=String.fromCharCode(x);
199
+
for(vari=1;i<n+1;i++){
200
+
lineList[i-1]=i+'\n';
201
+
charList[i-1]=String.fromCharCode(i);
202
202
}
203
203
assertEquals(n,lineList.length);
204
204
varlines=lineList.join('');
@@ -208,6 +208,17 @@ function testDiffCharsToLines() {
208
208
vardiffs=[[DIFF_DELETE,chars]];
209
209
dmp.diff_charsToLines_(diffs,lineList);
210
210
assertEquivalent([[DIFF_DELETE,lines]],diffs);
211
+
212
+
// More than 65536 to verify any 16-bit limitation.
213
+
lineList=[];
214
+
for(vari=0;i<66000;i++){
215
+
lineList[i]=i+'\n';
216
+
}
217
+
chars=lineList.join('');
218
+
varresults=dmp.diff_linesToChars_(chars,'');
219
+
diffs=[[DIFF_INSERT,results.chars1]];
220
+
dmp.diff_charsToLines_(diffs,results.lineArray);
221
+
assertEquals(chars,diffs[0][1]);
211
222
}
212
223
213
224
functiontestDiffCleanupMerge(){
@@ -560,8 +571,8 @@ function testDiffMain() {
560
571
varb='I am the very model of a modern major general,\nI\'ve information vegetable, animal, and mineral,\nI know the kings of England, and I quote the fights historical,\nFrom Marathon to Waterloo, in order categorical.\n';
561
572
// Increase the text lengths by 1024 times to ensure a timeout.
562
573
for(varx=0;x<10;x++){
563
-
a=a+a;
564
-
b=b+b;
574
+
a+=a;
575
+
b+=b;
565
576
}
566
577
varstartTime=(newDate()).getTime();
567
578
dmp.diff_main(a,b);
@@ -571,11 +582,7 @@ function testDiffMain() {
571
582
// Test that we didn't take forever (be forgiving).
572
583
// Theoretically this test could fail very occasionally if the
573
584
// OS task swaps or locks up for a second at the wrong moment.
574
-
// ****
575
-
// TODO(fraser): For unknown reasons this is taking 500 ms on Google's
576
-
// internal test system. Whereas browsers take 140 ms.
0 commit comments