Fix clippy.
All checks were successful
clippy Build clippy has succeeded
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-30 22:42:14 -05:00
parent 6b62176fd0
commit f4e0dddd9d
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
18 changed files with 80 additions and 231 deletions

View File

@ -127,7 +127,7 @@ spec:
- name: command
value: ["cargo", "fix"]
- name: args
value: ["--allow-dirty"]
value: ["--all-targets", "--all-features", "--allow-dirty"]
- name: docker-image
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
- name: commit-changes

View File

@ -30,7 +30,7 @@ endif
# NOTE: This target will write to folders underneath the git-root
.PHONY: run
run: build
docker run --rm --init --read-only --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME)
docker run --rm --init -t --read-only --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME)
.PHONY: shell
shell: build

View File

@ -11,13 +11,9 @@ pub use compare::run_compare_on_file;
pub use compare::run_compare_on_file_with_settings;
pub use compare::silent_anonymous_compare;
pub use compare::silent_compare_on_file;
pub use sexp::sexp;
pub(crate) use sexp::unquote;
pub(crate) use sexp::TextWithProperties;
pub use sexp::Token;
pub(crate) use util::maybe_token_to_usize;
pub(crate) use util::EmacsStandardProperties;

View File

@ -1,4 +1,3 @@
use std::collections::HashMap;
use serde::Deserialize;
@ -31,12 +30,6 @@ pub struct AdditionalProperties {
pub(crate) properties: HashMap<String, AdditionalPropertyValue>,
}
impl AdditionalProperties {
pub(crate) fn get_elisp_names<'c>(&'c self) -> impl Iterator<Item = String> + 'c {
self.properties.keys().map(move |key| format!(":{}", key))
}
}
to_wasm!(
AdditionalProperties,
AffiliatedKeywords<'s>,

View File

@ -8,8 +8,8 @@ use super::additional_property::AdditionalPropertyValue;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::util::elisp_fact::ElispFact;
use crate::types::Document;
use crate::util::elisp_fact::ElispFact;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
@ -29,7 +29,7 @@ to_wasm!(
{ WasmAstNode::Document(original) },
{ "org-data".into() },
{
let category = original.category.as_ref().map(String::as_str);
let category = original.category.as_deref();
let path = original.path.clone();
let mut additional_properties = AdditionalProperties::default();

View File

@ -8,12 +8,12 @@ use super::src_block::WasmNumberLinesWrapper;
use super::src_block::WasmRetainLabels;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::util::elisp_fact::ElispFact;
use crate::types::CharOffsetInLine;
use crate::types::ExampleBlock;
use crate::types::GetAffiliatedKeywords;
use crate::types::RetainLabels;
use crate::types::SwitchNumberLines;
use crate::util::elisp_fact::ElispFact;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
@ -58,7 +58,7 @@ to_wasm!(
inner: WasmNumberLines::New(n),
}),
Some(SwitchNumberLines::Continued(n)) => Some(WasmNumberLinesWrapper {
inner: WasmNumberLines::continued(n),
inner: WasmNumberLines::Continued(n),
}),
},
preserve_indent: original.preserve_indent,

View File

@ -6,11 +6,11 @@ use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use super::AdditionalPropertyValue;
use crate::util::elisp_fact::ElispFact;
use crate::types::Heading;
use crate::types::HeadlineLevel;
use crate::types::PriorityCookie;
use crate::types::TodoKeywordType;
use crate::util::elisp_fact::ElispFact;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
@ -112,7 +112,7 @@ to_wasm!(
.map(Into::<WasmAstNode>::into)
})
.map_or(Ok(None), |r| r.map(Some))?
.map(|child| Box::new(child)),
.map(Box::new),
deadline: original
.deadline
.as_ref()
@ -122,7 +122,7 @@ to_wasm!(
.map(Into::<WasmAstNode>::into)
})
.map_or(Ok(None), |r| r.map(Some))?
.map(|child| Box::new(child)),
.map(Box::new),
closed: original
.closed
.as_ref()
@ -132,7 +132,7 @@ to_wasm!(
.map(Into::<WasmAstNode>::into)
})
.map_or(Ok(None), |r| r.map(Some))?
.map(|child| Box::new(child)),
.map(Box::new),
pre_blank: Noop {},
},
))

View File

