Handle matching no switches.

This commit is contained in:
Tom Alexander 2023-10-04 14:49:08 -04:00
parent 169bf69f5e
commit 32da06776c
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 18 additions and 6 deletions

View File

@ -0,0 +1,2 @@
#+begin_example
#+end_example

View File

@ -1559,12 +1559,20 @@ fn compare_example_block<'b, 's>(
// Compare switches
let switches = get_property_quoted_string(emacs, ":switches")?;
if switches.as_ref().map(String::as_str) != rust.switches {
this_status = DiffStatus::Bad;
message = Some(format!(
"Switches mismatch (emacs != rust) {:?} != {:?}",
switches, rust.switches
));
match (switches.as_ref().map(String::as_str), rust.switches) {
(None, None) => {}
(Some(""), None) => {}
(None, Some("")) => {
unreachable!("The organic parser would return a None instead of an empty string.");
}
(Some(e), Some(r)) if e == r => {}
_ => {
this_status = DiffStatus::Bad;
message = Some(format!(
"Switches mismatch (emacs != rust) {:?} != {:?}",
switches, rust.switches
));
}
}
// Compare number-lines

View File

@ -326,6 +326,7 @@ fn _lesser_block_begin<'b, 'g, 'r, 's, 'c>(
Ok((remaining, name))
}
#[derive(Debug)]
struct ExampleSwitches<'s> {
source: &'s str,
number_lines: Option<SwitchNumberLines>,
@ -334,6 +335,7 @@ struct ExampleSwitches<'s> {
label_format: Option<&'s str>,
}
#[derive(Debug)]
enum SwitchState {
Normal,
NewLineNumber,