Improve compact diff API (#24)
* Remove is_binary from API * Format * Rename file * Test with more feature combinations * Don't depend on serde for wasm * Fix lint & tests * Don't unwrap to MAX number * Expose undiff to JS * Add undiff tests * Lint * Change name
This commit is contained in:
parent
6191d1adb3
commit
e85eb485e8
20 changed files with 430 additions and 424 deletions
|
|
@ -3,7 +3,7 @@ mod example_document;
|
|||
use std::{fs, path::Path};
|
||||
|
||||
use example_document::ExampleDocument;
|
||||
use reconcile_text::{BuiltinTokenizer, EditedText, reconcile};
|
||||
use reconcile_text::{BuiltinTokenizer, reconcile};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[test]
|
||||
|
|
@ -34,8 +34,11 @@ fn test_document_one_way_with_cursors() {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
#[test]
|
||||
fn test_document_one_way_with_cursors_and_serialisation() {
|
||||
fn test_document_one_way_with_serialisation() {
|
||||
use reconcile_text::EditedText;
|
||||
|
||||
for doc in &get_all_documents() {
|
||||
let parent = doc.parent();
|
||||
let left_operations =
|
||||
|
|
@ -47,19 +50,23 @@ fn test_document_one_way_with_cursors_and_serialisation() {
|
|||
);
|
||||
|
||||
let serialised_left =
|
||||
serde_yaml::from_str(&serde_yaml::to_string(&left_operations.to_change_set()).unwrap())
|
||||
serde_yaml::from_str(&serde_yaml::to_string(&left_operations.to_diff()).unwrap())
|
||||
.unwrap();
|
||||
let serialised_right =
|
||||
serde_yaml::from_str(&serde_yaml::to_string(&right_operations.to_diff()).unwrap())
|
||||
.unwrap();
|
||||
let serialised_right = serde_yaml::from_str(
|
||||
&serde_yaml::to_string(&right_operations.to_change_set()).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let restored_left_operations =
|
||||
EditedText::from_change_set(&parent, serialised_left, &*BuiltinTokenizer::Word);
|
||||
EditedText::from_diff(&parent, serialised_left, &*BuiltinTokenizer::Word);
|
||||
let restored_right_operations =
|
||||
EditedText::from_change_set(&parent, serialised_right, &*BuiltinTokenizer::Word);
|
||||
EditedText::from_diff(&parent, serialised_right, &*BuiltinTokenizer::Word);
|
||||
|
||||
doc.assert_eq(&restored_left_operations.merge(restored_right_operations));
|
||||
doc.assert_eq_without_cursors(
|
||||
&restored_left_operations
|
||||
.merge(restored_right_operations)
|
||||
.apply()
|
||||
.text(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue