compare_properties comment block.
This commit is contained in:
parent
0d0b1b2051
commit
ec98e1c3c5
@ -1892,39 +1892,51 @@ fn compare_verse_block<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_comment_block<'b, 's>(
|
fn compare_comment_block<'b, 's>(
|
||||||
_source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b CommentBlock<'s>,
|
rust: &'b CommentBlock<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
let mut child_status = Vec::new();
|
||||||
let mut message = None;
|
let mut message = None;
|
||||||
|
|
||||||
// TODO: Compare :caption
|
assert_no_children(emacs, &mut this_status, &mut message)?;
|
||||||
// Compare name
|
|
||||||
let name = get_property_quoted_string(emacs, ":name")?;
|
|
||||||
if name.as_ref().map(String::as_str) != rust.name {
|
|
||||||
this_status = DiffStatus::Bad;
|
|
||||||
message = Some(format!(
|
|
||||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
name, rust.name
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare value
|
for diff in compare_properties!(
|
||||||
let contents = get_property_quoted_string(emacs, ":value")?.unwrap_or(String::new());
|
source,
|
||||||
if contents != rust.contents {
|
emacs,
|
||||||
this_status = DiffStatus::Bad;
|
rust,
|
||||||
message = Some(format!(
|
(
|
||||||
"Value mismatch (emacs != rust) {:?} != {:?}",
|
EmacsField::Optional(":name"),
|
||||||
contents, rust.contents
|
|r| r.name,
|
||||||
));
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Optional(":caption"),
|
||||||
|
compare_identity,
|
||||||
|
compare_noop
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":value"),
|
||||||
|
|r| Some(r.contents),
|
||||||
|
compare_property_quoted_string
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
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 {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
name: rust.get_elisp_name(),
|
name: rust.get_elisp_name(),
|
||||||
message,
|
message,
|
||||||
children: Vec::new(),
|
children: child_status,
|
||||||
rust_source: rust.get_source(),
|
rust_source: rust.get_source(),
|
||||||
emacs_token: emacs,
|
emacs_token: emacs,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user