finish support for paragraph move.
This commit is contained in:
@@ -27,7 +27,11 @@ async def start_stop_server():
|
||||
def assert_equal_enough(tokens:List[Token], rev):
|
||||
# the tokens exclude newlines
|
||||
# we allow extra whitespace at the beginning or end
|
||||
assert ''.join([str(t) for t in tokens]).strip() == rev.replace('\n','').strip()
|
||||
token_doc = ''.join(str(t) for t in tokens).strip()
|
||||
rev_doc = rev.replace('\n','').strip()
|
||||
print(token_doc, file = open('token','w'))
|
||||
print(rev_doc, file = open('rev','w'))
|
||||
assert token_doc == rev_doc
|
||||
|
||||
|
||||
def assert_correct_equal_section(ops, expected_equal_lines, expected_equal_tokens):
|
||||
@@ -128,8 +132,6 @@ def test_delete():
|
||||
expected_equal_tokens=9323)
|
||||
|
||||
|
||||
|
||||
|
||||
# first lets test that we properly build the operations.
|
||||
# then we can test if the state seems to work as intended.
|
||||
def test_addition():
|
||||
@@ -170,3 +172,29 @@ def test_addition():
|
||||
assert n_inserted_tokens == last_b2 - initial_equal_tokens == 292
|
||||
assert n_inserts == 2
|
||||
|
||||
def test_paragraph_move():
|
||||
rev1 = open("test/test_diff_revisions/1295229484").read()
|
||||
rev2 = open("test/test_diff_revisions/1295229484_parmove").read()
|
||||
matcher = WikiDiffMatcher([rev1,rev2])
|
||||
diff_processor = matcher.processor()
|
||||
|
||||
# note that a and b are constructed from the diffs.
|
||||
# so they reflect the state of the text according to the diff processor
|
||||
ops, a, b = diff_processor.process(rev1)
|
||||
ops, a, b = diff_processor.process(rev2)
|
||||
assert_equal_enough(b, rev2)
|
||||
assert_equal_enough(a, rev1)
|
||||
|
||||
def test_paragraph_move_and_change():
|
||||
rev1 = open("test/test_diff_revisions/1295229484").read()
|
||||
rev2 = open("test/test_diff_revisions/1295229484_parmove_and_change").read()
|
||||
matcher = WikiDiffMatcher([rev1,rev2])
|
||||
diff_processor = matcher.processor()
|
||||
|
||||
# note that a and b are constructed from the diffs.
|
||||
# so they reflect the state of the text according to the diff processor
|
||||
ops, a, b = diff_processor.process(rev1)
|
||||
ops, a, b = diff_processor.process(rev2)
|
||||
assert_equal_enough(b, rev2)
|
||||
assert_equal_enough(a, rev1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user