Compare the standard properties.
Some checks failed
clippy Build clippy has failed
rust-foreign-document-test Build rust-foreign-document-test has succeeded
rust-build Build rust-build has succeeded
rust-test Build rust-test has succeeded

This commit is contained in:
Tom Alexander
2023-12-27 17:07:42 -05:00
parent 58290515b5
commit a5e108bc37
7 changed files with 95 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
use std::borrow::Cow;
use super::elisp_compare::WasmElispCompare;
use crate::compare::get_emacs_standard_properties;
use crate::compare::get_property_quoted_string;
use crate::compare::ElispFact;
use crate::compare::EmacsField;
@@ -9,6 +10,7 @@ use crate::wasm::WasmAstNode;
use crate::wasm::WasmDocument;
use crate::wasm::WasmHeadline;
use crate::wasm::WasmSection;
use crate::wasm::WasmStandardProperties;
use crate::wasm_test::macros::wasm_compare;
pub fn wasm_compare_document<'b, 's, 'p>(
@@ -343,3 +345,74 @@ fn wasm_compare_property_quoted_string<
}
Ok(result)
}
fn wasm_compare_standard_properties<'b, 's>(
_source: &'s str,
emacs: &'b Token<'s>,
wasm: &WasmStandardProperties,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default();
let mut layer = WasmDiffResult::default();
layer.name = "standard-properties".into();
let standard_properties = get_emacs_standard_properties(emacs)?;
if Some(wasm.begin) != standard_properties.begin {
layer.status.push(WasmDiffStatus::Bad(
format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = "begin",
emacs = standard_properties.begin,
wasm = Some(wasm.begin),
)
.into(),
));
}
if Some(wasm.end) != standard_properties.end {
layer.status.push(WasmDiffStatus::Bad(
format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = "end",
emacs = standard_properties.end,
wasm = Some(wasm.end),
)
.into(),
));
}
if wasm.contents_begin != standard_properties.contents_begin {
layer.status.push(WasmDiffStatus::Bad(
format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = "contents-begin",
emacs = standard_properties.contents_begin,
wasm = wasm.contents_begin,
)
.into(),
));
}
if wasm.contents_end != standard_properties.contents_end {
layer.status.push(WasmDiffStatus::Bad(
format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = "contents-end",
emacs = standard_properties.contents_end,
wasm = wasm.contents_end,
)
.into(),
));
}
if Some(wasm.post_blank).map(|post_blank| post_blank as usize) != standard_properties.post_blank
{
layer.status.push(WasmDiffStatus::Bad(
format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = "post-blank",
emacs = standard_properties.post_blank,
wasm = Some(wasm.post_blank),
)
.into(),
));
}
result.children.push(layer);
Ok(result)
}