@ -23,6 +23,7 @@ macro_rules! to_wasm {
&self,
$wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>,
) -> Result<Self::Output, crate::error::CustomError> {
#[allow(unused_variables)]
let $original = self;
let standard_properties =
self.to_wasm_standard_properties($wasm_context.clone())?;
@ -38,9 +39,8 @@ macro_rules! to_wasm {
}
}
impl Into<WasmAstNode> for crate::wasm::ast_node::WasmAstNodeWrapper<$ostruct> {
fn into(self) -> WasmAstNode {
let $original = self;
impl From<crate::wasm::ast_node::WasmAstNodeWrapper<$ostruct>> for WasmAstNode {
fn from($original: crate::wasm::ast_node::WasmAstNodeWrapper<$ostruct>) -> Self {
let ret = $toastnodebody;
ret
}
@ -48,7 +48,6 @@ macro_rules! to_wasm {
impl<'s> crate::util::elisp_fact::ElispFact<'s> for $ostruct {
fn get_elisp_name<'b>(&'b self) -> std::borrow::Cow<'s, str> {
let $original = self;
let ret = $elispnamebody;
ret
}

View File

@ -4,11 +4,11 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::util::elisp_fact::ElispFact;
use crate::types::CheckboxType;
use crate::types::PlainListItem;
use crate::types::PlainListItemCounter;
use crate::types::PlainListItemPreBlank;
use crate::util::elisp_fact::ElispFact;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
@ -52,7 +52,7 @@ to_wasm!(
})
.collect::<Result<Vec<_>, _>>()?,
bullet: original.bullet.to_owned(),
counter: original.counter.clone(),
counter: original.counter,
checkbox: original.checkbox.as_ref().map(|(checkbox_type, _)| {
match checkbox_type {
CheckboxType::On => "on",

View File

@ -4,8 +4,8 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::util::elisp_fact::ElispFact;
use crate::types::PlainText;
use crate::util::elisp_fact::ElispFact;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]

View File

@ -4,8 +4,8 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::util::elisp_fact::ElispFact;
use crate::types::Planning;
use crate::util::elisp_fact::ElispFact;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
@ -35,7 +35,7 @@ to_wasm!(
.map(Into::<WasmAstNode>::into)
})
.map_or(Ok(None), |r| r.map(Some))?
.map(|child| Box::new(child)),
.map(Box::new),
deadline: original
.deadline
.as_ref()
@ -45,7 +45,7 @@ to_wasm!(
.map(Into::<WasmAstNode>::into)
})
.map_or(Ok(None), |r| r.map(Some))?
.map(|child| Box::new(child)),
.map(Box::new),
closed: original
.closed
.as_ref()
@ -55,7 +55,7 @@ to_wasm!(
.map(Into::<WasmAstNode>::into)
})
.map_or(Ok(None), |r| r.map(Some))?
.map(|child| Box::new(child)),
.map(Box::new),
},
))
}

View File

@ -5,13 +5,13 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::util::elisp_fact::ElispFact;
use crate::types::CharOffsetInLine;
use crate::types::GetAffiliatedKeywords;
use crate::types::LineNumber;
use crate::types::RetainLabels;
use crate::types::SrcBlock;
use crate::types::SwitchNumberLines;
use crate::util::elisp_fact::ElispFact;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
@ -46,7 +46,7 @@ pub(crate) enum WasmNumberLines {
#[serde(rename = "new")]
New(LineNumber),
#[serde(rename = "continued")]
continued(LineNumber),
Continued(LineNumber),
}
#[derive(Debug, Serialize, Deserialize)]
@ -83,7 +83,7 @@ to_wasm!(
inner: WasmNumberLines::New(n),
}),
Some(SwitchNumberLines::Continued(n)) => Some(WasmNumberLinesWrapper {
inner: WasmNumberLines::continued(n),
inner: WasmNumberLines::Continued(n),
}),
},
preserve_indent: original.preserve_indent,

View File

@ -7,9 +7,9 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::util::elisp_fact::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::Table;
use crate::util::elisp_fact::ElispFact;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
@ -26,7 +26,7 @@ pub struct WasmTable {
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "string-set")]
#[serde(rename = "string-set")]
struct WasmStringSet {
pub(crate) struct WasmStringSet {
value: BTreeSet<String>,
}

View File

@ -5,9 +5,9 @@ use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::util::elisp_fact::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::VerseBlock;
use crate::util::elisp_fact::ElispFact;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]

View File

