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

Commit 97c9f4c

Browse files
committed
Add hack so Dart tests can call private methods.
1 parent a32a5f4 commit 97c9f4c

File tree

2 files changed

+121
-60
lines changed

2 files changed

+121
-60
lines changed

dart/DMPClass.dart

+63
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,13 @@ class DiffMatchPatch {
408408
];
409409
}
410410

411+
/**
412+
* Hack to allow unit tests to call private method. Do not use.
413+
*/
414+
List<Diff> test_diff_bisect(String text1, String text2, DateTime deadline) {
415+
return _diff_bisect(text1, text2, deadline);
416+
}
417+
411418
/**
412419
* Given the location of the 'middle snake', split the diff in two parts
413420
* and recurse.
@@ -458,6 +465,13 @@ class DiffMatchPatch {
458465
return {'chars1': chars1, 'chars2': chars2, 'lineArray': lineArray};
459466
}
460467

468+
/**
469+
* Hack to allow unit tests to call private method. Do not use.
470+
*/
471+
Map<String, dynamic> test_diff_linesToChars(String text1, String text2) {
472+
return _diff_linesToChars(text1, text2);
473+
}
474+
461475
/**
462476
* Split a text into a list of strings. Reduce the texts to a string of
463477
* hashes where each Unicode character represents one line.
@@ -520,6 +534,13 @@ class DiffMatchPatch {
520534
}
521535
}
522536

537+
/**
538+
* Hack to allow unit tests to call private method. Do not use.
539+
*/
540+
void test_diff_charsToLines(List<Diff> diffs, List<String> lineArray) {
541+
_diff_charsToLines(diffs, lineArray);
542+
}
543+
523544
/**
524545
* Determine the common prefix of two strings
525546
* [text1] is the first string.
@@ -607,6 +628,13 @@ class DiffMatchPatch {
607628
}
608629
}
609630

631+
/**
632+
* Hack to allow unit tests to call private method. Do not use.
633+
*/
634+
int test_diff_commonOverlap(String text1, String text2) {
635+
return _diff_commonOverlap(text1, text2);
636+
}
637+
610638
/**
611639
* Do the two texts share a substring which is at least half the length of
612640
* the longer text?
@@ -655,6 +683,13 @@ class DiffMatchPatch {
655683
}
656684
}
657685

686+
/**
687+
* Hack to allow unit tests to call private method. Do not use.
688+
*/
689+
List<String> test_diff_halfMatch(String text1, String text2) {
690+
return _diff_halfMatch(text1, text2);
691+
}
692+
658693
/**
659694
* Does a substring of shorttext exist within longtext such that the
660695
* substring is at least half the length of longtext?
@@ -937,6 +972,13 @@ class DiffMatchPatch {
937972
}
938973
}
939974

975+
/**
976+
* Hack to allow unit tests to call private method. Do not use.
977+
*/
978+
void test_diff_cleanupSemanticLossless(List<Diff> diffs) {
979+
_diff_cleanupSemanticLossless(diffs);
980+
}
981+
940982
// Define some regex patterns for matching boundaries.
941983
RegExp nonAlphaNumericRegex_ = new RegExp(r'[^a-zA-Z0-9]');
942984
RegExp whitespaceRegex_ = new RegExp(r'\s');
@@ -1540,6 +1582,13 @@ class DiffMatchPatch {
15401582
return best_loc;
15411583
}
15421584

1585+
/**
1586+
* Hack to allow unit tests to call private method. Do not use.
1587+
*/
1588+
int test_match_bitap(String text, String pattern, int loc) {
1589+
return _match_bitap(text, pattern, loc);
1590+
}
1591+
15431592
/**
15441593
* Compute and return the score for a match with e errors and x location.
15451594
* [e] is the number of errors in match.
@@ -1574,6 +1623,13 @@ class DiffMatchPatch {
15741623
return s;
15751624
}
15761625

1626+
/**
1627+
* Hack to allow unit tests to call private method. Do not use.
1628+
*/
1629+
Map<String, int> test_match_alphabet(String pattern) {
1630+
return _match_alphabet(pattern);
1631+
}
1632+
15771633
// PATCH FUNCTIONS
15781634

15791635
/**
@@ -1620,6 +1676,13 @@ class DiffMatchPatch {
16201676
patch.length2 += prefix.length + suffix.length;
16211677
}
16221678

1679+
/**
1680+
* Hack to allow unit tests to call private method. Do not use.
1681+
*/
1682+
void test_patch_addContext(Patch patch, String text) {
1683+
_patch_addContext(patch, text);
1684+
}
1685+
16231686
/**
16241687
* Compute a list of patches to turn text1 into text2.
16251688
* Use diffs if provided, otherwise compute it ourselves.

0 commit comments

Comments
 (0)