Compare row type.
This commit is contained in:
parent
e5a402ee1b
commit
b1244de1dc
@ -86,6 +86,7 @@ use crate::types::Superscript;
|
||||
use crate::types::Table;
|
||||
use crate::types::TableCell;
|
||||
use crate::types::TableRow;
|
||||
use crate::types::TableRowType;
|
||||
use crate::types::Target;
|
||||
use crate::types::Time;
|
||||
use crate::types::TimeUnit;
|
||||
@ -1427,12 +1428,23 @@ fn compare_table_row<'b, 's>(
|
||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||
let children = emacs.as_list()?;
|
||||
let mut child_status = Vec::new();
|
||||
let this_status = DiffStatus::Good;
|
||||
let message = None;
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// TODO: Compare :type
|
||||
//
|
||||
// :type is an unquoted atom of either standard or rule
|
||||
// Compare type
|
||||
let row_type = get_property_unquoted_atom(emacs, ":type")?;
|
||||
let rust_row_type = rust.get_type();
|
||||
match (row_type, &rust_row_type) {
|
||||
(Some("standard"), TableRowType::Standard) => {}
|
||||
(Some("rule"), TableRowType::Rule) => {}
|
||||
_ => {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Type mismatch (emacs != rust) {:?} != {:?}",
|
||||
row_type, rust_row_type
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
||||
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
|
||||
|
@ -111,6 +111,12 @@ pub struct TableRow<'s> {
|
||||
pub children: Vec<TableCell<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum TableRowType {
|
||||
Standard,
|
||||
Rule,
|
||||
}
|
||||
|
||||
impl<'s> StandardProperties<'s> for PlainList<'s> {
|
||||
fn get_source<'b>(&'b self) -> &'s str {
|
||||
self.source
|
||||
@ -194,3 +200,13 @@ impl<'s> PlainListItem<'s> {
|
||||
.map(|(checkbox_type, _)| checkbox_type)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> TableRow<'s> {
|
||||
pub fn get_type(&self) -> TableRowType {
|
||||
if self.children.is_empty() {
|
||||
TableRowType::Rule
|
||||
} else {
|
||||
TableRowType::Standard
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ pub use greater_element::QuoteBlock;
|
||||
pub use greater_element::SpecialBlock;
|
||||
pub use greater_element::Table;
|
||||
pub use greater_element::TableRow;
|
||||
pub use greater_element::TableRowType;
|
||||
pub use lesser_element::BabelCall;
|
||||
pub use lesser_element::Clock;
|
||||
pub use lesser_element::Comment;
|
||||
|
Loading…
Reference in New Issue
Block a user