Compare the properties of text markup.
This commit is contained in:
parent
627c785e24
commit
672848d06a
@ -2567,13 +2567,19 @@ fn compare_plain_text<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_bold<'b, 's>(
|
fn compare_bold<'b, 's>(
|
||||||
_source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b Bold<'s>,
|
rust: &'b Bold<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
|
let children = emacs.as_list()?;
|
||||||
let this_status = DiffStatus::Good;
|
let this_status = DiffStatus::Good;
|
||||||
|
let mut child_status = Vec::new();
|
||||||
let message = None;
|
let message = None;
|
||||||
|
|
||||||
|
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())?);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
name: rust.get_elisp_name(),
|
name: rust.get_elisp_name(),
|
||||||
@ -2586,13 +2592,19 @@ fn compare_bold<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_italic<'b, 's>(
|
fn compare_italic<'b, 's>(
|
||||||
_source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b Italic<'s>,
|
rust: &'b Italic<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
|
let children = emacs.as_list()?;
|
||||||
let this_status = DiffStatus::Good;
|
let this_status = DiffStatus::Good;
|
||||||
|
let mut child_status = Vec::new();
|
||||||
let message = None;
|
let message = None;
|
||||||
|
|
||||||
|
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())?);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
name: rust.get_elisp_name(),
|
name: rust.get_elisp_name(),
|
||||||
@ -2605,13 +2617,19 @@ fn compare_italic<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_underline<'b, 's>(
|
fn compare_underline<'b, 's>(
|
||||||
_source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b Underline<'s>,
|
rust: &'b Underline<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
|
let children = emacs.as_list()?;
|
||||||
let this_status = DiffStatus::Good;
|
let this_status = DiffStatus::Good;
|
||||||
|
let mut child_status = Vec::new();
|
||||||
let message = None;
|
let message = None;
|
||||||
|
|
||||||
|
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())?);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
name: rust.get_elisp_name(),
|
name: rust.get_elisp_name(),
|
||||||
@ -2628,10 +2646,18 @@ fn compare_verbatim<'b, 's>(
|
|||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b Verbatim<'s>,
|
rust: &'b Verbatim<'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 :value
|
// 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
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
@ -2649,10 +2675,18 @@ fn compare_code<'b, 's>(
|
|||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b Code<'s>,
|
rust: &'b Code<'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 :value
|
// 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
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
@ -2666,13 +2700,19 @@ fn compare_code<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_strike_through<'b, 's>(
|
fn compare_strike_through<'b, 's>(
|
||||||
_source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b StrikeThrough<'s>,
|
rust: &'b StrikeThrough<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
|
let children = emacs.as_list()?;
|
||||||
let this_status = DiffStatus::Good;
|
let this_status = DiffStatus::Good;
|
||||||
|
let mut child_status = Vec::new();
|
||||||
let message = None;
|
let message = None;
|
||||||
|
|
||||||
|
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())?);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
name: rust.get_elisp_name(),
|
name: rust.get_elisp_name(),
|
||||||
|
Loading…
Reference in New Issue
Block a user