Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Commit 1b99c81

Browse files
NeilFraserrgbkrk
authored andcommitted
initial typescript conversion
1 parent 28e5e59 commit 1b99c81

File tree

7 files changed

+6712
-0
lines changed

7 files changed

+6712
-0
lines changed

typescript/built/diff_match_patch.js

Lines changed: 2127 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2+
<!--
3+
Test Harness for diff_match_patch.js (compiled from diff_match_patch.ts)
4+
5+
Copyright 2018 The diff-match-patch Authors.
6+
https://github.com/google/diff-match-patch
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
-->
20+
21+
<html>
22+
<head>
23+
<TITLE>Test harness for diff_match_patch.js (compiled from diff_match_patch.ts)</TITLE>
24+
<script type="text/javascript" src="../diff_match_patch.js"></script>
25+
<script type="text/javascript" src="diff_match_patch_test.js"></script>
26+
27+
<script type="text/javascript">
28+
// Counters for unit test results.
29+
var test_good = 0;
30+
var test_bad = 0;
31+
32+
// If expected and actual are the identical, print 'Ok', otherwise 'Fail!'
33+
function assertEquals(msg, expected, actual) {
34+
if (typeof actual == 'undefined') {
35+
// msg is optional.
36+
actual = expected;
37+
expected = msg;
38+
msg = 'Expected: \'' + expected + '\' Actual: \'' + actual + '\'';
39+
}
40+
if (expected === actual) {
41+
document.write('<FONT COLOR="#009900">Ok</FONT><BR>');
42+
test_good++;
43+
return true;
44+
} else {
45+
document.write('<FONT COLOR="#990000"><BIG>Fail!</BIG></FONT><BR>');
46+
msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
47+
document.write('<code>' + msg + '</code><BR>');
48+
test_bad++;
49+
return false;
50+
}
51+
}
52+
53+
function assertTrue(msg, actual) {
54+
if (typeof actual == 'undefined') {
55+
// msg is optional.
56+
actual = msg;
57+
return assertEquals(true, actual);
58+
} else {
59+
return assertEquals(msg, true, actual);
60+
}
61+
}
62+
63+
function assertFalse(msg, actual) {
64+
if (typeof actual == 'undefined') {
65+
// msg is optional.
66+
actual = msg;
67+
return assertEquals(false, actual);
68+
} else {
69+
return assertEquals(msg, false, actual);
70+
}
71+
}
72+
73+
function runTests() {
74+
for (var x = 0; x < tests.length; x++) {
75+
document.write('<H3>' + tests[x] + ':</H3>');
76+
eval(tests[x] + '()');
77+
}
78+
}
79+
80+
var tests = [
81+
'testDiffCommonPrefix',
82+
'testDiffCommonSuffix',
83+
'testDiffCommonOverlap',
84+
'testDiffHalfMatch',
85+
'testDiffLinesToChars',
86+
'testDiffCharsToLines',
87+
'testDiffCleanupMerge',
88+
'testDiffCleanupSemanticLossless',
89+
'testDiffCleanupSemantic',
90+
'testDiffCleanupEfficiency',
91+
'testDiffPrettyHtml',
92+
'testDiffText',
93+
'testDiffDelta',
94+
'testDiffXIndex',
95+
'testDiffLevenshtein',
96+
'testDiffBisect',
97+
'testDiffMain',
98+
99+
'testMatchAlphabet',
100+
'testMatchBitap',
101+
'testMatchMain',
102+
103+
'testPatchObj',
104+
'testPatchFromText',
105+
'testPatchToText',
106+
'testPatchAddContext',
107+
'testPatchMake',
108+
'testPatchSplitMax',
109+
'testPatchAddPadding',
110+
'testPatchApply'];
111+
112+
</script>
113+
</head>
114+
<body>
115+
<H1>Test harness for diff_match_patch.js (compiled from diff_match_patch.ts)</H1>
116+
117+
<P>If debugging errors, start with the first reported error,
118+
subsequent tests often rely on earlier ones.</P>
119+
120+
<script type="text/javascript">
121+
var startTime = (new Date()).getTime();
122+
runTests();
123+
var endTime = (new Date()).getTime();
124+
document.write('<H3>Done.</H3>');
125+
document.write('<P>Tests passed: ' + test_good + '<BR>Tests failed: ' + test_bad + '</P>');
126+
document.write('<P>Total time: ' + (endTime - startTime) + ' ms</P>');
127+
</script>
128+
</body>
129+
</html>

0 commit comments

Comments
 (0)