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 this_status = DiffStatus::Good;
let message = None; let message = None;
// TODO: Compare :name
for (_emacs_child, _rust_child) in children.iter().skip(2).zip(rust.children.iter()) {} for (_emacs_child, _rust_child) in children.iter().skip(2).zip(rust.children.iter()) {}
Ok(DiffResult { Ok(DiffResult {
@ -1520,6 +1522,8 @@ fn compare_comment_block<'b, 's>(
let mut this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let mut message = None; let mut message = None;
// TODO: Compare :name
// Compare value // Compare value
let contents = get_property_quoted_string(emacs, ":value")?.unwrap_or(String::new()); let contents = get_property_quoted_string(emacs, ":value")?.unwrap_or(String::new());
if contents != rust.contents { if contents != rust.contents {
@ -1715,7 +1719,7 @@ fn compare_export_block<'b, 's>(
let this_status = DiffStatus::Good; let this_status = DiffStatus::Good;
let message = None; let message = None;
// TODO: Compare :type :value // TODO: Compare :type :value :name
Ok(DiffResult { Ok(DiffResult {
status: this_status, status: this_status,
@ -1736,6 +1740,8 @@ fn compare_src_block<'b, 's>(
let mut this_status = DiffStatus::Good; let mut this_status = DiffStatus::Good;
let mut message = None; let mut message = None;
// TODO: Compare :name
// Compare language // Compare language
let language = get_property_quoted_string(emacs, ":language")?; let language = get_property_quoted_string(emacs, ":language")?;
if language.as_ref().map(String::as_str) != rust.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, remaining,
VerseBlock { VerseBlock {
source: source.into(), source: source.into(),
name: name.into(), name: None, // TODO
data: parameters.map(|parameters| Into::<&str>::into(parameters)), data: parameters.map(|parameters| Into::<&str>::into(parameters)),
children, children,
}, },
@ -129,6 +129,7 @@ pub(crate) fn comment_block<'b, 'g, 'r, 's>(
remaining, remaining,
CommentBlock { CommentBlock {
source: source.into(), source: source.into(),
name: None, // TODO
contents: contents.into(), contents: contents.into(),
}, },
)) ))
@ -182,6 +183,7 @@ pub(crate) fn example_block<'b, 'g, 'r, 's>(
remaining, remaining,
ExampleBlock { ExampleBlock {
source: source.into(), source: source.into(),
name: None, // TODO
switches, switches,
number_lines, number_lines,
preserve_indent, preserve_indent,
@ -227,7 +229,7 @@ pub(crate) fn export_block<'b, 'g, 'r, 's>(
remaining, remaining,
ExportBlock { ExportBlock {
source: source.into(), source: source.into(),
name: name.into(), name: None, // TODO
data: parameters.map(|parameters| Into::<&str>::into(parameters)), data: parameters.map(|parameters| Into::<&str>::into(parameters)),
contents: contents.into(), contents: contents.into(),
}, },
@ -287,6 +289,7 @@ pub(crate) fn src_block<'b, 'g, 'r, 's>(
remaining, remaining,
SrcBlock { SrcBlock {
source: source.into(), source: source.into(),
name: None, // TODO
language: language.map(Into::<&str>::into), language: language.map(Into::<&str>::into),
switches, switches,
parameters: parameters.map(Into::<&str>::into), parameters: parameters.map(Into::<&str>::into),

View File

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