Compare post-blank.
This commit is contained in:
parent
92592104a4
commit
49bc51ba89
@ -47,6 +47,7 @@ pub(crate) fn compare_standard_properties<
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
assert_name(emacs, rust.get_elisp_fact().get_elisp_name())?;
|
||||
assert_bounds(original_document, emacs, rust)?;
|
||||
assert_post_blank(emacs, rust)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -112,13 +113,32 @@ fn assert_bounds<'b, 's, S: StandardProperties<'s> + ?Sized>(
|
||||
let rust_end_char_offset =
|
||||
rust_begin_char_offset + original_document[rust_begin..rust_end].chars().count(); // 1-based
|
||||
if rust_begin_char_offset != begin || rust_end_char_offset != end {
|
||||
Err(format!("Rust bounds (in chars) ({rust_begin}, {rust_end}) do not match emacs bounds ({emacs_begin}, {emacs_end})", rust_begin = rust_begin_char_offset, rust_end = rust_end_char_offset, emacs_begin=begin, emacs_end=end))?;
|
||||
Err(format!("Rust contents bounds (in chars) ({rust_begin}, {rust_end}) do not match emacs contents bounds ({emacs_begin}, {emacs_end})", rust_begin = rust_begin_char_offset, rust_end = rust_end_char_offset, emacs_begin=begin, emacs_end=end))?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Assert that the post blank matches between emacs and organic.
|
||||
///
|
||||
/// This does **not** handle plain text because plain text is a special case.
|
||||
fn assert_post_blank<'b, 's, S: StandardProperties<'s> + ?Sized>(
|
||||
emacs: &'b Token<'s>,
|
||||
rust: &'b S,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let standard_properties = get_emacs_standard_properties(emacs)?; // 1-based
|
||||
let rust_post_blank = rust.get_post_blank().chars().count();
|
||||
let emacs_post_blank = standard_properties
|
||||
.post_blank
|
||||
.ok_or("Token should have a post-blank.")?;
|
||||
if rust_post_blank != emacs_post_blank {
|
||||
Err(format!("Rust post-blank (in chars) {rust_post_blank} does not match emacs post-blank ({emacs_post_blank})", rust_post_blank = rust_post_blank, emacs_post_blank = emacs_post_blank))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
struct EmacsStandardProperties {
|
||||
begin: Option<usize>,
|
||||
#[allow(dead_code)]
|
||||
|
Loading…
Reference in New Issue
Block a user