Starting a compare properties document function.
This commit is contained in:
@@ -284,6 +284,39 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn compare_children_iter<
|
||||
'b,
|
||||
's,
|
||||
'x,
|
||||
RC: 'x,
|
||||
RI: Iterator<Item = &'x RC> + ExactSizeIterator,
|
||||
>(
|
||||
source: &'s str,
|
||||
emacs: &'b Token<'s>,
|
||||
rust_children: RI,
|
||||
child_status: &mut Vec<DiffEntry<'b, 's>>,
|
||||
this_status: &mut DiffStatus,
|
||||
message: &mut Option<String>,
|
||||
) -> Result<(), Box<dyn std::error::Error>>
|
||||
where
|
||||
AstNode<'b, 's>: From<&'x RC>,
|
||||
{
|
||||
let emacs_children = emacs.as_list()?;
|
||||
let emacs_children_length = emacs_children.len() - 2;
|
||||
if emacs_children_length != rust_children.len() {
|
||||
*this_status = DiffStatus::Bad;
|
||||
*message = Some(format!(
|
||||
"Child length mismatch (emacs != rust) {:?} != {:?}",
|
||||
emacs_children_length,
|
||||
rust_children.len()
|
||||
));
|
||||
}
|
||||
for (emacs_child, rust_child) in emacs_children.iter().skip(2).zip(rust_children) {
|
||||
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn assert_no_children<'b, 's>(
|
||||
emacs: &'b Token<'s>,
|
||||
this_status: &mut DiffStatus,
|
||||
|
||||
Reference in New Issue
Block a user