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

[WIP] initial typescript conversion #60

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,127 changes: 2,127 additions & 0 deletions typescript/built/diff_match_patch.js

Large diffs are not rendered by default.

129 changes: 129 additions & 0 deletions typescript/built/tests/diff_match_patch_test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!--
Test Harness for diff_match_patch.js (compiled from diff_match_patch.ts)

Copyright 2018 The diff-match-patch Authors.
https://github.com/google/diff-match-patch

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<html>
<head>
<TITLE>Test harness for diff_match_patch.js (compiled from diff_match_patch.ts)</TITLE>
<script type="text/javascript" src="../diff_match_patch.js"></script>
<script type="text/javascript" src="diff_match_patch_test.js"></script>

<script type="text/javascript">
// Counters for unit test results.
var test_good = 0;
var test_bad = 0;

// If expected and actual are the identical, print 'Ok', otherwise 'Fail!'
function assertEquals(msg, expected, actual) {
if (typeof actual == 'undefined') {
// msg is optional.
actual = expected;
expected = msg;
msg = 'Expected: \'' + expected + '\' Actual: \'' + actual + '\'';
}
if (expected === actual) {
document.write('<FONT COLOR="#009900">Ok</FONT><BR>');
test_good++;
return true;
} else {
document.write('<FONT COLOR="#990000"><BIG>Fail!</BIG></FONT><BR>');
msg = msg.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
document.write('<code>' + msg + '</code><BR>');
test_bad++;
return false;
}
}

function assertTrue(msg, actual) {
if (typeof actual == 'undefined') {
// msg is optional.
actual = msg;
return assertEquals(true, actual);
} else {
return assertEquals(msg, true, actual);
}
}

function assertFalse(msg, actual) {
if (typeof actual == 'undefined') {
// msg is optional.
actual = msg;
return assertEquals(false, actual);
} else {
return assertEquals(msg, false, actual);
}
}

function runTests() {
for (var x = 0; x < tests.length; x++) {
document.write('<H3>' + tests[x] + ':</H3>');
eval(tests[x] + '()');
}
}

var tests = [
'testDiffCommonPrefix',
'testDiffCommonSuffix',
'testDiffCommonOverlap',
'testDiffHalfMatch',
'testDiffLinesToChars',
'testDiffCharsToLines',
'testDiffCleanupMerge',
'testDiffCleanupSemanticLossless',
'testDiffCleanupSemantic',
'testDiffCleanupEfficiency',
'testDiffPrettyHtml',
'testDiffText',
'testDiffDelta',
'testDiffXIndex',
'testDiffLevenshtein',
'testDiffBisect',
'testDiffMain',

'testMatchAlphabet',
'testMatchBitap',
'testMatchMain',

'testPatchObj',
'testPatchFromText',
'testPatchToText',
'testPatchAddContext',
'testPatchMake',
'testPatchSplitMax',
'testPatchAddPadding',
'testPatchApply'];

</script>
</head>
<body>
<H1>Test harness for diff_match_patch.js (compiled from diff_match_patch.ts)</H1>

<P>If debugging errors, start with the first reported error,
subsequent tests often rely on earlier ones.</P>

<script type="text/javascript">
var startTime = (new Date()).getTime();
runTests();
var endTime = (new Date()).getTime();
document.write('<H3>Done.</H3>');
document.write('<P>Tests passed: ' + test_good + '<BR>Tests failed: ' + test_bad + '</P>');
document.write('<P>Total time: ' + (endTime - startTime) + ' ms</P>');
</script>
</body>
</html>
Loading