Implement the comparison.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user