Fix failing tests that were relying on the captured trailing whitespace.

This commit is contained in:
Tom Alexander 2023-04-22 00:19:01 -04:00
parent 9b66929c14
commit fbdf40fed0
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 9 additions and 10 deletions

View File

@ -110,6 +110,7 @@ mod tests {
use crate::parser::parser_context::ContextElement; use crate::parser::parser_context::ContextElement;
use crate::parser::parser_context::ContextTree; use crate::parser::parser_context::ContextTree;
use crate::parser::parser_with_context::parser_with_context; use crate::parser::parser_with_context::parser_with_context;
use crate::parser::Source;
use super::*; use super::*;
@ -123,21 +124,20 @@ line footnote.";
let initial_context: ContextTree<'_, '_> = ContextTree::new(); let initial_context: ContextTree<'_, '_> = ContextTree::new();
let document_context = let document_context =
initial_context.with_additional_node(ContextElement::DocumentRoot(input)); initial_context.with_additional_node(ContextElement::DocumentRoot(input));
let footnote_definition_matcher = let footnote_definition_matcher = parser_with_context!(element)(&document_context);
parser_with_context!(footnote_definition)(&document_context);
let (remaining, first_footnote_definition) = let (remaining, first_footnote_definition) =
footnote_definition_matcher(input).expect("Parse first footnote_definition"); footnote_definition_matcher(input).expect("Parse first footnote_definition");
let (remaining, second_footnote_definition) = let (remaining, second_footnote_definition) =
footnote_definition_matcher(remaining).expect("Parse second footnote_definition."); footnote_definition_matcher(remaining).expect("Parse second footnote_definition.");
assert_eq!(remaining, ""); assert_eq!(remaining, "");
assert_eq!( assert_eq!(
first_footnote_definition.source, first_footnote_definition.get_source(),
"[fn:1] A footnote. "[fn:1] A footnote.
" "
); );
assert_eq!( assert_eq!(
second_footnote_definition.source, second_footnote_definition.get_source(),
"[fn:2] A multi- "[fn:2] A multi-
line footnote." line footnote."
@ -155,13 +155,12 @@ not in the footnote.";
let initial_context: ContextTree<'_, '_> = ContextTree::new(); let initial_context: ContextTree<'_, '_> = ContextTree::new();
let document_context = let document_context =
initial_context.with_additional_node(ContextElement::DocumentRoot(input)); initial_context.with_additional_node(ContextElement::DocumentRoot(input));
let footnote_definition_matcher = let footnote_definition_matcher = parser_with_context!(element)(&document_context);
parser_with_context!(footnote_definition)(&document_context);
let (remaining, first_footnote_definition) = let (remaining, first_footnote_definition) =
footnote_definition_matcher(input).expect("Parse first footnote_definition"); footnote_definition_matcher(input).expect("Parse first footnote_definition");
assert_eq!(remaining, "not in the footnote."); assert_eq!(remaining, "not in the footnote.");
assert_eq!( assert_eq!(
first_footnote_definition.source, first_footnote_definition.get_source(),
"[fn:2] A multi- "[fn:2] A multi-
line footnote. line footnote.

View File

@ -370,7 +370,7 @@ mod tests {
let initial_context: ContextTree<'_, '_> = ContextTree::new(); let initial_context: ContextTree<'_, '_> = ContextTree::new();
let document_context = let document_context =
initial_context.with_additional_node(ContextElement::DocumentRoot(input)); initial_context.with_additional_node(ContextElement::DocumentRoot(input));
let plain_list_matcher = parser_with_context!(plain_list)(&document_context); let plain_list_matcher = parser_with_context!(element)(&document_context);
let (remaining, result) = let (remaining, result) =
plain_list_matcher(input).expect("Should parse the plain list successfully."); plain_list_matcher(input).expect("Should parse the plain list successfully.");
assert_eq!(remaining, " ipsum\n"); assert_eq!(remaining, " ipsum\n");
@ -396,7 +396,7 @@ baz"#;
let initial_context: ContextTree<'_, '_> = ContextTree::new(); let initial_context: ContextTree<'_, '_> = ContextTree::new();
let document_context = let document_context =
initial_context.with_additional_node(ContextElement::DocumentRoot(input)); initial_context.with_additional_node(ContextElement::DocumentRoot(input));
let plain_list_matcher = parser_with_context!(plain_list)(&document_context); let plain_list_matcher = parser_with_context!(element)(&document_context);
let (remaining, result) = let (remaining, result) =
plain_list_matcher(input).expect("Should parse the plain list successfully."); plain_list_matcher(input).expect("Should parse the plain list successfully.");
assert_eq!(remaining, "baz"); assert_eq!(remaining, "baz");
@ -427,7 +427,7 @@ dolar"#;
let initial_context: ContextTree<'_, '_> = ContextTree::new(); let initial_context: ContextTree<'_, '_> = ContextTree::new();
let document_context = let document_context =
initial_context.with_additional_node(ContextElement::DocumentRoot(input)); initial_context.with_additional_node(ContextElement::DocumentRoot(input));
let plain_list_matcher = parser_with_context!(plain_list)(&document_context); let plain_list_matcher = parser_with_context!(element)(&document_context);
let (remaining, result) = let (remaining, result) =
plain_list_matcher(input).expect("Should parse the plain list successfully."); plain_list_matcher(input).expect("Should parse the plain list successfully.");
assert_eq!(remaining, "dolar"); assert_eq!(remaining, "dolar");