Compare radio target properties.

This commit is contained in:
Tom Alexander
2023-10-07 01:24:32 -04:00
parent 8d9ff77799
commit c70eb69ed6
3 changed files with 36 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
use std::borrow::Cow;
// TODO: Add a check for unexpected keys in the properties
// TODO: Update all to use the macro to assert there are no unexpected keys.
// TODO: Check all compare funtions for whether they correctly iterate children.
use std::collections::BTreeSet;
use std::collections::HashSet;
@@ -2893,14 +2894,31 @@ fn compare_radio_link<'b, 's>(
}
fn compare_radio_target<'b, 's>(
_source: &'s str,
source: &'s str,
emacs: &'b Token<'s>,
rust: &'b RadioTarget<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let this_status = DiffStatus::Good;
let message = None;
let children = emacs.as_list()?;
let mut this_status = DiffStatus::Good;
let mut child_status = Vec::new();
let mut message = None;
// TODO: Compare :value
if let Some((new_status, new_message)) = compare_properties!(
emacs,
rust,
(
EmacsField::Required(":value"),
|r| Some(r.value),
compare_property_quoted_string
)
)? {
this_status = new_status;
message = new_message;
}
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
}
Ok(DiffResult {
status: this_status,