From f5218a6c311a743ca2ddb576fe4292479edb329f Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 21 Apr 2023 18:05:40 -0400 Subject: [PATCH] Implement comparing the lesser blocks. --- src/compare/diff.rs | 89 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 52f6c16..d471e02 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -564,7 +564,26 @@ fn compare_verse_block<'s>( emacs: &'s Token<'s>, rust: &'s VerseBlock<'s>, ) -> Result> { - todo!() + let children = emacs.as_list()?; + let mut child_status = Vec::new(); + let mut this_status = DiffStatus::Good; + let emacs_name = "verse-block"; + if assert_name(emacs, emacs_name).is_err() { + this_status = DiffStatus::Bad; + } + + if assert_bounds(source, emacs, rust).is_err() { + this_status = DiffStatus::Bad; + } + + for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {} + + Ok(DiffResult { + status: this_status, + name: emacs_name.to_owned(), + message: None, + children: child_status, + }) } fn compare_comment_block<'s>( @@ -572,7 +591,22 @@ fn compare_comment_block<'s>( emacs: &'s Token<'s>, rust: &'s CommentBlock<'s>, ) -> Result> { - todo!() + let mut this_status = DiffStatus::Good; + let emacs_name = "comment-block"; + if assert_name(emacs, emacs_name).is_err() { + this_status = DiffStatus::Bad; + } + + if assert_bounds(source, emacs, rust).is_err() { + this_status = DiffStatus::Bad; + } + + Ok(DiffResult { + status: this_status, + name: emacs_name.to_owned(), + message: None, + children: Vec::new(), + }) } fn compare_example_block<'s>( @@ -580,7 +614,22 @@ fn compare_example_block<'s>( emacs: &'s Token<'s>, rust: &'s ExampleBlock<'s>, ) -> Result> { - todo!() + let mut this_status = DiffStatus::Good; + let emacs_name = "example-block"; + if assert_name(emacs, emacs_name).is_err() { + this_status = DiffStatus::Bad; + } + + if assert_bounds(source, emacs, rust).is_err() { + this_status = DiffStatus::Bad; + } + + Ok(DiffResult { + status: this_status, + name: emacs_name.to_owned(), + message: None, + children: Vec::new(), + }) } fn compare_export_block<'s>( @@ -588,7 +637,22 @@ fn compare_export_block<'s>( emacs: &'s Token<'s>, rust: &'s ExportBlock<'s>, ) -> Result> { - todo!() + let mut this_status = DiffStatus::Good; + let emacs_name = "export-block"; + if assert_name(emacs, emacs_name).is_err() { + this_status = DiffStatus::Bad; + } + + if assert_bounds(source, emacs, rust).is_err() { + this_status = DiffStatus::Bad; + } + + Ok(DiffResult { + status: this_status, + name: emacs_name.to_owned(), + message: None, + children: Vec::new(), + }) } fn compare_src_block<'s>( @@ -596,5 +660,20 @@ fn compare_src_block<'s>( emacs: &'s Token<'s>, rust: &'s SrcBlock<'s>, ) -> Result> { - todo!() + let mut this_status = DiffStatus::Good; + let emacs_name = "src-block"; + if assert_name(emacs, emacs_name).is_err() { + this_status = DiffStatus::Bad; + } + + if assert_bounds(source, emacs, rust).is_err() { + this_status = DiffStatus::Bad; + } + + Ok(DiffResult { + status: this_status, + name: emacs_name.to_owned(), + message: None, + children: Vec::new(), + }) }