Retain labels is actually either a boolean or a number.

This commit is contained in:
Tom Alexander
2023-10-04 15:43:09 -04:00
parent 301a6db83e
commit bcade66e68
4 changed files with 61 additions and 12 deletions

View File

@@ -77,6 +77,7 @@ use crate::types::RadioTarget;
use crate::types::RegularLink;
use crate::types::RepeaterType;
use crate::types::RepeaterWarningDelayValueType;
use crate::types::RetainLabels;
use crate::types::Section;
use crate::types::SpecialBlock;
use crate::types::SrcBlock;
@@ -1625,13 +1626,45 @@ fn compare_example_block<'b, 's>(
}
// Compare retain-labels
let retain_labels: Option<CharOffsetInLine> = get_property_numeric(emacs, ":retain-labels")?;
if retain_labels != rust.retain_labels {
this_status = DiffStatus::Bad;
message = Some(format!(
"Retain labels mismatch (emacs != rust) {:?} != {:?}",
retain_labels, rust.retain_labels
));
// retain-labels is t by default, nil if -r is set, or a number if -k is set.
let retain_labels = get_property_unquoted_atom(emacs, ":retain-labels")?;
if let Some(retain_labels) = retain_labels {
if retain_labels == "t" {
match rust.retain_labels {
RetainLabels::Yes => {}
_ => {
this_status = DiffStatus::Bad;
message = Some(format!(
"Retain labels mismatch (emacs != rust) {:?} != {:?}",
retain_labels, rust.retain_labels
));
}
}
} else {
let retain_labels: CharOffsetInLine = get_property_numeric(emacs, ":retain-labels")?.expect("Cannot be None or else the earlier get_property_unquoted_atom would have been None.");
match (retain_labels, &rust.retain_labels) {
(e, RetainLabels::Keep(r)) if e == *r => {}
_ => {
this_status = DiffStatus::Bad;
message = Some(format!(
"Retain labels mismatch (emacs != rust) {:?} != {:?}",
retain_labels, rust.retain_labels
));
}
}
// foo
}
} else {
match rust.retain_labels {
RetainLabels::No => {}
_ => {
this_status = DiffStatus::Bad;
message = Some(format!(
"Retain labels mismatch (emacs != rust) {:?} != {:?}",
retain_labels, rust.retain_labels
));
}
}
}
// Compare use-labels