Assume :standard-properties is an expected field.
This commit is contained in:
@@ -3,6 +3,7 @@ use std::borrow::Cow;
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::compare_field::compare_property_quoted_string_required_value;
|
||||
use super::elisp_fact::ElispFact;
|
||||
use super::elisp_fact::GetElispFact;
|
||||
use super::sexp::unquote;
|
||||
@@ -13,8 +14,8 @@ use super::util::get_property_boolean;
|
||||
use super::util::get_property_numeric;
|
||||
use super::util::get_property_quoted_string;
|
||||
use super::util::get_property_unquoted_atom;
|
||||
use crate::compare::compare_field::EmacsField;
|
||||
use crate::compare::macros::compare_properties;
|
||||
use crate::compare::macros::EmacsField;
|
||||
use crate::types::AngleLink;
|
||||
use crate::types::AstNode;
|
||||
use crate::types::BabelCall;
|
||||
@@ -126,7 +127,7 @@ pub struct DiffResult<'b, 's> {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
enum DiffStatus {
|
||||
pub(crate) enum DiffStatus {
|
||||
Good,
|
||||
Bad,
|
||||
}
|
||||
@@ -425,24 +426,6 @@ fn compare_ast_node<'b, 's>(
|
||||
Ok(compare_result.into())
|
||||
}
|
||||
|
||||
fn compare_property_quoted_string_required_value<'b, 's, 'x>(
|
||||
emacs: &'b Token<'s>,
|
||||
emacs_field: &'x str,
|
||||
rust_value: &'s str,
|
||||
) -> Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> {
|
||||
let value = get_property_quoted_string(emacs, emacs_field)?;
|
||||
if value.as_ref().map(String::as_str) != Some(rust_value) {
|
||||
let this_status = DiffStatus::Bad;
|
||||
let message = Some(format!(
|
||||
"{} mismatch (emacs != rust) {:?} != {:?}",
|
||||
emacs_field, value, rust_value
|
||||
));
|
||||
Ok(Some((this_status, message)))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn compare_document<'b, 's>(
|
||||
emacs: &'b Token<'s>,
|
||||
rust: &'b Document<'s>,
|
||||
@@ -2669,14 +2652,14 @@ fn compare_verbatim<'b, 's>(
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// Compare value
|
||||
let value = get_property_quoted_string(emacs, ":value")?;
|
||||
if value.as_ref().map(String::as_str) != Some(rust.contents) {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Value mismatch (emacs != rust) {:?} != {:?}",
|
||||
value, rust.contents
|
||||
));
|
||||
if let Some((new_status, new_message)) = compare_properties!(
|
||||
emacs,
|
||||
EmacsField::Required(":value"),
|
||||
rust.contents,
|
||||
compare_property_quoted_string_required_value
|
||||
)? {
|
||||
this_status = new_status;
|
||||
message = new_message;
|
||||
}
|
||||
|
||||
Ok(DiffResult {
|
||||
@@ -2698,16 +2681,6 @@ fn compare_code<'b, 's>(
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// Compare value
|
||||
let value = get_property_quoted_string(emacs, ":value")?;
|
||||
if value.as_ref().map(String::as_str) != Some(rust.contents) {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Value mismatch (emacs != rust) {:?} != {:?}",
|
||||
value, rust.contents
|
||||
));
|
||||
}
|
||||
|
||||
if let Some((new_status, new_message)) = compare_properties!(
|
||||
emacs,
|
||||
EmacsField::Required(":value"),
|
||||
|
||||
Reference in New Issue
Block a user