Implement a compare_property_numeric.

This commit is contained in:
Tom Alexander
2023-10-09 21:04:41 -04:00
parent 8e357ed3b6
commit 166e59b922
2 changed files with 84 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ use super::compare_field::compare_property_always_nil;
use super::compare_field::compare_property_boolean;
use super::compare_field::compare_property_list_of_ast_nodes;
use super::compare_field::compare_property_list_of_quoted_string;
use super::compare_field::compare_property_numeric;
use super::compare_field::compare_property_quoted_string;
use super::compare_field::compare_property_unquoted_atom;
use super::elisp_fact::ElispFact;
@@ -594,6 +595,55 @@ fn compare_section<'b, 's>(
.into())
}
fn new_compare_heading<'b, 's>(
source: &'s str,
emacs: &'b Token<'s>,
rust: &'b Heading<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error + 's>> {
let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None;
compare_children(
source,
emacs,
&rust.children,
&mut child_status,
&mut this_status,
&mut message,
)?;
for diff in compare_properties!(
source,
emacs,
rust,
(
EmacsField::Required(":level"),
|r| Some(r.level),
compare_property_numeric
)
) {
match diff {
ComparePropertiesResult::NoChange => {}
ComparePropertiesResult::SelfChange(new_status, new_message) => {
this_status = new_status;
message = new_message
}
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
}
}
Ok(DiffResult {
status: this_status,
name: rust.get_elisp_name(),
message,
children: child_status,
rust_source: rust.get_source(),
emacs_token: emacs,
}
.into())
}
fn compare_heading<'b, 's>(
source: &'s str,
emacs: &'b Token<'s>,