@ -13,19 +13,19 @@ use crate::compare::Token;
use crate::wasm::WasmAstNodeWrapper;
use crate::wasm::WasmDocument;
pub fn wasm_compare_document<'e, 's, 'w>(
pub fn wasm_compare_document<'s>(
source: &'s str,
emacs: &'e Token<'s>,
wasm: &'w WasmAstNodeWrapper<WasmDocument>,
emacs: &Token<'s>,
wasm: &WasmAstNodeWrapper<WasmDocument>,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let wasm_json = serde_json::to_string(&wasm)?;
let wasm_json_parsed = serde_json::from_str(&wasm_json)?;
compare_json_value(source, emacs, &wasm_json_parsed)
}
fn compare_json_value<'b, 's>(
fn compare_json_value<'s>(
source: &'s str,
emacs: &'b Token<'s>,
emacs: &Token<'s>,
wasm: &serde_json::Value,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
// println!("XXXXXXXXXXXXXX compare_json_value XXXXXXXXXXXXXX");
@ -147,9 +147,9 @@ fn compare_json_value<'b, 's>(
}
}
fn compare_optional_json_value<'b, 's>(
fn compare_optional_json_value<'s>(
source: &'s str,
emacs: Option<&'b Token<'s>>,
emacs: Option<&Token<'s>>,
wasm: Option<&serde_json::Value>,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
match (emacs, wasm) {
@ -175,10 +175,10 @@ fn compare_optional_json_value<'b, 's>(
}
}
fn compare_ast_node<'e, 's, 'w>(
fn compare_ast_node<'s>(
source: &'s str,
emacs: &'e Vec<Token<'s>>,
wasm: &'w serde_json::Map<String, serde_json::Value>,
emacs: &[Token<'s>],
wasm: &serde_json::Map<String, serde_json::Value>,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default();
let mut emacs_list_iter = emacs.iter();
@ -277,11 +277,13 @@ fn compare_ast_node<'e, 's, 'w>(
{
// Compare attributes.
for attribute_name in wasm_attributes_map.keys() {
let mut layer = WasmDiffResult::default();
layer.name = Cow::Owned(attribute_name.clone());
let mut layer = WasmDiffResult::<'_> {
name: Cow::Owned(attribute_name.clone()),
..Default::default()
};
let wasm_attribute_value = wasm_attributes_map.get(attribute_name);
let emacs_key = wasm_key_to_emacs_key(attribute_name);
let emacs_attribute_value = emacs_attributes_map.get(emacs_key.as_str()).map(|e| *e);
let emacs_attribute_value = emacs_attributes_map.get(emacs_key.as_str()).copied();
let inner_layer =
compare_optional_json_value(source, emacs_attribute_value, wasm_attribute_value)?;
if !inner_layer.name.is_empty() {
@ -295,8 +297,10 @@ fn compare_ast_node<'e, 's, 'w>(
{
// Compare standard-properties.
let mut layer = WasmDiffResult::default();
layer.name = "standard-properties".into();
let mut layer = WasmDiffResult::<'_> {
name: "standard-properties".into(),
..Default::default()
};
let emacs_standard_properties = wasm_get_emacs_standard_properties(&emacs_attributes_map)?;
let wasm_standard_properties = wasm
.get("standard-properties")
@ -349,12 +353,13 @@ fn compare_ast_node<'e, 's, 'w>(
{
// Compare children.
let mut layer = WasmDiffResult::default();
layer.name = "children".into();
let mut layer = WasmDiffResult::<'_> {
name: "children".into(),
..Default::default()
};
if let Some(wasm_iter) = wasm
.get("children")
.map(|children| children.as_array())
.flatten()
.and_then(|children| children.as_array())
.map(|children| children.iter())
{
layer.extend(wasm_compare_list(source, emacs_list_iter, wasm_iter)?)?;
@ -375,10 +380,10 @@ fn wasm_key_to_emacs_key<WK: std::fmt::Display>(wasm_key: WK) -> String {
format!(":{key}", key = wasm_key)
}
fn compare_quoted_string<'e, 's, 'w>(
fn compare_quoted_string<'s>(
_source: &'s str,
emacs: &'e str,
wasm: &'w String,
emacs: &str,
wasm: &String,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default();
let emacs_text = unquote(emacs)?;
@ -448,10 +453,8 @@ where
{
let emacs_length = emacs.len();
let wasm_length = wasm.len();
if emacs_length == 1 && wasm_length == 0 {
if emacs.all(|t| matches!(t.as_atom(), Ok(r#""""#))) {
return Ok(WasmDiffResult::default());
}
if emacs_length == 1 && wasm_length == 0 && emacs.all(|t| matches!(t.as_atom(), Ok(r#""""#))) {
return Ok(WasmDiffResult::default());
}
if emacs_length != wasm_length {
return Ok(WasmDiffResult {
@ -479,10 +482,10 @@ where
})
}
fn compare_optional_pair<'e, 's, 'w>(
fn compare_optional_pair<'s>(
source: &'s str,
emacs: &'e Vec<Token<'s>>,
wasm: &'w serde_json::Map<String, serde_json::Value>,
emacs: &Vec<Token<'s>>,
wasm: &serde_json::Map<String, serde_json::Value>,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default();
let wasm_optval = wasm
@ -540,10 +543,10 @@ fn compare_optional_pair<'e, 's, 'w>(
Ok(result)
}
fn compare_object_tree<'e, 's, 'w>(
fn compare_object_tree<'s>(
source: &'s str,
emacs: &'e Vec<Token<'s>>,
wasm: &'w serde_json::Map<String, serde_json::Value>,
emacs: &[Token<'s>],
wasm: &serde_json::Map<String, serde_json::Value>,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default();
let wasm_attributes = wasm
@ -657,10 +660,10 @@ fn compare_object_tree<'e, 's, 'w>(
Ok(result)
}
fn compare_number_lines<'e, 's, 'w>(
fn compare_number_lines<'s>(
_source: &'s str,
emacs: &'e Vec<Token<'s>>,
wasm: &'w serde_json::Map<String, serde_json::Value>,
emacs: &[Token<'s>],
wasm: &serde_json::Map<String, serde_json::Value>,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default();
let mut emacs_iter = emacs.iter();
@ -669,8 +672,7 @@ fn compare_number_lines<'e, 's, 'w>(
.ok_or("Emacs number lines should have 3 children.")?
.as_atom()?;
let emacs_number: i64 = emacs_iter
.skip(1)
.next()
.nth(1)
.ok_or("Emacs number lines should have 3 children.")?
.as_atom()?
.parse()?;
@ -744,10 +746,10 @@ fn compare_number_lines<'e, 's, 'w>(
Ok(result)
}
fn compare_string_set<'e, 's, 'w>(
fn compare_string_set<'s>(
_source: &'s str,
emacs: &'e Vec<Token<'s>>,
wasm: &'w serde_json::Map<String, serde_json::Value>,
emacs: &[Token<'s>],
wasm: &serde_json::Map<String, serde_json::Value>,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default();
let wasm_list = wasm
@ -764,7 +766,7 @@ fn compare_string_set<'e, 's, 'w>(
.map(|v| v.as_atom())
.collect::<Result<Vec<_>, Box<dyn std::error::Error>>>()?
.into_iter()
.map(|s| unquote(s))
.map(unquote)
.collect::<Result<Vec<_>, Box<dyn std::error::Error>>>()?;
let emacs_strings = emacs_strings
.iter()
@ -788,7 +790,7 @@ fn compare_string_set<'e, 's, 'w>(
Ok(result)
}
fn is_plain_text<'e, 's, 'w>(wasm: &'w serde_json::Map<String, serde_json::Value>) -> bool {
fn is_plain_text(wasm: &serde_json::Map<String, serde_json::Value>) -> bool {
if let Some(serde_json::Value::String(node_type)) = wasm.get("ast-node") {
node_type == "plain-text"
} else {
@ -796,13 +798,15 @@ fn is_plain_text<'e, 's, 'w>(wasm: &'w serde_json::Map<String, serde_json::Value
}
}
fn compare_plain_text<'e, 's, 'w>(
fn compare_plain_text<'s>(
source: &'s str,
emacs: &'e TextWithProperties<'s>,
wasm: &'w serde_json::Map<String, serde_json::Value>,
emacs: &TextWithProperties<'s>,
wasm: &serde_json::Map<String, serde_json::Value>,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default();
result.name = "plain-text".into();
let mut result = WasmDiffResult::<'_> {
name: "plain-text".into(),
..Default::default()
};
if !is_plain_text(wasm) {
result.status.push(WasmDiffStatus::Bad(
format!(

View File

@ -12,6 +12,7 @@ pub struct WasmDiffResult<'s> {
#[derive(Debug)]
pub(crate) enum WasmDiffStatus {
#[allow(dead_code)]
Good,
Bad(Cow<'static, str>),
}
@ -50,7 +51,7 @@ impl<'s> WasmDiffResult<'s> {
fn print_indented(
&self,
indentation: usize,
original_document: &str,
_original_document: &str,
) -> Result<(), Box<dyn std::error::Error>> {
let status_text = {
if self.is_self_bad() {
@ -90,7 +91,7 @@ impl<'s> WasmDiffResult<'s> {
);
for child in self.children.iter() {
child.print_indented(indentation + 1, original_document)?;
child.print_indented(indentation + 1, _original_document)?;
}
Ok(())

View File

@ -1,143 +0,0 @@
macro_rules! wasm_compare {
($source:expr, $emacs:expr, $wasm:expr, $(($emacs_field:expr, $wasm_value_getter:expr, $compare_fn: expr)),*) => {{
let mut result = WasmDiffResult::default();
let emacs_list = $emacs.as_list()?;
let mut emacs_list_iter = emacs_list.iter();
let emacs_name = emacs_list_iter
.next()
.ok_or("Should have an attributes child.")?
.as_atom()?;
result.name = emacs_name.into();
let emacs_attributes_map = emacs_list_iter
.next()
.ok_or("Should have an attributes child.")?
.as_map()?;
let mut emacs_keys: std::collections::BTreeSet<&str> =
emacs_attributes_map.keys().map(|s| *s).collect();
// Mark :standard-properties as seen because it will be handled separately.
if emacs_keys.contains(":standard-properties") {
emacs_keys.remove(":standard-properties");
} else {
result.status.push(WasmDiffStatus::Bad(
"Emacs node lacked :standard-properties field.".into(),
));
}
{
// Compare name.
let wasm_name = $wasm.get_elisp_name();
if emacs_name != wasm_name {
result.status.push(WasmDiffStatus::Bad(
format!(
"AST node name mismatch. Emacs=({emacs}) Wasm=({wasm}).",
emacs = emacs_name,
wasm = wasm_name,
)
.into(),
));
}
}
{
// Compare standard properties.
result.extend(wasm_compare_standard_properties($source, $emacs, &$wasm.standard_properties)?)?;
}
{
// Compare additional properties.
let additional_property_names: Vec<String> = $wasm.additional_properties.get_elisp_names().collect();
for additional_property in additional_property_names.iter().map(String::as_str).map(EmacsField::Required) {
match additional_property {
EmacsField::Required(name) if emacs_keys.contains(name) => {
emacs_keys.remove(name);
}
EmacsField::Optional(name) if emacs_keys.contains(name) => {
emacs_keys.remove(name);
}
EmacsField::Required(name) => {
result.status.push(WasmDiffStatus::Bad(
format!(
"Emacs node lacked required field ({name}).",
name = name,
)
.into(),
));
}
EmacsField::Optional(_name) => {}
}
}
result.extend(wasm_compare_additional_properties($source, $emacs, &$wasm.additional_properties)?)?;
}
{
// Compare children.
result.extend(wasm_compare_list(
$source,
emacs_list_iter,
$wasm.children.iter(),
)?)?;
}
{
// Check for properties that are missing from the elisp node.
$(
match $emacs_field {
EmacsField::Required(name) if emacs_keys.contains(name) => {
emacs_keys.remove(name);
}
EmacsField::Optional(name) if emacs_keys.contains(name) => {
emacs_keys.remove(name);
}
EmacsField::Required(name) => {
result.status.push(WasmDiffStatus::Bad(
format!(
"Emacs node lacked required field ({name}).",
name = name,
)
.into(),
));
}
EmacsField::Optional(_name) => {}
}
)*
}
{
// Check for elisp properties that were not compared.
if !emacs_keys.is_empty() {
let unexpected_keys: Vec<&str> = emacs_keys.into_iter().collect();
let unexpected_keys = unexpected_keys.join(", ");
result.status.push(WasmDiffStatus::Bad(
format!(
"Emacs node had extra field(s): ({field_names}).",
field_names = unexpected_keys,
)
.into(),
));
}
}
{
// Compare properties.
$(
let emacs_name = match $emacs_field {
EmacsField::Required(name) => {
name
},
EmacsField::Optional(name) => {
name
},
};
result.extend($compare_fn($source, $emacs, $wasm, emacs_name, $wasm_value_getter)?)?;
)*
}
result
}};
}

View File

@ -1,6 +1,5 @@
mod compare;
mod diff;
mod macros;
mod runner;
pub use runner::wasm_run_anonymous_compare;