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,13 +1559,21 @@ fn compare_example_block<'b, 's>(
// Compare switches // Compare switches
let switches = get_property_quoted_string(emacs, ":switches")?; let switches = get_property_quoted_string(emacs, ":switches")?;
if switches.as_ref().map(String::as_str) != 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; this_status = DiffStatus::Bad;
message = Some(format!( message = Some(format!(
"Switches mismatch (emacs != rust) {:?} != {:?}", "Switches mismatch (emacs != rust) {:?} != {:?}",
switches, rust.switches switches, rust.switches
)); ));
} }
}
// Compare number-lines // Compare number-lines
let number_lines = get_property(emacs, ":number-lines")?; let number_lines = get_property(emacs, ":number-lines")?;

View File

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