Add tests for names for lesser blocks.

This commit is contained in:
Tom Alexander 2023-10-04 19:37:14 -04:00
parent 258e9485de
commit 4fc81e983a
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
6 changed files with 29 additions and 5 deletions

View File

@ -0,0 +1,4 @@
#+NAME: foo
#+begin_comment text
bar
#+end_comment

View File

@ -0,0 +1,4 @@
#+NAME: foo
#+begin_export text
bar
#+end_export

View File

@ -0,0 +1,4 @@
#+NAME: foo
#+begin_verse text
bar
#+end_verse

View File

@ -1499,6 +1499,8 @@ fn compare_verse_block<'b, 's>(
let this_status = DiffStatus::Good;
let message = None;
// TODO: Compare :name
for (_emacs_child, _rust_child) in children.iter().skip(2).zip(rust.children.iter()) {}
Ok(DiffResult {
@ -1520,6 +1522,8 @@ fn compare_comment_block<'b, 's>(
let mut this_status = DiffStatus::Good;
let mut message = None;
// TODO: Compare :name
// Compare value
let contents = get_property_quoted_string(emacs, ":value")?.unwrap_or(String::new());
if contents != rust.contents {
@ -1715,7 +1719,7 @@ fn compare_export_block<'b, 's>(
let this_status = DiffStatus::Good;
let message = None;
// TODO: Compare :type :value
// TODO: Compare :type :value :name
Ok(DiffResult {
status: this_status,
@ -1736,6 +1740,8 @@ fn compare_src_block<'b, 's>(
let mut this_status = DiffStatus::Good;
let mut message = None;
// TODO: Compare :name
// Compare language
let language = get_property_quoted_string(emacs, ":language")?;
if language.as_ref().map(String::as_str) != rust.language {

View File

@ -93,7 +93,7 @@ pub(crate) fn verse_block<'b, 'g, 'r, 's>(
remaining,
VerseBlock {
source: source.into(),
name: name.into(),
name: None, // TODO
data: parameters.map(|parameters| Into::<&str>::into(parameters)),
children,
},
@ -129,6 +129,7 @@ pub(crate) fn comment_block<'b, 'g, 'r, 's>(
remaining,
CommentBlock {
source: source.into(),
name: None, // TODO
contents: contents.into(),
},
))
@ -182,6 +183,7 @@ pub(crate) fn example_block<'b, 'g, 'r, 's>(
remaining,
ExampleBlock {
source: source.into(),
name: None, // TODO
switches,
number_lines,
preserve_indent,
@ -227,7 +229,7 @@ pub(crate) fn export_block<'b, 'g, 'r, 's>(
remaining,
ExportBlock {
source: source.into(),
name: name.into(),
name: None, // TODO
data: parameters.map(|parameters| Into::<&str>::into(parameters)),
contents: contents.into(),
},
@ -287,6 +289,7 @@ pub(crate) fn src_block<'b, 'g, 'r, 's>(
remaining,
SrcBlock {
source: source.into(),
name: None, // TODO
language: language.map(Into::<&str>::into),
switches,
parameters: parameters.map(Into::<&str>::into),

View File

@ -24,7 +24,7 @@ pub struct TableCell<'s> {
#[derive(Debug)]
pub struct VerseBlock<'s> {
pub source: &'s str,
pub name: &'s str,
pub name: Option<&'s str>,
pub data: Option<&'s str>,
pub children: Vec<Object<'s>>,
}
@ -32,6 +32,7 @@ pub struct VerseBlock<'s> {
#[derive(Debug)]
pub struct CommentBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub contents: &'s str,
}
@ -48,6 +49,7 @@ pub enum RetainLabels {
#[derive(Debug)]
pub struct ExampleBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub switches: Option<&'s str>,
pub number_lines: Option<SwitchNumberLines>,
pub preserve_indent: Option<CharOffsetInLine>,
@ -60,7 +62,7 @@ pub struct ExampleBlock<'s> {
#[derive(Debug)]
pub struct ExportBlock<'s> {
pub source: &'s str,
pub name: &'s str,
pub name: Option<&'s str>,
pub data: Option<&'s str>,
pub contents: &'s str,
}
@ -68,6 +70,7 @@ pub struct ExportBlock<'s> {
#[derive(Debug)]
pub struct SrcBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub language: Option<&'s str>,
pub switches: Option<&'s str>,
pub parameters: Option<&'s str>,