Add a debug assert for org entities being sorted.

This commit is contained in:
Tom Alexander 2023-10-11 09:24:20 -04:00
parent 6e39029f91
commit 0d1ab0e75a
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
5 changed files with 54 additions and 1 deletions

View File

@ -1,5 +1,5 @@
#+NAME: a #+NAME: a
#+caption: b #+caption: b *lorem* ipsum
#+results: c #+results: c
#+headers: d #+headers: d
#+header: e #+header: e
@ -12,4 +12,18 @@
#+tblname: l #+tblname: l
#+attr_latex: m #+attr_latex: m
#+attr_html: n #+attr_html: n
#+NAME: aa
#+caption: bb *lorem* ipsum
#+results: cc
#+headers: dd
#+header: ee
#+label: ff
#+plot: gg
#+resname: hh
#+result: ii
#+source: jj
#+srcname: kk
#+tblname: ll
#+attr_latex: mm
#+attr_html: nn
1. bar 1. bar

View File

@ -9,6 +9,7 @@ use crate::compare::diff::compare_ast_node;
use crate::compare::sexp::unquote; use crate::compare::sexp::unquote;
use crate::types::AstNode; use crate::types::AstNode;
use crate::types::GetStandardProperties; use crate::types::GetStandardProperties;
use crate::types::Keyword;
use crate::types::StandardProperties; use crate::types::StandardProperties;
/// Check if the child string slice is a slice of the parent string slice. /// Check if the child string slice is a slice of the parent string slice.
@ -337,3 +338,29 @@ where
} }
Ok(ComparePropertiesResult::NoChange) Ok(ComparePropertiesResult::NoChange)
} }
// pub(crate) fn compare_affiliated_keywords<'b, 's, RK, RV, RI>(
// emacs: &'b Token<'s>,
// rust_children: RI,
// ) -> Result<ComparePropertiesResult<'b, 's>, Box<dyn std::error::Error>>
// where
// RI: Iterator<Item = &'b Keyword<'s>> + ExactSizeIterator,
// {
// for kw in rust_children {
// }
// for (rust_key, rust_value) in rust_children {
// let rust_key = rust_key.as_ref();
// let rust_value = rust_value.as_ref();
// let emacs_value = get_property_quoted_string(emacs, rust_key)?;
// if Some(rust_value) != emacs_value.as_ref().map(String::as_str) {
// let this_status = DiffStatus::Bad;
// let message = Some(format!(
// "{} mismatch (emacs != rust) {:?} != {:?}",
// rust_key, emacs_value, rust_value
// ));
// return Ok(ComparePropertiesResult::SelfChange(this_status, message));
// }
// }
// Ok(ComparePropertiesResult::NoChange)
// }

View File

@ -71,6 +71,7 @@ pub struct EntityDefinition<'a> {
impl<'g, 's> GlobalSettings<'g, 's> { impl<'g, 's> GlobalSettings<'g, 's> {
fn new() -> GlobalSettings<'g, 's> { fn new() -> GlobalSettings<'g, 's> {
debug_assert!(DEFAULT_ORG_ENTITIES.is_sorted_by(|a, b| b.name.len().partial_cmp(&a.name.len())));
GlobalSettings { GlobalSettings {
radio_targets: Vec::new(), radio_targets: Vec::new(),
file_access: &LocalFileAccessInterface { file_access: &LocalFileAccessInterface {

View File

@ -1,6 +1,7 @@
#![feature(exit_status_error)] #![feature(exit_status_error)]
#![feature(trait_alias)] #![feature(trait_alias)]
#![feature(path_file_prefix)] #![feature(path_file_prefix)]
#![feature(is_sorted)]
// TODO: #![warn(missing_docs)] // TODO: #![warn(missing_docs)]
#[cfg(feature = "compare")] #[cfg(feature = "compare")]

View File

@ -219,3 +219,13 @@ impl<'s> TableRow<'s> {
} }
} }
} }
pub trait GetAffiliatedKeywords<'s> {
fn get_affiliated_keywords(&self) -> () {
// foo
}
}
// impl<'s> GetAffiliatedKeywords for PlainList<'s> {
// }