Progress on comparing properties in the wasm_compare macro.

This commit is contained in:
Tom Alexander
2023-12-27 15:58:31 -05:00
parent 5f1668702a
commit 5b02c21ebf
4 changed files with 69 additions and 6 deletions

View File

@@ -15,7 +15,7 @@ macro_rules! wasm_compare {
emacs_attributes_map.keys().map(|s| *s).collect();
{
// Compare name
// Compare name.
let wasm_name = $wasm.get_elisp_name();
if emacs_name != wasm_name {
@@ -31,7 +31,7 @@ macro_rules! wasm_compare {
}
{
// Compare children
// Compare children.
result.extend(wasm_compare_list(
$source,
emacs_list_iter,
@@ -40,7 +40,7 @@ macro_rules! wasm_compare {
}
{
// Compare fields
// Check for properties that are missing from the elisp node.
$(
match $emacs_field {
EmacsField::Required(name) if emacs_keys.contains(name) => {
@@ -63,6 +63,38 @@ macro_rules! wasm_compare {
)*
}
{
// 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
},
};
let result = $compare_fn($source, $emacs, $wasm, emacs_name, $wasm_value_getter)?;
// TODO: record this result.
)*
}
result
}};
}