Update test to use elements to capture the trailing whitespace.
This commit is contained in:
		
							parent
							
								
									7b7779ee7e
								
							
						
					
					
						commit
						9b66929c14
					
				| @ -4,7 +4,8 @@ use crate::init_tracing::shutdown_telemetry; | ||||
| use ::organic::parser::document; | ||||
| mod init_tracing; | ||||
| 
 | ||||
| const TEST_DOC: &'static str = include_str!("../toy_language.txt"); | ||||
| // const TEST_DOC: &'static str = include_str!("../toy_language.txt");
 | ||||
| const TEST_DOC: &'static str = "foo bar baz\n\nlorem ipsum"; | ||||
| 
 | ||||
| fn main() -> Result<(), Box<dyn std::error::Error>> { | ||||
|     init_telemetry()?; | ||||
|  | ||||
| @ -57,9 +57,11 @@ fn paragraph_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st | ||||
| 
 | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
|     use crate::parser::element_parser::paragraph_element; | ||||
|     use crate::parser::parser_context::ContextElement; | ||||
|     use crate::parser::parser_context::ContextTree; | ||||
|     use crate::parser::parser_with_context::parser_with_context; | ||||
|     use crate::parser::source::Source; | ||||
| 
 | ||||
|     use super::*; | ||||
| 
 | ||||
| @ -69,12 +71,12 @@ mod tests { | ||||
|         let initial_context: ContextTree<'_, '_> = ContextTree::new(); | ||||
|         let document_context = | ||||
|             initial_context.with_additional_node(ContextElement::DocumentRoot(input)); | ||||
|         let paragraph_matcher = parser_with_context!(paragraph)(&document_context); | ||||
|         let paragraph_matcher = parser_with_context!(paragraph_element)(&document_context); | ||||
|         let (remaining, first_paragraph) = paragraph_matcher(input).expect("Parse first paragraph"); | ||||
|         let (remaining, second_paragraph) = | ||||
|             paragraph_matcher(remaining).expect("Parse second paragraph."); | ||||
|         assert_eq!(remaining, ""); | ||||
|         assert_eq!(first_paragraph.source, "foo bar baz\n\n"); | ||||
|         assert_eq!(second_paragraph.source, "lorem ipsum"); | ||||
|         assert_eq!(first_paragraph.get_source(), "foo bar baz\n\n"); | ||||
|         assert_eq!(second_paragraph.get_source(), "lorem ipsum"); | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander