compare_properties export block.
This commit is contained in:
parent
bdfa050ee3
commit
0b1e06f0d5
@ -2028,51 +2028,56 @@ fn compare_example_block<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_export_block<'b, 's>(
|
fn compare_export_block<'b, 's>(
|
||||||
_source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b ExportBlock<'s>,
|
rust: &'b ExportBlock<'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 type
|
for diff in compare_properties!(
|
||||||
let export_type = get_property_quoted_string(emacs, ":type")?;
|
source,
|
||||||
let rust_export_type = rust.get_export_type();
|
emacs,
|
||||||
if export_type != rust_export_type {
|
rust,
|
||||||
this_status = DiffStatus::Bad;
|
(
|
||||||
message = Some(format!(
|
EmacsField::Optional(":name"),
|
||||||
"Export type mismatch (emacs != rust) {:?} != {:?}",
|
|r| r.name,
|
||||||
export_type, rust.export_type
|
compare_property_quoted_string
|
||||||
));
|
),
|
||||||
}
|
(
|
||||||
|
EmacsField::Optional(":caption"),
|
||||||
// Compare value
|
compare_identity,
|
||||||
let contents = get_property_quoted_string(emacs, ":value")?.unwrap_or(String::new());
|
compare_noop
|
||||||
if contents != rust.contents {
|
),
|
||||||
this_status = DiffStatus::Bad;
|
(
|
||||||
message = Some(format!(
|
EmacsField::Required(":type"),
|
||||||
"Value mismatch (emacs != rust) {:?} != {:?}",
|
|r| r.get_export_type(),
|
||||||
contents, rust.contents
|
compare_property_quoted_string
|
||||||
));
|
),
|
||||||
}
|
(
|
||||||
|
EmacsField::Required(":value"),
|
||||||
// Compare name
|
|r| Some(r.contents.as_str()),
|
||||||
let name = get_property_quoted_string(emacs, ":name")?;
|
compare_property_quoted_string
|
||||||
if name.as_ref().map(String::as_str) != rust.name {
|
)
|
||||||
this_status = DiffStatus::Bad;
|
) {
|
||||||
message = Some(format!(
|
match diff {
|
||||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
ComparePropertiesResult::NoChange => {}
|
||||||
name, rust.name
|
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…
Reference in New Issue
Block a user