Starting to compare entity properties.

This commit is contained in:
Tom Alexander 2023-10-08 17:24:03 -04:00
parent 8a109276df
commit 1df6777b0b
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 52 additions and 5 deletions

View File

@ -5,6 +5,7 @@ use std::collections::BTreeSet;
use std::collections::HashSet; use std::collections::HashSet;
use super::compare_field::compare_identity; use super::compare_field::compare_identity;
use super::compare_field::compare_noop;
use super::compare_field::compare_property_always_nil; use super::compare_field::compare_property_always_nil;
use super::compare_field::compare_property_list_of_quoted_string; use super::compare_field::compare_property_list_of_quoted_string;
use super::compare_field::compare_property_quoted_string; use super::compare_field::compare_property_quoted_string;
@ -3115,10 +3116,56 @@ fn compare_entity<'b, 's>(
emacs: &'b Token<'s>, emacs: &'b Token<'s>,
rust: &'b Entity<'s>, rust: &'b Entity<'s>,
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
let this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let message = None; let mut message = None;
// TODO: Compare :name :latex :latex-math-p :html :ascii :latin1 :utf-8 :use-brackets-p if let Some((new_status, new_message)) = compare_properties!(
emacs,
rust,
(
EmacsField::Required(":name"),
|r| Some(r.name),
compare_property_quoted_string
),
(
EmacsField::Required(":latex"),
compare_identity,
compare_noop
),
(
EmacsField::Required(":latex-math-p"),
compare_identity,
compare_noop
),
(
EmacsField::Required(":html"),
compare_identity,
compare_noop
),
(
EmacsField::Required(":ascii"),
compare_identity,
compare_noop
),
(
EmacsField::Required(":latin1"),
compare_identity,
compare_noop
),
(
EmacsField::Required(":utf-8"),
compare_identity,
compare_noop
),
(
EmacsField::Required(":use-brackets-p"),
compare_identity,
compare_noop
)
)? {
this_status = new_status;
message = new_message;
}
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,

View File

@ -448,7 +448,7 @@ pub(crate) fn entity<'b, 'g, 'r, 's>(
remaining, remaining,
Entity { Entity {
source: source.into(), source: source.into(),
entity_name: entity_name.into(), name: entity_name.into(),
}, },
)) ))
} }

View File

@ -167,7 +167,7 @@ pub struct OrgMacro<'s> {
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub struct Entity<'s> { pub struct Entity<'s> {
pub source: &'s str, pub source: &'s str,
pub entity_name: &'s str, pub name: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]