compare_properties keyword.
This commit is contained in:
parent
fc104680eb
commit
c2222c9102
@ -2431,48 +2431,49 @@ fn compare_horizontal_rule<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_keyword<'b, 's>(
|
fn compare_keyword<'b, 's>(
|
||||||
_source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b Keyword<'s>,
|
rust: &'b Keyword<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let child_status = Vec::new();
|
|
||||||
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
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
let key = unquote(
|
for diff in compare_properties!(
|
||||||
get_property(emacs, ":key")?
|
source,
|
||||||
.ok_or("Emacs keywords should have a :key")?
|
emacs,
|
||||||
.as_atom()?,
|
rust,
|
||||||
)?;
|
(
|
||||||
if key != rust.key.to_uppercase() {
|
EmacsField::Optional(":name"),
|
||||||
this_status = DiffStatus::Bad;
|
|r| r.name,
|
||||||
message = Some(format!(
|
compare_property_quoted_string
|
||||||
"Mismatchs keyword keys (emacs != rust) {:?} != {:?}",
|
),
|
||||||
key, rust.key
|
(
|
||||||
))
|
EmacsField::Optional(":caption"),
|
||||||
}
|
compare_identity,
|
||||||
let value = unquote(
|
compare_noop
|
||||||
get_property(emacs, ":value")?
|
),
|
||||||
.ok_or("Emacs keywords should have a :value")?
|
(
|
||||||
.as_atom()?,
|
EmacsField::Required(":key"),
|
||||||
)?;
|
|r| Some(r.key.to_uppercase()),
|
||||||
if value != rust.value {
|
compare_property_quoted_string
|
||||||
this_status = DiffStatus::Bad;
|
),
|
||||||
message = Some(format!(
|
(
|
||||||
"Mismatchs keyword values (emacs != rust) {:?} != {:?}",
|
EmacsField::Required(":value"),
|
||||||
value, rust.value
|
|r| Some(r.value),
|
||||||
))
|
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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user