Implement the comparison.

This commit is contained in:
Tom Alexander
2023-10-06 13:29:46 -04:00
parent d06e4de7b0
commit 1b603f3a05
2 changed files with 47 additions and 5 deletions

View File

@@ -425,6 +425,24 @@ fn compare_ast_node<'b, 's>(
Ok(compare_result.into())
}
fn compare_property_quoted_string_required_value<'b, 's, 'x>(
emacs: &'b Token<'s>,
emacs_field: &'x str,
rust_value: &'s str,
) -> Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> {
let value = get_property_quoted_string(emacs, emacs_field)?;
if value.as_ref().map(String::as_str) != Some(rust_value) {
let this_status = DiffStatus::Bad;
let message = Some(format!(
"{} mismatch (emacs != rust) {:?} != {:?}",
emacs_field, value, rust_value
));
Ok(Some((this_status, message)))
} else {
Ok(None)
}
}
pub fn compare_document<'b, 's>(
emacs: &'b Token<'s>,
rust: &'b Document<'s>,
@@ -2690,8 +2708,15 @@ fn compare_code<'b, 's>(
));
}
let foo: Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> =
compare_properties!(emacs, EmacsField::Required(":value"));
if let Some((new_status, new_message)) = compare_properties!(
emacs,
EmacsField::Required(":value"),
rust.contents,
compare_property_quoted_string_required_value
)? {
this_status = new_status;
message = new_message;
}
Ok(DiffResult {
status: this_status,